Skip to content

Commit 7d63a1b

Browse files
committed
test(motion): 放宽动态 import 的等待窗口
1 parent 51f6019 commit 7d63a1b

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎app/src/shell/phaseFreeze.seams.test.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ const need = (sel: string): HTMLElement => {
5959
if (el === null) throw new Error(`找不到元素:${sel}`);
6060
return el;
6161
};
62+
/**
63+
* 动态 import 的等待窗口(**不是**动画的等待窗口):`controls.ts` 首次被转换要连带 `gsap` 家族,
64+
* 全量并行跑时实测可超过 `waitFor` 的 1000ms 默认值(本批已知 6 个负载敏感 flake 的同族:
65+
* 首轮提交树全量里本文件恰因它红过一次)⇒ 只放宽**等待上限**,断言一字不改。
66+
*/
67+
const WAIT = { timeout: 5000 } as const;
6268

6369
describe("S1 · 琥珀退去(R4.5):只引 `--ed-due` 族、零颜色字面量、零 `--ed-*` 定义", () => {
6470
it("退去规则逐条:琥珀族引用非空 · 越族引用为空 · 无色值字面量 · 覆盖复习态", () => {
@@ -113,7 +119,7 @@ describe("S2 · 接线:`LiveBar` 的墨度层与波形真的接上了编排层
113119
expect([...shapes].every((t) => t.startsWith("scaleY(")), "几何只经 scaleY 表达(R8.4)").toBe(true);
114120

115121
view.rerender(bar("idle"));
116-
await waitFor(() => expect(layer.style.opacity, "相位翻转后墨度层必须被编排层写").not.toBe(""));
122+
await waitFor(() => expect(layer.style.opacity, "相位翻转后墨度层必须被编排层写").not.toBe(""), WAIT);
117123
const v = Number.parseFloat(layer.style.opacity);
118124
// 生产侧时间线**不 paused**(ticker 驱动)⇒ 只断「落在 [常态档, 满墨] 之间、方向朝常态档」;
119125
// 逐端点的精确读数归 `usePhaseFreeze.test.tsx` 的 F2/F3(那是 paused + `freezeAt` 的确定性面)。
@@ -128,8 +134,9 @@ describe("S3 · 相位从 `PhaseChrome` 真的转发到了编排层(缺这一
128134
const layer = need('[data-testid="live-ink"]');
129135
expect(layer.style.opacity, "挂载时相位未变 ⇒ hook 零动作").toBe("");
130136
view.rerender(<PhaseChrome phase="idle"><i /></PhaseChrome>);
131-
await waitFor(() =>
132-
expect(layer.style.opacity, "`LiveBarHost` 没拿到相位(转发断了)⇒ 编排层永远零动作").not.toBe(""),
137+
await waitFor(
138+
() => expect(layer.style.opacity, "`LiveBarHost` 没拿到相位(转发断了)⇒ 编排层永远零动作").not.toBe(""),
139+
WAIT,
133140
);
134141
const v = Number.parseFloat(layer.style.opacity);
135142
expect(v, "退去方向朝常态档").toBeGreaterThanOrEqual(DUE_INK_NORMAL - 0.005);

‎app/src/shell/usePhaseFreeze.test.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ const scales = (): number[] =>
6767
bars().map((b) => Number.parseFloat(/scaleY\(([^)]+)\)/.exec(b.style.transform)?.[1] ?? "NaN"));
6868
const distinct = (xs: readonly number[]): number => new Set(xs).size;
6969
const timeline = () => seen.api!.handle.current!.timeline;
70+
/**
71+
* 动态 import 的等待窗口(**不是**动画的等待窗口):`controls.ts` 首次被转换要连带 `gsap` 家族,
72+
* 全量并行跑时实测可超过 `waitFor` 的 1000ms 默认值(本批已知 6 个负载敏感 flake 的同族)
73+
* ⇒ 只放宽**等待上限**,断言一字不改。
74+
*/
75+
const WAIT = { timeout: 5000 } as const;
7076
/** 确定性推进(R8.1):paused timeline + `tl.time(t)`,并 flush 编排层的 setState。 */
7177
const seek = (t: number): void => {
7278
act(() => {
@@ -77,7 +83,7 @@ const seek = (t: number): void => {
7783
async function flip(view: { rerender: (ui: React.ReactElement) => void }, phase: ShellPhase): Promise<void> {
7884
const before = seen.api?.handle.current ?? null;
7985
view.rerender(<Probe phase={phase} />);
80-
await waitFor(() => expect(seen.api?.handle.current).not.toBe(before));
86+
await waitFor(() => expect(seen.api?.handle.current).not.toBe(before), WAIT);
8187
}
8288
beforeEach(() => {
8389
seen.api = null;
@@ -228,7 +234,7 @@ describe("F6~F7 · 三档自消费(R35.4)与属性集合审计(R8.4)", (
228234
view.rerender(<Probe phase="idle" />);
229235
if (tier === "eco") {
230236
// eco 也不经编排 timeline:终态由出口的零时长 tween 写(走动态 import ⇒ 等它到达)
231-
await waitFor(() => expect(seen.api!.freeze).toBeCloseTo(1, 3));
237+
await waitFor(() => expect(seen.api!.freeze).toBeCloseTo(1, 3), WAIT);
232238
expect(seen.api!.handle.current, "§8.5:节能档 ⇒ 编排层直接跳终态(不建编排 timeline)").toBeNull();
233239
expect(tweenCount(ink())).toBe(0);
234240
expect(inkNow(), "终态 = 常态档墨度").toBeCloseTo(DUE_INK_NORMAL, 3);

0 commit comments

Comments
 (0)