Files
gym-manage/gym-manage-web/e2e/helpers/auth.ts
T
张翔 d2cef85187 docs: add test report and database reset scripts
- Add comprehensive test report (TEST_REPORT.md)
- Add database reset scripts for testing
- Update .gitignore to exclude temporary files
- Add frontend e2e test utilities and configuration
2026-04-23 16:36:12 +08:00

24 lines
682 B
TypeScript

import { Page } from '@playwright/test';
export async function loginAsAdmin(page: Page) {
await page.goto('/login');
await page.waitForLoadState('networkidle');
await page.locator('input[placeholder*="用户名"]').fill('admin');
await page.locator('input[placeholder*="密码"]').fill('Test@123');
await page.locator('button:has-text("登录")').click();
await page.waitForURL('**/dashboard', { timeout: 30000 });
const token = await page.evaluate(() => {
return localStorage.getItem('token') || '';
});
return token;
}
export async function saveAuthState(page: Page) {
const storage = await page.context().storageState();
return storage;
}