Login.ts 787 B

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