Skip to content

Commit

Permalink
feat: move/update/fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Arce <[email protected]>
  • Loading branch information
raphael-arce committed Oct 11, 2024
1 parent b9ebff8 commit a26e555
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ permissions:
packages: write
on:
push:
branches: [main]
branches: [main, staging]
pull_request:
branches: [main]
branches: [main, staging]
workflow_dispatch:
inputs:
debug_enabled:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dist-ssr
*.njsproj
*.sln
*.sw?
/test-results/
**/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"prettier:ci": "prettier --check .",
"preview": "vite preview",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "vitest run",
"test:e2e": "playwright test"
"test:unit": "vitest run --config ./tests/unit/vitest.config.ts",
"test:e2e": "playwright test --config=tests/e2e/playwright.config.ts"
},
"dependencies": {
"@supabase/supabase-js": "2.43.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect, test } from "@playwright/test";
import {
baseUrl,
defaultEmail,
defaultInbucketEmailUsername,
defaultPassword,
Expand All @@ -13,7 +12,6 @@ import {

test.describe("Setup", () => {
test("should check if all environment/default variables are set", () => {
expect(baseUrl).toBeDefined();
expect(supabaseApiUrl).not.toBe("");
expect(supabaseAnonKey).not.toBe("");
expect(inbucketUrl).not.toBe("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
registerThenLoginWithDefaultAccount,
} from "./utils.ts";
import {
baseUrl,
changedEmail,
changedInbucketEmailUsername,
defaultEmail,
Expand All @@ -14,20 +13,20 @@ import {
defaultUsername,
inbucketUrl,
supabaseClient,
} from "./constants.ts";
} from "../constants.ts";

test.describe("Edit user", () => {
test.describe("Edit Username", () => {
test.beforeEach(async ({ page }) => {
await registerThenLoginWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLoginWithDefaultAccount({ page, isMobile });
});

test.afterEach(async () => {
await deleteDefaultAccount();
});

test("should be able to edit username", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page
.locator("div")
Expand All @@ -47,16 +46,16 @@ test.describe("Edit user", () => {
});

test.describe("Edit Email", () => {
test.beforeEach(async ({ page }) => {
await registerThenLoginWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLoginWithDefaultAccount({ page, isMobile });
});

test.afterEach(async () => {
await deleteChangedEmailAccount();
});

test("should be able to edit e-mail", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page
.locator("div")
Expand Down Expand Up @@ -87,16 +86,16 @@ test.describe("Edit user", () => {
});

test.describe("Edit password", () => {
test.beforeEach(async ({ page }) => {
await registerThenLoginWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLoginWithDefaultAccount({ page, isMobile });
});

test.afterEach(async () => {
await deleteDefaultAccount();
});

test("should be able to edit password", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByRole("button", { name: "Passwort ändern" }).click();
await page.getByRole("button", { name: "OK" }).click();
Expand All @@ -114,12 +113,12 @@ test.describe("Edit user", () => {
});

test.describe("Delete account", () => {
test.beforeEach(async ({ page }) => {
await registerThenLoginWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLoginWithDefaultAccount({ page, isMobile });
});

test("should be able to delete account", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByRole("button", { name: "Account löschen" }).click();
await page.getByRole("button", { name: "Löschen", exact: true }).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ import {
registerThenLogoutWithDefaultAccount,
} from "./utils";
import {
baseUrl,
defaultEmail,
defaultInbucketEmailUsername,
defaultPassword,
inbucketUrl,
} from "./constants";
} from "../constants";

test.describe("Forgot password", () => {
test.describe("Happy Case", () => {
test.beforeEach(async ({ page }) => {
await registerThenLogoutWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLogoutWithDefaultAccount({ page, isMobile });
});
test.afterEach(async () => {
await deleteDefaultAccount();
});

test("should be able to reset password via e-mail", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);
await page.getByRole("link", { name: "Passwort vergessen?" }).click();
await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill(defaultEmail);
Expand Down Expand Up @@ -59,7 +58,7 @@ test.describe("Forgot password", () => {
test("should not be able to reset password with empty email", async ({
page,
}) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);
await page.getByRole("link", { name: "Passwort vergessen?" }).click();

await page.getByLabel("E-Mail").click();
Expand All @@ -72,7 +71,7 @@ test.describe("Forgot password", () => {
test("should not be able to reset password with invalid email format", async ({
page,
}) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);
await page.getByRole("link", { name: "Passwort vergessen?" }).click();

await page.getByLabel("E-Mail").click();
Expand All @@ -84,7 +83,7 @@ test.describe("Forgot password", () => {
test('should not be able to reset password by going on "profile/reset-password" directly', async ({
page,
}) => {
await page.goto(`${baseUrl}/profile/reset-password`);
await page.goto(`/profile/reset-password`);

await page.goto("http://localhost:5173/profile/reset-password");
await expect(
Expand All @@ -100,7 +99,7 @@ test.describe("Forgot password", () => {
page.getByText("Hinweis: Diese Seite kann nur"),
).toBeVisible();
await page.getByRole("button", { name: "Zurück zur Startseite" }).click();
await expect(page).toHaveURL(new RegExp(`${baseUrl}/map.*`));
await expect(page).toHaveURL(new RegExp(`/map.*`));
});
});

Expand All @@ -112,7 +111,7 @@ test.describe("Forgot password", () => {
const browserContext = await browser.newContext();
const page = await browserContext.newPage();

await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);
await page.getByRole("link", { name: "Passwort vergessen?" }).click();

await page.getByLabel("E-Mail").click();
Expand All @@ -129,8 +128,8 @@ test.describe("Forgot password", () => {
});

test.describe("Reset password page", () => {
test.beforeEach(async ({ page }) => {
await registerThenLogoutWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLogoutWithDefaultAccount({ page, isMobile });
});
test.afterEach(async () => {
await deleteDefaultAccount();
Expand All @@ -142,7 +141,7 @@ test.describe("Forgot password", () => {
const browserContext = await browser.newContext();
const page = await browserContext.newPage();

await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);
await page.getByRole("link", { name: "Passwort vergessen?" }).click();
await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill(defaultEmail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import {
deleteDefaultAccount,
registerThenLogoutWithDefaultAccount,
} from "./utils";
import { baseUrl, defaultEmail, defaultPassword } from "./constants";
import { defaultEmail, defaultPassword } from "../constants";

test.describe("Login", () => {
test.describe("Happy Case", () => {
test.beforeEach(async ({ page }) => {
await registerThenLogoutWithDefaultAccount(page);
test.beforeEach(async ({ page, isMobile }) => {
await registerThenLogoutWithDefaultAccount({ page, isMobile });
});
test.afterEach(async () => {
await deleteDefaultAccount();
});

test("should be able to log-in then log-out", async ({ page }) => {
await page.goto(`${baseUrl}/map`);
await page.goto(`/map`);

// Go to profile
await page.getByRole("link", { name: "Profil" }).click();
Expand All @@ -39,7 +39,7 @@ test.describe("Login", () => {

test.describe("Client-Side Validation", () => {
test("should not be able to log-in with empty email", async ({ page }) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill(" ");
Expand All @@ -54,7 +54,7 @@ test.describe("Login", () => {
test("should not be able to log-in with invalid email format", async ({
page,
}) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill("invalid-email");
Expand All @@ -68,7 +68,7 @@ test.describe("Login", () => {
test("should not be able to log-in with empty password", async ({
page,
}) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill("invalid-email");
Expand All @@ -85,7 +85,7 @@ test.describe("Login", () => {
test("should not be able to log-in with wrong email/password credentials", async ({
page,
}) => {
await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill("[email protected]");
Expand All @@ -108,7 +108,7 @@ test.describe("Login", () => {
const browserContext = await browser.newContext();
const page = await browserContext.newPage();

await page.goto(`${baseUrl}/profile`);
await page.goto(`/profile`);

await page.getByLabel("E-Mail").click();
await page.getByLabel("E-Mail").fill(defaultEmail);
Expand Down
Loading

0 comments on commit a26e555

Please sign in to comment.