- top-level view switch workbench|admin in App.tsx (no router; hash #turn anchors untouched) - new admin/console/AdminConsoleView with left group nav in the existing token/inline-style idiom, plus 8 self-fetching sections: overview, kb, features, settings, workflows, roles, users, docs - absorb the six AdminSettingsModal tabs into sections and delete the modal - new api/systemAdmin.ts + types for /api/v1/admin/system/* endpoints - playwright smoke spec web/e2e/admin-console.spec.ts (skip by default)
41 lines
2.0 KiB
TypeScript
41 lines
2.0 KiB
TypeScript
import { test, expect, type Page } from '@playwright/test';
|
|
|
|
/**
|
|
* 系统管理台最小冒烟:admin 登录 → 进入管理台 → 分组导航渲染 → 返回工作台。
|
|
* 与其他 e2e 一致:仅 RUN_UI_ACCEPTANCE=1 且对接真实 dev 栈时运行(无 mock),
|
|
* 需要 ADMIN_USERNAME / ADMIN_PASSWORD 环境变量。
|
|
*/
|
|
const runAcceptance = process.env.RUN_UI_ACCEPTANCE === '1';
|
|
const ADMIN_USER = process.env.ADMIN_USERNAME?.trim() || '';
|
|
const ADMIN_PASS = process.env.ADMIN_PASSWORD?.trim() || '';
|
|
|
|
test.skip(!runAcceptance, 'set RUN_UI_ACCEPTANCE=1 against the real dev stack');
|
|
|
|
async function login(page: Page, username: string, password: string) {
|
|
await page.goto('/');
|
|
await page.fill('input[placeholder*="系统用户名"]', username);
|
|
await page.fill('input[placeholder*="登录密码"]', password);
|
|
await page.click('button:has-text("进入医疗协同工作台")');
|
|
await expect(page.getByText('新建立项会话')).toBeVisible({ timeout: 30_000 });
|
|
}
|
|
|
|
test('admin console smoke: enter, nav renders, exit back to workbench', async ({ page }) => {
|
|
if (!ADMIN_USER || !ADMIN_PASS) {
|
|
throw new Error('ADMIN_USERNAME and ADMIN_PASSWORD are required');
|
|
}
|
|
await login(page, ADMIN_USER, ADMIN_PASS);
|
|
|
|
// 进入系统管理台(LeftRail 管理盾牌按钮,仅管理员可见)
|
|
await page.click('button[title*="系统管理与准入治理控制台"]');
|
|
await expect(page.getByText('系统管理', { exact: true })).toBeVisible({ timeout: 15_000 });
|
|
|
|
// 左侧分组导航渲染
|
|
for (const label of ['系统运行总览', '知识库连接', '特性功能开关', '系统设置白名单', '工作流定义', 'RBAC 角色权限', '用户与准入治理', '文档与模板库']) {
|
|
await expect(page.getByRole('button', { name: label })).toBeVisible();
|
|
}
|
|
|
|
// 返回工作台
|
|
await page.getByRole('button', { name: '返回工作台' }).first().click();
|
|
await expect(page.getByText('新建立项会话')).toBeVisible({ timeout: 15_000 });
|
|
});
|