Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

test(web): 同步通知布局与轮询断言的读取状态

longmeidao4eabd955a6d8
diff --git a/frontend/e2e/notification-shell.test.ts b/frontend/e2e/notification-shell.test.ts
index 22ee7da94..18602b4e7 100644
--- a/frontend/e2e/notification-shell.test.ts
+++ b/frontend/e2e/notification-shell.test.ts
@@ -34,8 +34,9 @@ describe('通知和任务卡的共用外框', () => {
const measure = () => page.evaluate(() => [...document.querySelectorAll<HTMLElement>(
'#toasts [data-sonner-toast][data-styled="true"],#toasts [data-processing-dock]')].map(node => {
const css = getComputedStyle(node), box = node.getBoundingClientRect();
- return { radius: css.borderRadius, shadow: css.boxShadow, border: css.border,
- width: box.width, height: box.height, padding: css.padding };
+ return { kind: node.hasAttribute('data-processing-dock') ? 'task' : 'receipt',
+ visibility: css.visibility, radius: css.borderRadius, shadow: css.boxShadow, border: css.border,
+ x: box.x, y: box.y, width: box.width, height: box.height, padding: css.padding };
}));
const aligned = await measure();
assert.equal(aligned.length, 2);
@@ -43,7 +44,9 @@ describe('通知和任务卡的共用外框', () => {
assert.equal(aligned[0]!.radius, aligned[1]!.radius);
assert.equal(aligned[0]!.shadow, aligned[1]!.shadow);
assert.equal(aligned[0]!.border, aligned[1]!.border);
- const box = (await task.boundingBox())!, top = (await receipt.boundingBox())!.y;
+ // 外观与坐标使用同一次测量,尺寸必须来自可见的布局框。
+ for (const item of aligned) assert.ok(item.visibility === 'visible' && item.width > 0 && item.height > 0, JSON.stringify(item));
+ const box = aligned.find(item => item.kind === 'task')!, top = aligned.find(item => item.kind === 'receipt')!.y;
const clip = { x: Math.max(0, viewport.width - 600), y: Math.max(0, top - 20),
width: Math.min(viewport.width, 600), height: viewport.height - Math.max(0, top - 20) };
assert.ok(box.x >= 0 && box.x + box.width <= viewport.width);
diff --git a/frontend/e2e/smoke.test.ts b/frontend/e2e/smoke.test.ts
index 65cbf8731..3eb2d5c64 100644
--- a/frontend/e2e/smoke.test.ts
+++ b/frontend/e2e/smoke.test.ts
@@ -217,7 +217,7 @@ describe('路由冒烟', () => {
if (polls.length >= least) return;
await opened.page.waitForTimeout(250);
}
- assert.fail(`${what}:只看到 ${polls.length} 次 /api/tasks,要 ${least} 次`);
+ assert.ok(polls.length >= least, `${what}:只看到 ${polls.length} 次 /api/tasks,要 ${least} 次`);
};
await expectBody(opened.page, '/tasks',
[heading(opened.page, '#stats', '还没有任务记录')]);