diff --git a/e2e/package.json b/e2e/package.json index 7006a817..d99c4107 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -15,8 +15,6 @@ "pretest": "tsc && tsc-alias", "test": "playwright test -c ./dist/e2e", "test:ui": "pnpm pretest && playwright test --ui -c ./dist/e2e", - "codegen": "pnpm --filter api start:dev & pnpm --filter client dev & playwright codegen localhost:3000", - "codegen:prod": "pnpm --filter api run build & NODE_ENV=test pnpm --filter api run start:prod & NODE_ENV=test pnpm --filter client run build & NODE_ENV=test pnpm --filter client run start & playwright codegen localhost:3000", - "test2": "playwright test" + "codegen": "pnpm --filter api start:dev & pnpm --filter client dev & playwright codegen localhost:3000" } } diff --git a/e2e/tests/auth/auth.spec.ts b/e2e/tests/auth/auth.spec.ts index 11f6375d..cebb0ae6 100644 --- a/e2e/tests/auth/auth.spec.ts +++ b/e2e/tests/auth/auth.spec.ts @@ -5,22 +5,37 @@ import { User } from "@shared/entities/users/user.entity"; let testManager: E2eTestManager; let page: Page; -test.beforeAll(async ({ browser }) => { - page = await browser.newPage(); - testManager = await E2eTestManager.load(page); -}); +test.describe.configure({ mode: "serial" }); -test.beforeEach(async () => { - await testManager.clearDatabase(); -}); +test.describe("Auth", () => { + test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); + testManager = await E2eTestManager.load(page); + }); -test.afterEach(async () => { - //await testManager.clearDatabase(); -}); + test.beforeEach(async () => { + await testManager.clearDatabase(); + }); -test.afterAll(async () => { - await testManager.logout(); - await testManager.close(); + test.afterEach(async () => { + // await testManager.clearDatabase(); + }); + + test.afterAll(async () => { + //await testManager.logout(); + await testManager.close(); + }); + + test("an user signs in successfully", async () => { + const user: Pick = { + email: "jhondoe@test.com", + password: "12345678", + partnerName: "admin", + }; + await testManager.mocks().createUser(user); + await testManager.login(user as User); + await expect(page.getByText(`Email: ${user.email}`)).toBeVisible(); + }); }); // test("an user signs up successfully", async ({ page }) => { @@ -49,42 +64,3 @@ test.afterAll(async () => { // user.email, // ); // }); - -test("an user signs in successfully", async ({ page }) => { - const user: Pick = { - email: "jhondoe@test.com", - password: "12345678", - partnerName: "admin", - }; - - await testManager.mocks().createUser(user); - await page.goto("/auth/signin"); - await page.getByLabel("Email").fill(user.email); - await page.locator('input[type="password"]').fill(user.password); - await page.getByRole("button", { name: /log in/i }).click(); -}); - -test("test", async ({ page }) => { - await page.goto("http://localhost:3000/"); - await page.getByRole("link", { name: "Sign in" }).click(); - await page.getByPlaceholder("Enter your email").click(); - await page.getByPlaceholder("Enter your email").fill("jhondoe@test.com"); - await page.getByPlaceholder("*******").click(); - await page.getByPlaceholder("*******").fill("12345678"); - await page.getByRole("button", { name: "Log in" }).click(); -}); -// test("test", async ({ page }) => { -// const user: Pick = { -// email: "jhondoe@test.com", -// password: "12345678", -// partnerName: "admin", -// }; -// await page.goto("http://localhost:3000/"); -// await page.getByRole("link", { name: "Sign in" }).click(); -// await page.getByPlaceholder("Enter your email").click(); -// await page.getByPlaceholder("Enter your email").fill(user.email); -// await page.getByPlaceholder("*******").click(); -// await page.getByPlaceholder("*******").fill(user.password); -// await page.getByRole("button", { name: "Log in" }).click(); -// await expect(page.getByText(`Email: ${user.email}`)).toBeVisible(); -// });