test(web): stabilize governance authz page matrix locators

Avoid matching the blocked-run hint when opening settings, and close leftover modals before project 143.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-14 08:39:44 +00:00
co-authored by Cursor
parent aec166ea41
commit 1d366fd38e
+14 -7
View File
@@ -39,8 +39,8 @@ async function login(page: Page, username: string, password: string) {
}
async function goToDutyStep(page: Page) {
const approval = page.getByText('纳入人工审批').first();
const selectHint = page.getByText('选择要激活的已发布工作流版本');
const approval = page.locator('label', { hasText: '纳入人工审批' }).first();
const selectHint = page.getByText('选择要激活的已发布工作流版本。激活后将冻结配置,运行中不可切换。');
await expect(selectHint.or(approval)).toBeVisible({ timeout: 20_000 });
if (await approval.isVisible().catch(() => false)) {
return;
@@ -112,13 +112,15 @@ test.describe.serial('governance action-level authz', () => {
await expect(page.locator('[data-chat-role="assistant"]').last()).toBeVisible({ timeout: 45_000 });
await shot(page, '02-casual-chat.png');
await input.fill('帮我生成立项文档');
// 「生成立项文档」会命中前端私密草稿捷径;编制用户初始需求收集表才会 POST /tasks/runs。
const generatePrompt = '请编制用户初始需求收集表';
await input.fill(generatePrompt);
await page.getByRole('button', { name: /发送/ }).click();
await expect(page.getByText('帮我生成立项文档')).toBeVisible({ timeout: 20_000 });
await expect(page.getByText(generatePrompt)).toBeVisible({ timeout: 20_000 });
await expect(page.getByText(GOVERNANCE_BLOCKED_HINT)).toBeVisible({ timeout: 45_000 });
await expect(page.getByText('待激活工作流')).toBeVisible({ timeout: 15_000 });
const blocked = runCreates.find((row) => row.body.includes('blocked_pending_governance'));
if (!blocked || blocked.status !== 202) {
const blocked = runCreates.find((row) => row.status === 202 && row.body.includes('blocked_pending_governance'));
if (!blocked) {
throw new Error(`expected 202 blocked run, got ${JSON.stringify(runCreates)}`);
}
await shot(page, '03-blocked-generate.png');
@@ -165,7 +167,12 @@ test.describe.serial('governance action-level authz', () => {
}
await shot(page, '06-duty-gated-actions.png');
await page.getByRole('complementary').getByTitle('对话协同会话', { exact: true }).click();
const leftoverClose = page.getByRole('button', { name: '关闭' });
if (await leftoverClose.isVisible().catch(() => false)) {
await leftoverClose.click();
}
await page.keyboard.press('Escape');
await page.getByRole('complementary').getByTitle('对话协同会话', { exact: true }).click({ force: true });
await expect(page.getByRole('banner')).toContainText('对话协同会话', { timeout: 15_000 });
await page.getByRole('button', { name: '查看工作流设置' }).click();
await expect(page.getByText('当前工作流已冻结,只读查看')).toBeVisible({ timeout: 15_000 });