adds playwright tests
This commit is contained in:
19
web/tests/playwright/auth.setup.ts
Normal file
19
web/tests/playwright/auth.setup.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { test as setup } from '@playwright/test';
|
||||
|
||||
const authFile = 'playwright/.auth/user.json';
|
||||
|
||||
setup('authenticate', async ({ page }) => {
|
||||
await page.goto('/login', { waitUntil: 'networkidle' });
|
||||
await page.locator('input[name="username"]').fill('Test');
|
||||
await page.locator('input[name="password"]').fill('password');
|
||||
await page.getByRole('button', { name: 'Login' }).click();
|
||||
// Wait until the page receives the cookies.
|
||||
//
|
||||
// Sometimes login flow sets cookies in the process of several redirects.
|
||||
// Wait for the final URL to ensure that the cookies are actually set.
|
||||
await page.waitForURL('/');
|
||||
|
||||
// End of authentication steps.
|
||||
|
||||
await page.context().storageState({ path: authFile });
|
||||
});
|
||||
Reference in New Issue
Block a user