feat(ci): 搭建 A0 工程骨架与契约基线 #2

Merged
wang259797 merged 7 commits from feat/ci-a0-foundation into main 2026-11-02 09:27:48 +00:00
2 changed files with 74 additions and 0 deletions
Showing only changes of commit 1876c56008 - Show all commits

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { expect, type Page, test } from '@playwright/test';
async function signIn(page: Page): Promise<void> {
await page.goto('/login');
await page.getByPlaceholder('请输入账号或邮箱').fill('admin');
await page.getByPlaceholder('请输入密码').fill('demo1234');
await page.getByTestId('login-submit').click();
await expect(page.getByTestId('app-shell')).toBeVisible();
}
test('登录页打开并进入工作台', async ({ page }) => {
await page.goto('/login');
await expect(page.getByRole('heading', { name: '登录灵犀' })).toBeVisible();
await signIn(page);
await expect(page).toHaveURL('/');
await expect(page.getByRole('heading', { name: '工作台', exact: true })).toBeVisible();
await expect(page.getByRole('navigation', { name: '模块导航' })).toBeVisible();
});
test('403 页可演示', async ({ page }) => {
await page.goto('/403');
await expect(page.getByTestId('error-403')).toBeVisible();
await expect(page.getByRole('heading', { name: '没有访问权限' })).toBeVisible();
});
test('模块切换与侧边栏、面包屑联动', async ({ page }) => {
await signIn(page);
await page.getByRole('button', { name: '素材', exact: true }).click();
await expect(page).toHaveURL(/\/material/);
await page.getByRole('link', { name: '快筛', exact: true }).click();
await expect(page.getByRole('heading', { name: '快筛' })).toBeVisible();
await expect(page.getByRole('navigation', { name: '面包屑' })).toContainText('素材');
});
test('未知路由展示 404', async ({ page }) => {
await page.goto('/404');
await expect(page.getByTestId('error-404')).toBeVisible();
});
+36
View File
@@ -0,0 +1,36 @@
import { defineConfig, devices } from '@playwright/test';
const channel = process.env.CI ? undefined : 'chrome';
export default defineConfig({
testDir: './e2e',
timeout: 60_000,
expect: { timeout: 10_000 },
fullyParallel: true,
forbidOnly: Boolean(process.env.CI),
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI
? [['list'], ['html', { open: 'never' }], ['junit', { outputFile: 'test-results/e2e.xml' }]]
: [['list'], ['html', { open: 'never' }]],
use: {
baseURL: 'http://127.0.0.1:4173',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
channel,
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], channel },
},
],
webServer: {
command: 'node node_modules/vite/bin/vite.js preview --host 127.0.0.1 --port 4173 --strictPort',
cwd: 'apps/web',
url: 'http://127.0.0.1:4173/login',
reuseExistingServer: false,
timeout: 60_000,
stdout: 'ignore',
stderr: 'pipe',
},
});