From f51dbb400a476793d75bad48a805571b1beaadd8 Mon Sep 17 00:00:00 2001 From: "xiuting.xu" Date: Thu, 30 Oct 2025 16:05:59 +0800 Subject: [PATCH] modify playwright scripts --- src/web/tests/playwright/helpers/entrycards-helpers.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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');