Skip to content

Commit

Permalink
fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Oct 10, 2024
1 parent 152f5fa commit 74d67e2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 55 deletions.
4 changes: 1 addition & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
80 changes: 28 additions & 52 deletions e2e/tests/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<User, "email" | "password" | "partnerName"> = {
email: "[email protected]",
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 }) => {
Expand Down Expand Up @@ -49,42 +64,3 @@ test.afterAll(async () => {
// user.email,
// );
// });

test("an user signs in successfully", async ({ page }) => {
const user: Pick<User, "email" | "password" | "partnerName"> = {
email: "[email protected]",
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("[email protected]");
await page.getByPlaceholder("*******").click();
await page.getByPlaceholder("*******").fill("12345678");
await page.getByRole("button", { name: "Log in" }).click();
});
// test("test", async ({ page }) => {
// const user: Pick<User, "email" | "password" | "partnerName"> = {
// email: "[email protected]",
// 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();
// });

0 comments on commit 74d67e2

Please sign in to comment.