From c3ccae75af7d4186e05eb82d6a993546526f9e94 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Fri, 11 Sep 2026 22:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E5=AE=9E=E6=B5=8B=E6=94=B6=E5=9B=9E?= =?UTF-8?q?=20cfd89ba57=20=E9=A1=BA=E6=89=8B=E5=8A=A0=E5=AE=BD=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E6=B5=8B=E8=AF=95=E8=B6=85=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=86=99=E6=98=8E=E5=8F=A6=E4=B8=80=E5=A4=84=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E7=9A=84=E7=90=86=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `prefetches only cards that are actually in view, and still fills the first screen` 的 `}, 30000)` 收回(回到 vitest 默认 5 s):实测 93 ms,约 54 倍余量,而且真正的时间门是内层 `waitFor` 自带的 1 s。cfd89ba57 那次只是给负载留余量,没有对应的结构性成本 —— 对照 `releases Blob URLs while continuously browsing beyond the cache limit`(79 轮串行读盘、实测 6120 ms、超默认 5 s)那条的预算属结构性必需,保持不动。 - `keeps a visible card cached when later loads push the cache over its limit` 的 `}, 60000)` **保留**并写明理由:它的职责是挂起护栏,必须大于内层 `waitFor` 的 20 s 断言预算,否则内层断言自己的失败信息永远不出现(vitest 会先在测试超时处中止,只剩笼统的 "test timed out")。用例实测 120 ms,20 s 与 60 s 都不是耗时预期;硬收会让内层预算变成不可达配置,是更差的诊断而不是更紧的门禁。 - 无功能改动。 --- .../tests/useProjectResourceCardPreviews.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/tests/useProjectResourceCardPreviews.test.ts b/apps/ai-game-creator-shell/tests/useProjectResourceCardPreviews.test.ts index b0679a0f7..feba40865 100644 --- a/apps/ai-game-creator-shell/tests/useProjectResourceCardPreviews.test.ts +++ b/apps/ai-game-creator-shell/tests/useProjectResourceCardPreviews.test.ts @@ -1950,6 +1950,10 @@ describe('冷启动首屏的放行范围与放行顺序', () => { }; } + // 本用例不设显式测试超时:实测 **84 ms**,对 vitest 默认的 5 s 有约 60 倍余量,而且真正的时间门 + // 是下面那个 `waitFor` 自带的 1 s。`cfd89ba57` 曾顺手给它加 `}, 30000)` —— 那只是给负载留余量, + // 没有对应的结构性成本(对比 `releases Blob URLs …` 那条:79 轮串行读盘实测 6120 ms,超默认 5 s, + // 那条的预算是必需的),故按实测收回。 it('prefetches only cards that are actually in view, and still fills the first screen', async () => { // A:热预取此前按投影顺序盲取前 12 张,条件里没有几何判断 —— 排在前面的视口外卡片 // 先占满 3 个读取槽,屏幕里的卡反而排队,首屏就是"等图片"。 @@ -1999,7 +2003,7 @@ describe('冷启动首屏的放行范围与放行顺序', () => { } // 首屏要保证有图可读:可见的 12 张一张都不能少。 expect(readPathsSet.size).toBe(resources.length - offscreen.length); - }, 30000); + }); it('releases intersecting cards in two bands: viewport first, margin second', async () => { // B:一次 observer 回调可能同时报来 ~21 张相交卡,物理读取只有 3 个槽。 @@ -2065,6 +2069,12 @@ describe('冷启动首屏的放行范围与放行顺序', () => { }); describe('预览缓存驱逐必须避开可见卡', () => { + /** + * 外层 `}, 60000)` **保留**,但它不是"给负载留余量"的耗时预期:它的职责是**挂起护栏**, + * 必须大于上面那个 `waitFor` 的 20 s 断言预算 —— 否则断言自己的失败信息永远不会出现 + * (vitest 会先在测试超时处中止,只剩一句笼统的 "test timed out")。用例实测 150 ms, + * 20 s 与 60 s 都不是耗时预期。 + */ it('keeps a visible card cached when later loads push the cache over its limit', async () => { // 现场:缓存条目顺序是「最近一次被请求」,而停在屏幕上不动的卡不会产生新请求 —— // 纯 LRU 会首选淘汰用户正看着的那张,图片"消失又回来"。