nocobase/scripts/auth.setup.ts

19 lines
675 B
TypeScript
Raw Normal View History

2023-09-09 00:14:28 +00:00
import { expect, test as setup } from '@playwright/test';
const adminFile = 'playwright/.auth/admin.json';
// 保存登录状态,避免每次都要登录
setup('admin', async ({ page }) => {
await page.goto('/');
await page.getByPlaceholder('Username/Email').click();
await page.getByPlaceholder('Username/Email').fill('admin@nocobase.com');
await page.getByPlaceholder('Password').click();
await page.getByPlaceholder('Password').fill('admin123');
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Super Admin')).toBeVisible();
// 保存登录状态
await page.context().storageState({ path: adminFile });
});