Skip to content

Commit 7f866ac

Browse files
committed
feat(e2e): create e2e testing signin page form element
1 parent 6944485 commit 7f866ac

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"prepare": "husky",
1414
"test": "vitest",
1515
"test:coverage": "vitest run --coverage",
16-
"test:e2e": "playwright test --config=tests/setup/playwright.config.ts"
16+
"test:e2e": "playwright test --config=tests/setup/playwright.config.ts",
17+
"test:e2e:ui": "playwright test --config=tests/setup/playwright.config.ts --ui",
18+
"test:e2e:headed": "playwright test --config=tests/setup/playwright.config.ts --headed",
19+
"test:e2e:debug": "playwright test --config=tests/setup/playwright.config.ts --debug"
1720
},
1821
"husky": {
1922
"hooks": {

src/locales/id.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"enter-email": "Masukan Email",
6767
"enter-password": "Masukan Password",
6868
"no-account": "Apakah Belum Punya Akun?",
69-
"sign-in": "Sign In",
69+
"sign-in": "Masuk",
7070
"sign-up": "Sign Up",
7171
"forgot-password": "Lupa Password?"
7272
},

tests/e2e/auth/sign-in.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test.describe("Sign In Page", () => {
4+
test.describe("English (Default)", () => {
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto("/sign-in");
7+
});
8+
9+
test("should display sign in form elements", async ({ page }) => {
10+
await expect(page.getByRole("heading", { name: /welcome back 👋/i })).toBeVisible();
11+
await expect(page.getByText(/sign in to connect, learn, and grow together./i)).toBeVisible();
12+
13+
await expect(page.locator('input[name="email"]')).toBeVisible();
14+
await expect(page.locator('input[name="password"]')).toBeVisible();
15+
await expect(page.getByRole("button", { name: /sign in/i })).toBeVisible();
16+
17+
const forgotPasswordLink = page.getByRole("link", { name: /forgot password\?/i });
18+
await expect(forgotPasswordLink).toBeVisible();
19+
await expect(forgotPasswordLink).toHaveAttribute("href", "/en/forgot-password/");
20+
21+
const signUpLink = page.getByRole("link", { name: /sign up/i });
22+
await expect(signUpLink).toBeVisible();
23+
await expect(signUpLink).toHaveAttribute("href", "/en/sign-up/");
24+
});
25+
});
26+
});

tests/e2e/example.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test("has title", async ({ page }) => {
44
await page.goto("https://playwright.dev/");
55

66
// Expect a title "to contain" a substring.
7-
await expect(page).toHaveTitle(/Playwright/);
7+
await expect(page).toHaveTitle(/Playwrighasdasdt/);
88
});
99

1010
test("get started link", async ({ page }) => {

tests/setup/playwright.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineConfig({
2626
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2727
use: {
2828
/* Base URL to use in actions like `await page.goto('/')`. */
29-
// baseURL: 'http://localhost:3000',
29+
baseURL: "http://localhost:3000",
3030

3131
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3232
trace: "on-first-retry",
@@ -71,9 +71,9 @@ export default defineConfig({
7171
],
7272

7373
/* Run your local dev server before starting the tests */
74-
// webServer: {
75-
// command: 'npm run start',
76-
// url: 'http://localhost:3000',
77-
// reuseExistingServer: !process.env.CI,
78-
// },
74+
webServer: {
75+
command: "pnpm run dev",
76+
url: "http://localhost:3000",
77+
reuseExistingServer: !process.env.CI,
78+
},
7979
});

0 commit comments

Comments
 (0)