1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-15 05:15:14 +00:00

refactor: add formatter to Playwright tests

This commit is contained in:
Elias Schneider
2025-06-27 23:33:26 +02:00
parent d070b9a778
commit 73e7e0b1c5
22 changed files with 1581 additions and 1764 deletions

View File

@@ -1,48 +1,48 @@
import test, { expect } from "@playwright/test";
import { oneTimeAccessTokens } from "../data";
import { cleanupBackend } from "../utils/cleanup.util";
import test, { expect } from '@playwright/test';
import { oneTimeAccessTokens } from '../data';
import { cleanupBackend } from '../utils/cleanup.util';
test.beforeEach(cleanupBackend);
// Disable authentication for these tests
test.use({ storageState: { cookies: [], origins: [] } });
test("Sign in with login code", async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
await page.goto(`/lc/${token.token}`);
test('Sign in with login code', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
await page.goto(`/lc/${token.token}`);
await page.waitForURL("/settings/account");
await page.waitForURL('/settings/account');
});
test("Sign in with login code entered manually", async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
await page.goto("/lc");
test('Sign in with login code entered manually', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
await page.goto('/lc');
await page.getByPlaceholder("Code").first().fill(token.token);
await page.getByPlaceholder('Code').first().fill(token.token);
await page.getByText("Submit").first().click();
await page.getByText('Submit').first().click();
await page.waitForURL("/settings/account");
await page.waitForURL('/settings/account');
});
test("Sign in with expired login code fails", async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
await page.goto(`/lc/${token.token}`);
test('Sign in with expired login code fails', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
await page.goto(`/lc/${token.token}`);
await expect(page.getByRole("paragraph")).toHaveText(
"Token is invalid or expired. Please try again."
);
await expect(page.getByRole('paragraph')).toHaveText(
'Token is invalid or expired. Please try again.'
);
});
test("Sign in with login code entered manually fails", async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
await page.goto("/lc");
test('Sign in with login code entered manually fails', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
await page.goto('/lc');
await page.getByPlaceholder("Code").first().fill(token.token);
await page.getByPlaceholder('Code').first().fill(token.token);
await page.getByText("Submit").first().click();
await page.getByText('Submit').first().click();
await expect(page.getByRole("paragraph")).toHaveText(
"Token is invalid or expired. Please try again."
);
await expect(page.getByRole('paragraph')).toHaveText(
'Token is invalid or expired. Please try again.'
);
});