tests: add e2e test for one time access tokens

This commit is contained in:
Elias Schneider
2024-12-13 09:03:52 +01:00
parent bad901ea2b
commit 5480ab0f18
3 changed files with 49 additions and 0 deletions

View File

@@ -55,3 +55,8 @@ export const userGroups = {
name: 'human_resources'
}
};
export const oneTimeAccessTokens = [
{ token: 'HPe6k6uiDRRVuAQV', expired: false },
{ token: 'YCGDtftvsvYWiXd0', expired: true }
];

View File

@@ -0,0 +1,21 @@
import test, { expect } from '@playwright/test';
import { oneTimeAccessTokens } from './data';
// Disable authentication for these tests
test.use({ storageState: { cookies: [], origins: [] } });
test('Sign in with one time access token', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => !t.expired)[0];
await page.goto(`/login/${token.token}`);
await page.getByRole('button', { name: 'Continue' }).click();
await page.waitForURL('/settings/account');
});
test('Sign in with expired one time access token fails', async ({ page }) => {
const token = oneTimeAccessTokens.filter((t) => t.expired)[0];
await page.goto(`/login/${token.token}`);
await page.getByRole('button', { name: 'Continue' }).click();
await expect(page.getByRole('status')).toHaveText('Token is invalid or expired');
});