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);