From d34cb182e3aa041507185363e8daac77fc03d086 Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 13 Oct 2026 23:18:56 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E6=AD=A3=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=A1=8C=E5=8A=A8=E6=8C=89=E9=92=AE=E7=9A=84=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首页行动按钮在 inquiry 能力停用时退化为 Text,H5 端 Button 又渲染为 taro-button-core 自定义元素,两种情况都没有原生 button,因此按标签断言恒为 0。改为按稳定的 .home-action 类名断言,H5 预览的 11 项浏览器回归由 10 通过恢复为全部通过。 --- apps/taro/test/browser/preview.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/taro/test/browser/preview.spec.ts b/apps/taro/test/browser/preview.spec.ts index fef18ba..a513200 100644 --- a/apps/taro/test/browser/preview.spec.ts +++ b/apps/taro/test/browser/preview.spec.ts @@ -8,14 +8,17 @@ test("真实 API 驱动首页、出摊和主理人视觉槽位", async ({ page } page.on("pageerror", (error) => errors.push(error.message)); await page.goto("/"); await expect(page.locator(".food-home .name")).toContainText("阿成"); - await expect(page.locator(".food-home .actions button")).toHaveCount(2); - const actionBounds = await page.locator(".food-home .actions button").evaluateAll((buttons) => { - const parent = buttons[0].parentElement!.getBoundingClientRect(); - return buttons.map((button) => button.getBoundingClientRect().right - parent.right); - }); + // 行动按钮在能力停用时退化为文本,按标签断言会漏掉,因此按稳定的类名断言。 + await expect(page.locator(".food-home .actions .home-action")).toHaveCount(2); + const actionBounds = await page + .locator(".food-home .actions .home-action") + .evaluateAll((buttons) => { + const parent = buttons[0].parentElement!.getBoundingClientRect(); + return buttons.map((button) => button.getBoundingClientRect().right - parent.right); + }); expect(Math.max(...actionBounds)).toBeLessThanOrEqual(1); const actionStyles = await page - .locator(".food-home .actions button") + .locator(".food-home .actions .home-action") .first() .evaluate((button) => { const style = getComputedStyle(button);