2024-12-13 09:03:52 +01:00
|
|
|
import test, { expect } from '@playwright/test';
|
|
|
|
|
import { oneTimeAccessTokens } from './data';
|
2025-03-10 12:45:45 +01:00
|
|
|
import { cleanupBackend } from './utils/cleanup.util';
|
|
|
|
|
|
|
|
|
|
test.beforeEach(cleanupBackend);
|
2024-12-13 09:03:52 +01:00
|
|
|
|
|
|
|
|
// Disable authentication for these tests
|
|
|
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
|
|
2025-03-10 12:45:45 +01:00
|
|
|
test('Sign in with login code', async ({ page }) => {
|
2024-12-13 09:03:52 +01:00
|
|
|
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
|
2025-03-10 12:45:45 +01:00
|
|
|
await page.goto(`/lc/${token.token}`);
|
2024-12-13 09:03:52 +01:00
|
|
|
|
|
|
|
|
await page.waitForURL('/settings/account');
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-10 12:45:45 +01:00
|
|
|
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.getByText('Submit').first().click();
|
|
|
|
|
|
|
|
|
|
await page.waitForURL('/settings/account');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Sign in with expired login code fails', async ({ page }) => {
|
2024-12-13 09:03:52 +01:00
|
|
|
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
|
2025-03-10 12:45:45 +01:00
|
|
|
await page.goto(`/lc/${token.token}`);
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
await page.getByPlaceholder('Code').first().fill(token.token);
|
|
|
|
|
|
|
|
|
|
await page.getByText('Submit').first().click();
|
2024-12-13 09:03:52 +01:00
|
|
|
|
2025-01-19 15:41:16 +01:00
|
|
|
await expect(page.getByRole('paragraph')).toHaveText(
|
|
|
|
|
'Token is invalid or expired. Please try again.'
|
|
|
|
|
);
|
2024-12-13 09:03:52 +01:00
|
|
|
});
|