Peach: Local-first video metadata scraper and media manager.
test(e2e): 首次切换按页面高度判夹顶并补齐资源同步旧地址
longmeidaob9cc5e46e1c2
diff --git a/frontend/e2e/anchor-navigation.test.ts b/frontend/e2e/anchor-navigation.test.tsindex 5a65a94b5..f91f977f9 100644--- a/frontend/e2e/anchor-navigation.test.ts+++ b/frontend/e2e/anchor-navigation.test.ts@@ -22,33 +22,45 @@ describe('页面滚动定位', () => {await waiting;await route.fallback();});- const previousHeight = await page.evaluate(() => {+ const { previousHeight, animates, floor } = await page.evaluate(async () => {// 长度只放在离开的列表内,导航清空列表时会一起移除。const tail = document.createElement('div');tail.style.height = '3000px';document.getElementById('grid')!.append(tail);+ // 关闭系统动画的 Windows(如托管 runner)上,Chrome 把程序触发的平滑滚动直接跳到终点;先探测有无中间帧。+ window.scrollTo({ top: 0, behavior: 'instant' });+ window.scrollTo({ top: 1000, behavior: 'smooth' });+ let animates = false;+ for (let frame = 0; frame < 5 && !animates; frame++) {+ await new Promise(resolve => requestAnimationFrame(resolve));+ animates = scrollY > 0 && scrollY < 1000;+ }window.scrollTo({ top: 500, behavior: 'instant' });- const frames: number[] = [];+ const frames: { y: number; height: number }[] = [];const tracking = { frames, running: true };Object.assign(window, { coldFollowScroll: tracking });const record = () => {- frames.push(scrollY);+ frames.push({ y: scrollY, height: document.documentElement.scrollHeight });if (tracking.running) requestAnimationFrame(record);};requestAnimationFrame(record);- return document.documentElement.style.minHeight;+ return { previousHeight: document.documentElement.style.minHeight, animates, floor: 500 + innerHeight - 1 };});if (viewport.mobile) await page.locator('header button[aria-label="展开侧栏"]').click();await page.locator('#drawer [data-nav="follow"]').click();await page.waitForURL('**/follow');await page.waitForFunction(() => scrollY === 0);const frames = await page.evaluate(() => {- const tracking = (window as unknown as { coldFollowScroll: { frames: number[]; running: boolean } }).coldFollowScroll;+ const tracking = (window as unknown as {+ coldFollowScroll: { frames: { y: number; height: number }[]; running: boolean } }).coldFollowScroll;tracking.running = false;return tracking.frames;});- if (!reduced) assert.ok(frames.some(y => y > 2 && y < 490),- `首次切换应经过中间位置,不能先被短骨架夹到顶部;逐帧位置:${frames.join(',')}`);+ const trace = frames.map(({ y, height }) => `${y}/${height}`).join(',');+ assert.ok(frames.every(({ height }) => height >= floor),+ `回顶完成前页面高度不能低于离开时的阅读位置,否则短骨架会把位置夹到顶部;逐帧位置/高度:${trace}`);+ if (!reduced && animates) assert.ok(frames.some(({ y }) => y > 2 && y < 490),+ `首次切换应经过中间位置;逐帧位置/高度:${trace}`);release();await page.locator('[data-follow-list] > [data-follow-item]').first().waitFor();await page.waitForFunction(height => document.documentElement.style.minHeight === heightdiff --git a/frontend/e2e/smoke.test.ts b/frontend/e2e/smoke.test.tsindex 7d4741e83..1f7a508a3 100644--- a/frontend/e2e/smoke.test.ts+++ b/frontend/e2e/smoke.test.ts@@ -136,7 +136,7 @@ const ROUTES: readonly Route[] = [{// 旧直达地址进入资源同步二级页。path: '/resource-sync',- body: (page) => [heading(page, '#main', '资源同步'), page.locator('#stats section#resource-sync')],+ body: (page) => [pageTitle(page, '资源同步'), page.locator('#stats section#resource-sync')],},{path: '/quality-goals',