diff --git a/src/web/tests/playwright/helpers/entrycards-helpers.ts b/src/web/tests/playwright/helpers/entrycards-helpers.ts index 943ff32..892d7cc 100644 --- a/src/web/tests/playwright/helpers/entrycards-helpers.ts +++ b/src/web/tests/playwright/helpers/entrycards-helpers.ts @@ -11,9 +11,13 @@ export async function testEntryCards( const card = page.locator(`.mantine-Card-root:has-text("${entry.label}")`); await expect(card).toBeVisible({ timeout: 10000 }); - // 检查卡片内部的链接 + // 检查卡片内部的链接,忽略端口号 const link = card.locator('a'); - await expect(link).toHaveAttribute('href', entry.href); + const href = await link.getAttribute('href'); + + // 正则:保留协议和 host,忽略端口号 + const expectedHrefPattern = entry.href.replace(/:(\d+)/, '(:\\d+)?'); + expect(href).toMatch(new RegExp(`^${expectedHrefPattern}$`)); // 检查图标 const img = card.locator('img');