From fb846bed1454df7edd9d3fcf2c56ebb972cf0c27 Mon Sep 17 00:00:00 2001 From: weichen Date: Sun, 11 Oct 2026 17:53:40 +0000 Subject: [PATCH] Pin summary-card assertions to exact labels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: hasText('章节') also matches the 空缺章节 card, tripping Playwright strict mode. Evidence: rerun of scripts/e2e.sh in this task. Impact: test-only. --- e2e/rdm-audit.playwright.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/e2e/rdm-audit.playwright.ts b/e2e/rdm-audit.playwright.ts index fe0a4c0..021d4de 100644 --- a/e2e/rdm-audit.playwright.ts +++ b/e2e/rdm-audit.playwright.ts @@ -48,15 +48,19 @@ async function openAudit(page: Page) { } test.describe.serial('U4 项目追溯审计工作区', () => { + // 卡片按 label 精确定位(「章节」与「空缺章节」等子串互不干扰)。 + const card = (page: Page, label: string) => + page.locator('.rdm-audit-card').filter({ has: page.locator('.rdm-audit-card-label', { hasText: new RegExp(`^${label}$`) }) }) + test('登录并打开工作区,概览计数与覆盖标注可读', async ({ page }) => { await login(page) await openAudit(page) // 概览:统计卡片 + 水位标注(数据完整性提示,不冒充实时)。 await expect(page.locator('.rdm-audit-card')).toHaveCount(9) await expect(page.getByText(/截至水位 \d+/)).toBeVisible() - // 主项目应有切片与章节(种子 ingest 保证)。 - await expect(page.locator('.rdm-audit-card', { hasText: '切片' })).toContainText(/\d+/) - await expect(page.locator('.rdm-audit-card', { hasText: '章节' })).not.toContainText(/^0$/) + // 主项目应有切片与章节(种子 structure 装载 + ingest 保证)。 + await expect(card(page, '切片')).toContainText(/[1-9]/) + await expect(card(page, '章节')).toContainText(/[1-9]/) }) test('三次主要点击内完成取证:章节来源依据与最近修改原因', async ({ page }) => { @@ -97,7 +101,7 @@ test.describe.serial('U4 项目追溯审计工作区', () => { // 切到隔离项目:概览计数应为 0 且无残留「加载中…」。 await page.locator('.rdm-audit-project').selectOption({ label: ISOLATED }) await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 }) - await expect(page.locator('.rdm-audit-card', { hasText: '切片' })).toContainText(/^0$/) + await expect(card(page, '切片')).toContainText(/^0$/) // 空态:文档树与时间线给出可理解提示。 await page.getByRole('tab', { name: '资料与文档' }).click() await expect(page.getByText('暂无文档')).toBeVisible() @@ -107,7 +111,7 @@ test.describe.serial('U4 项目追溯审计工作区', () => { await page.getByRole('tab', { name: '概览' }).click() await page.locator('.rdm-audit-project').selectOption({ label: MAIN }) await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 }) - await expect(page.locator('.rdm-audit-card', { hasText: '切片' })).toContainText(/[1-9]/) + await expect(card(page, '切片')).toContainText(/[1-9]/) await expect(page.locator('.rdm-audit-project')).toHaveValue( await page.locator('.rdm-audit-project option', { hasText: MAIN }).getAttribute('value') ?? '', )