1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-13 00:50:13 +00:00

add e2e tests

This commit is contained in:
Elias Schneider
2026-01-11 00:14:25 +01:00
parent dd8e4dec6c
commit d318b02ea0
6 changed files with 80 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
import test, { expect } from '@playwright/test';
import { users } from '../data';
import { emailVerificationTokens, users } from '../data';
import authUtil from '../utils/auth.util';
import { cleanupBackend } from '../utils/cleanup.util';
import passkeyUtil from '../utils/passkey.util';
@@ -128,3 +128,31 @@ test('Generate own one time access token as non admin', async ({ page, context }
await page.goto(link!);
await page.waitForURL('/settings/account');
});
test('Email verification succeeds', async ({ page, context }) => {
await context.clearCookies();
const token = emailVerificationTokens.find((t) => !t.expired)!.token;
await page.goto(`/verify-email?token=${token}`);
await (await passkeyUtil.init(page)).addPasskey('craig');
await page.getByRole('button', { name: 'Authenticate' }).click();
await page.waitForURL('/settings/account?emailVerificationState=success');
await expect(page.getByText('Email Verified Successfully')).toBeVisible();
});
test('Email verification fails with expired token', async ({ page, context }) => {
await context.clearCookies();
const token = emailVerificationTokens.find((t) => t.expired)!.token;
await page.goto(`/verify-email?token=${token}`);
await (await passkeyUtil.init(page)).addPasskey('craig');
await page.getByRole('button', { name: 'Authenticate' }).click();
await page.waitForURL(
'/settings/account?emailVerificationState=Invalid+email+verification+token'
);
await expect(page.getByText('Invalid email verification token')).toBeVisible();
});

View File

@@ -113,7 +113,7 @@ test('End session without id token hint shows confirmation page', async ({ page
await expect(page).toHaveURL('/logout');
await page.getByRole('button', { name: 'Sign out' }).click();
await expect(page).toHaveURL('/login?redirect=%2F"');
await expect(page).toHaveURL('/login?redirect=%2F');
});
test('End session with id token hint redirects to callback URL', async ({ page }) => {