2022-03-28 20:06:41 +00:00
|
|
|
import { expect } from "@playwright/test";
|
|
|
|
|
|
|
|
import { test } from "./lib/fixtures";
|
2021-11-02 14:19:40 +00:00
|
|
|
|
2022-03-17 19:36:11 +00:00
|
|
|
test.describe("Login tests", () => {
|
|
|
|
// Using logged in state from globalSteup
|
|
|
|
test.use({ storageState: "playwright/artifacts/proStorageState.json" });
|
2021-11-02 14:19:40 +00:00
|
|
|
|
2022-03-28 20:06:41 +00:00
|
|
|
test("Login with pro@example.com", async ({ page }) => {
|
2022-03-17 19:36:11 +00:00
|
|
|
// Try to go homepage
|
|
|
|
await page.goto("/");
|
|
|
|
// It should redirect you to the event-types page
|
|
|
|
await page.waitForSelector("[data-testid=event-types]");
|
|
|
|
});
|
2022-03-28 20:06:41 +00:00
|
|
|
|
|
|
|
test("Should logout using the logout path", async ({ page, users }) => {
|
|
|
|
// creates a user and login
|
|
|
|
const pro = await users.create();
|
|
|
|
await pro.login();
|
|
|
|
|
|
|
|
// users.logout() action uses the logout route "/auth/logout" to clear the session
|
|
|
|
await users.logout();
|
|
|
|
|
|
|
|
// check if we are at the login page
|
|
|
|
await page.goto("/");
|
|
|
|
await expect(page.locator(`[data-testid=login-form]`)).toBeVisible();
|
|
|
|
});
|
2021-11-02 14:19:40 +00:00
|
|
|
});
|