test: 修正首页行动按钮的失效断言

首页行动按钮在 inquiry 能力停用时退化为 Text,H5 端 Button 又渲染为 taro-button-core
自定义元素,两种情况都没有原生 button,因此按标签断言恒为 0。改为按稳定的
.home-action 类名断言,H5 预览的 11 项浏览器回归由 10 通过恢复为全部通过。
This commit is contained in:
que01 committed 2026-10-13 23:18:56 +08:00
1 parent 4d1cd8f365
commit d34cb182e3
1 file changed
+9 -6
+9 -6
View File
@@ -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);