Skip to content

armgit / peach

Public Imported from GitHub
0

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

test(e2e): 管理页骨架几何先等壳层过渡落定再量

longmeidaof65e4d7c6d66
diff --git a/frontend/e2e/management-layout.test.ts b/frontend/e2e/management-layout.test.ts
index 564fb6a25..3ec4f0cb6 100644
--- a/frontend/e2e/management-layout.test.ts
+++ b/frontend/e2e/management-layout.test.ts
@@ -21,6 +21,12 @@ const liveBox = async (page: Page, selector: string): Promise<Box> => {
const aligned = (waiting: Box, ready: Box, keys: readonly (keyof Box)[] = ['x', 'y', 'width', 'height']) => {
for (const key of keys) assert.ok(Math.abs(waiting[key] - ready[key]) <= 1, `${key}: ${waiting[key]} / ${ready[key]}`);
};
+/* 冷启动时壳层的过渡(`body` 的 padding-left、侧栏宽度等)还在走,整页正文跟着它横移;机器一忙,
+ 这段过渡会拖得更长。量骨架前先等全部 CSS 过渡落定:这里比的是骨架与接管后的落位,不是量的那一刻
+ 过渡走到了哪儿。骨架的循环闪光是 CSS 动画,不在等待之列。 */
+const transitionsSettled = (page: Page) => page.evaluate(() => Promise.all(document.getAnimations()
+ .filter((motion) => motion instanceof CSSTransition)
+ .map((motion) => motion.finished.catch(() => undefined))));
describe('管理页面容器与骨架', () => {
let browser: Browser;
@@ -81,12 +87,7 @@ describe('管理页面容器与骨架', () => {
await page.reload({ waitUntil: 'load' });
const skeleton = page.locator('[data-skeleton="board/stats"]');
await skeleton.waitFor();
- /* 冷启动时侧栏展开那段过渡(`body` 的 padding-left 与侧栏宽度)还在走,整页正文跟着它横移。
- 先等它落定再量:这里比的是骨架与接管后的落位,不是量的那一刻侧栏走到了哪儿。 */
- await page.evaluate(() => Promise.all(document.getAnimations()
- .filter((motion) => motion instanceof CSSTransition && ['padding-left', 'width'].includes(motion.transitionProperty)
- && (motion.effect as KeyframeEffect | null)?.target?.matches('body, #drawer'))
- .map((motion) => motion.finished.catch(() => undefined))));
+ await transitionsSettled(page);
const metrics = await box(skeleton.locator('[data-stats-metrics]'));
const chart = await box(skeleton.locator('[data-stats-chart]').first());
const waitingLayout = await layout(page);
@@ -125,6 +126,7 @@ describe('管理页面容器与骨架', () => {
await page.reload({ waitUntil: 'load' });
const skeleton = page.locator('[data-skeleton="board/duplicates"]');
await skeleton.waitFor();
+ await transitionsSettled(page);
const summary = await box(skeleton.locator('[data-collection-summary]'));
const row = await box(skeleton.locator('.duplicate-row').first());
release();
@@ -152,6 +154,7 @@ describe('管理页面容器与骨架', () => {
await page.reload({ waitUntil: 'load' });
const skeleton = page.locator('[data-skeleton="board/quality-goals"]');
await skeleton.waitFor();
+ await transitionsSettled(page);
const summary = await box(skeleton.locator('[data-collection-summary]'));
const card = await box(skeleton.locator('.card-grid-cover > li').first());
release();
@@ -194,6 +197,8 @@ describe('管理页面容器与骨架', () => {
size: 1048576, location: 'local', cost: '' })) } });
});
await page.reload({ waitUntil: 'load' });
+ await page.locator('#grid .catalog-skeleton .skeletoncard').first().waitFor();
+ await transitionsSettled(page);
const card = await liveBox(page, '#grid .catalog-skeleton .skeletoncard');
release();
await page.locator('#grid [data-junk-card]').first().waitFor();