Peach: Local-first video metadata scraper and media manager.
test(ci): 修正响应就绪与浏览器交互等待
longmeidao1516989ec504
diff --git a/docs/TESTING.md b/docs/TESTING.mdindex f842af497..faf6375b5 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -157,11 +157,11 @@ macOS 按影响域验证:主检出只按 ADR-0091 只读检查依赖;缺包或检查失败时以 `3` 退出,依赖变更由重启流程执行。找不到 uv、锁文件过期或同步失败也会停止测试。前端依赖与构建仍按上文安装。完成安装和编辑后再启动最终验证;运行中发生改动时,完整批次按下述规则保留未受影响的文件结果。-会起浏览器或整套 vitest 的运行(全量、选中 `test_web_e2e` 或 `test_frontend_build` 的域、含 `frontend/` 选择器的定向调试)先排整机的重负载锁 `%LOCALAPPDATA%\peach-test-locks\test-machine.lock`(macOS/Linux 在 `~/.local/state/peach-test-locks/`),再拿仓库的全量锁。所有工作树、所有会话与本机 GitGud runner 的作业都排这一把:Windows runner 就是开发机,本机测试与 CI 作业叠在一起跑时,固定时限的用例会因负载偶发超时。runner 的构建、冒烟与镜像作业用 `scripts/machine_lock.py` 包一层拿同一把锁;验证作业经测试入口,入口自己拿。本机最多等 `--lock-timeout`(30 分钟),CI 作业(`CI=true`)最多等 60 分钟,排在本机两轮全量后面也等得到。只有已合入这套入口的工作树会排这把锁;还在旧 master 上的工作树要 rebase 之后才参与排队。+测试入口不取得机器级重负载锁。全量验证与集成只按下文的仓库代码一致性锁互斥;浏览器和 Vitest 的阶段顺序由测试入口安排。全量先单独跑一片秒级检查(`test_runner.GATE_TESTS`:仓库策略、编码、文案终态、上下文预算、源码断言棘轮、复杂度、Python lint、外发代理、仓库整洁与依赖清单,合计约 1 分钟),有一项不过就不起其余分片。-全量失败后,入口从逐条结果里取出失败的 Python 用例、e2e 文件与 vitest 文件,不超过 6 个文件时用定向入口逐个单独重跑一次(父进程已持有整机锁,重跑不再排队)。单独重跑通过的,记录照样签为通过,名字写进记录的 `flaky` 字段并打印出来;单独重跑仍失败、失败面更大、或浏览器容器整个没起来的,按真实失败处理。同一用例反复出现在 `flaky` 里,说明它的等待写法或时限需要修。+全量失败后,入口从逐条结果里取出失败的 Python 用例、e2e 文件与 vitest 文件,不超过 6 个文件时用定向入口逐个单独重跑一次。单独重跑通过的,记录照样签为通过,名字写进记录的 `flaky` 字段并打印出来;单独重跑仍失败、失败面更大、或浏览器容器整个没起来的,按真实失败处理。同一用例反复出现在 `flaky` 里,说明它的等待写法或时限需要修。本机全量验证与 `integrate` 共用 `full-suite.lock`,从取得代码和环境快照一直持有到记录写入完成。锁忙时按到达先后排队:等待者在锁旁的 `full-suite.lock.queue/` 放一张以纳秒时刻开头的票,diff --git a/frontend/e2e/collapse-motion.test.ts b/frontend/e2e/collapse-motion.test.tsindex 3fe282588..265c9eb91 100644--- a/frontend/e2e/collapse-motion.test.ts+++ b/frontend/e2e/collapse-motion.test.ts@@ -11,20 +11,27 @@ async function motion(page: Page, trigger: Locator) {const arrow = button.querySelector('svg')!;const initialTransform = getComputedStyle(arrow).transform;const height = body.getBoundingClientRect().height;- let transitioned = false;- body.addEventListener('transitionrun', event => { if ((event as TransitionEvent).propertyName === 'height') transitioned = true });(button as HTMLElement).click();- await new Promise(resolve => setTimeout(resolve, 80));+ await new Promise<void>(resolve => requestAnimationFrame(() => resolve()));+ const transition = body.getAnimations().find(animation =>+ animation instanceof CSSTransition && animation.transitionProperty === 'height');+ if (transition) {+ transition.pause();+ transition.currentTime = Number(transition.effect!.getComputedTiming().duration) / 2;+ }const middle = body.getBoundingClientRect().height;const inert = body.inert;- await new Promise(resolve => setTimeout(resolve, 240));- return { height, middle, inert, transitioned, hidden: body.hidden, stableArrow: button.querySelector('svg') === arrow,- duration: getComputedStyle(arrow).transitionDuration, transform: getComputedStyle(arrow).transform, initialTransform };+ const stableArrow = button.querySelector('svg') === arrow;+ const duration = getComputedStyle(arrow).transitionDuration;+ for (const animation of [...body.getAnimations(), ...arrow.getAnimations()]) animation.finish();+ return { height, middle, inert, transitioned: Boolean(transition), stableArrow,+ duration, transform: getComputedStyle(arrow).transform, initialTransform };});assert.ok(result.height > 0 && result.middle > 0 && result.middle < result.height, JSON.stringify(result));assert.equal(result.transitioned, true);assert.equal(result.inert, true);- assert.equal(result.hidden, true);+ const body = page.locator(`[id="${await trigger.getAttribute('aria-controls')}"]`);+ await page.waitForFunction(node => (node as HTMLElement).hidden, await body.elementHandle());assert.equal(result.stableArrow, true);assert.notEqual(result.duration, '0s');assert.notEqual(result.transform, result.initialTransform);@@ -33,9 +40,9 @@ async function motion(page: Page, trigger: Locator) {await trigger.click();await page.waitForTimeout(40);await trigger.click();- await page.waitForTimeout(320);+ await page.waitForFunction(node => (node as HTMLElement).classList.contains('ui-fcollapse-settled'),+ await body.elementHandle());assert.equal(await trigger.getAttribute('aria-expanded'), 'true');- const body = page.locator(`[id="${await trigger.getAttribute('aria-controls')}"]`);assert.equal(await body.evaluate(node => (node as HTMLElement).inert || (node as HTMLElement).hidden), false);await page.emulateMedia({ reducedMotion: 'reduce' });assert.equal(await trigger.locator('svg').evaluate(node => getComputedStyle(node).transitionDuration), '0s');diff --git a/frontend/e2e/design-people.test.ts b/frontend/e2e/design-people.test.tsindex b8a7d6a51..dc9c76784 100644--- a/frontend/e2e/design-people.test.ts+++ b/frontend/e2e/design-people.test.ts@@ -579,9 +579,7 @@ describe('设计决定:人物与厂牌资料页', () => {it('看片那一行:两枚标识隔 32px、按 22px 字高对齐;MISSAV 按它站上的排字,AV 用它的粉;第二枚带序号', { timeout: 60_000 }, async () => {const name = '七沢みあ';- const opened = await visit(browser, '/', DESKTOP);- try {- const page = opened.page;+ const opened = await visit(browser, `/performers/${encodeURIComponent(name)}`, DESKTOP, async page => {await page.route(/\/api\/entity\?/, (route) => route.fulfill({ json: {id: 90_001, kind: 'performer', canonical_name: name, aliases: [], display_aliases: [],user_aliases: [], asset_count: 0, tags: [], related_performers: [], links: [], metadata: {},@@ -591,7 +589,9 @@ describe('设计决定:人物与厂牌资料页', () => {{ site: 'missav', label: 'MISSAV', ordinal: '2', slot: 'mark', mark: '', url: 'https://missav.ws/actresses/x' },],} }));- await page.goto(new URL(`/performers/${encodeURIComponent(name)}`, page.url()).href, { waitUntil: 'load' });+ });+ try {+ const page = opened.page;await page.locator('[data-missav-mark]').waitFor({ timeout: 15_000 });const marks = await page.locator('[data-entry-marks]').evaluate((row) => {const wordmark = row.querySelector('[data-missav-mark]')!;diff --git a/frontend/e2e/table-preferences-fixture.ts b/frontend/e2e/table-preferences-fixture.tsindex 27ec80c01..b45fe1dbe 100644--- a/frontend/e2e/table-preferences-fixture.ts+++ b/frontend/e2e/table-preferences-fixture.ts@@ -61,9 +61,11 @@ export async function verifyTablePreferences(page: Page, table: Locator, label:const initial = await width();const handle = header.getByRole('slider');await handle.focus(); await handle.press('Enter');- await handle.press('ArrowRight'); await handle.press('ArrowRight'); await handle.press('Tab');+ await header.locator('.react-aria-ColumnResizer[data-resizing]').waitFor();+ await handle.press('ArrowRight'); await handle.press('ArrowRight');await page.waitForFunction(({ node, initial }) => node && node.getBoundingClientRect().width > initial,{ node: await header.elementHandle(), initial }, { timeout: 5000 });+ await handle.press('Tab');const resized = await width(); assert.ok(resized > initial, `${label}: ${initial} → ${resized}`);const scroll = table.locator('..');const range = await scroll.evaluate(node => node.scrollWidth - node.clientWidth);diff --git a/tests/test_stream_lifecycle.py b/tests/test_stream_lifecycle.pyindex ac1b8f963..9c02291bc 100644--- a/tests/test_stream_lifecycle.py+++ b/tests/test_stream_lifecycle.py@@ -381,7 +381,8 @@ class MediaResponseLifecycleTests(unittest.IsolatedAsyncioTestCase):mock.patch.object(SplicedMp4Response, "_respond", slow_headers), \mock.patch("peach.api._server_error_headers", return_value={"X-Peach-Error-ID": "test"}) as errors:task, _, sent = self.request("/owned-session")- await asyncio.wait_for(entered.wait(), 1)+ # 首次请求还包含应用路由准备;取消完成的时限从响应进入后单独计算。+ await asyncio.wait_for(entered.wait(), 10)self.assertEqual(self.app.state.stream_sessions.cancel("owned"), 1)observed = Nonetry: