nocobase/scripts/auth.setup.ts
Zeke Zhang 3b7c1345cc
test(e2e): add tests for client (#3144)
* test: add tests for lazy loading of association fields

* refactor: migrate

* test: add tests for page

* test: add tests for page menu

* test: add tests for tabs

* test: add tests for detail block

* test: add tests for list block

* test: add tests for grid card block

* test: add tests for filter collapse block

* test: add tests for markdown block

* test: add tests for table block

* test: add tests for table block

* test: add tests for lazy loading of association fields

* test: add tests for data scope

* test: add tests for filter block

* test: add tests for block template

* test: add tests for drag and sorting

* test: add tests for sorting rules

* test: make testing more stable

* Revert "test: make testing more stable"

This reverts commit 78b7badeb6.

* perf: remove enableToConfig

* test: make testing more stable

* test: make testing more stable

* test: delete newly created records to make tests more stable

* fix: fix error when deleting records

* test: make testing more stable

* test: make testing more stable

* test: fix tests

* refactor: optimize file structure

* test: fix tests

* test: fix tests

* refactor: optimize description

* refactor: optimize description

* refactor: use __e2e__ as the root directory for test files

* fix: fix build

* test: make testing more stable
2023-12-13 14:14:33 +08:00

29 lines
964 B
TypeScript

import { expect, test as setup } from '@playwright/test';
import dotenv from 'dotenv';
import path from 'path';
const adminFile = 'playwright/.auth/admin.json';
// 加载变量
dotenv.config({ path: path.resolve(process.cwd(), '.env.e2e') });
// 保存登录状态,避免每次都要登录
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.getByTestId('user-center-button').getByText('Super Admin')).toBeVisible();
// 开启配置状态
await page.evaluate(() => {
localStorage.setItem('NOCOBASE_DESIGNABLE', 'true');
});
// 保存登录状态
await page.context().storageState({ path: adminFile });
});