Assert the count element instead of the concatenated card text

Why: card text renders as num+label (e.g. 0切片), so whole-text regexes never matched.

Evidence: scripts/e2e.sh rerun in this task.

Impact: test-only.
This commit is contained in:
2026-10-11 17:58:12 +00:00
parent c22120d7fe
commit 7acfef0a1f
+3 -3
View File
@@ -59,7 +59,7 @@ test.describe.serial('U4 项目追溯审计工作区', () => {
await expect(page.locator('.rdm-audit-card')).toHaveCount(9) await expect(page.locator('.rdm-audit-card')).toHaveCount(9)
await expect(page.getByText(/截至水位 \d+/)).toBeVisible() await expect(page.getByText(/截至水位 \d+/)).toBeVisible()
// 主项目应有切片与章节(种子 structure 装载 + ingest 保证)。 // 主项目应有切片与章节(种子 structure 装载 + ingest 保证)。
await expect(card(page, '切片')).toContainText(/[1-9]/) await expect(card(page, '切片').locator('.rdm-audit-card-num')).toHaveText(/[1-9]/)
await expect(card(page, '章节')).toContainText(/[1-9]/) await expect(card(page, '章节')).toContainText(/[1-9]/)
}) })
@@ -108,7 +108,7 @@ test.describe.serial('U4 项目追溯审计工作区', () => {
// 切到隔离项目:概览计数应为 0 且无残留「加载中…」。 // 切到隔离项目:概览计数应为 0 且无残留「加载中…」。
await page.locator('.rdm-audit-project').selectOption({ label: ISOLATED }) await page.locator('.rdm-audit-project').selectOption({ label: ISOLATED })
await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 }) await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 })
await expect(card(page, '切片')).toContainText(/^0$/) await expect(card(page, '切片').locator('.rdm-audit-card-num')).toHaveText('0')
// 空态:文档树与时间线给出可理解提示。 // 空态:文档树与时间线给出可理解提示。
await page.getByRole('tab', { name: '资料与文档' }).click() await page.getByRole('tab', { name: '资料与文档' }).click()
await expect(page.getByText('暂无文档')).toBeVisible() await expect(page.getByText('暂无文档')).toBeVisible()
@@ -118,7 +118,7 @@ test.describe.serial('U4 项目追溯审计工作区', () => {
await page.getByRole('tab', { name: '概览' }).click() await page.getByRole('tab', { name: '概览' }).click()
await page.locator('.rdm-audit-project').selectOption({ label: MAIN }) await page.locator('.rdm-audit-project').selectOption({ label: MAIN })
await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 }) await expect(page.getByText('加载中…')).toHaveCount(0, { timeout: 10_000 })
await expect(card(page, '切片')).toContainText(/[1-9]/) await expect(card(page, '切片').locator('.rdm-audit-card-num')).toHaveText(/[1-9]/)
await expect(page.locator('.rdm-audit-project')).toHaveValue( await expect(page.locator('.rdm-audit-project')).toHaveValue(
await page.locator('.rdm-audit-project option', { hasText: MAIN }).getAttribute('value') ?? '', await page.locator('.rdm-audit-project option', { hasText: MAIN }).getAttribute('value') ?? '',
) )