auth.setup.ts 751 B

12345678910111213141516171819202122
  1. import { test as setup, expect } from '@playwright/test';
  2. const authFile = 'playwright/.auth/admin.json';
  3. setup('Authenticate as the "admin" user', async({ page }) => {
  4. // Perform authentication steps. Replace these actions with your own.
  5. await page.goto('/admin');
  6. const loginForm = await page.$('form#login-form');
  7. if (loginForm != null) {
  8. await page.getByLabel('Username or E-mail').fill('admin');
  9. await page.getByLabel('Password').fill('adminadmin');
  10. await page.locator('[type=submit]').filter({ hasText: 'Login' }).click();
  11. }
  12. await page.waitForURL('/admin');
  13. await expect(page).toHaveTitle(/Wiki Management Homepage/);
  14. // End of authentication steps.
  15. await page.context().storageState({ path: authFile });
  16. });