From 2f148c900c1e7047b5150a07af5eaf1c89ffe03f Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 16 Sep 2026 13:02:46 +0800 Subject: [PATCH] test(07-08): #06-07-1 bind the event layer in the teleport playback test - createSmallMapScene returns map (additive; existing callers ignore it) - target case binds state.pathfinding.finder.useMapLayer(map.eventLayer) after floor activation - teleport target changed to (2,0) to avoid self-target empty-path early return; asserts x=2/y=0 - un-skip and rename to reflect test-side event layer binding; neutral leading comment --- .../data-state/test/replayPlayback.test.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages-user/data-state/test/replayPlayback.test.ts b/packages-user/data-state/test/replayPlayback.test.ts index 1e6a692..cdc2a99 100644 --- a/packages-user/data-state/test/replayPlayback.test.ts +++ b/packages-user/data-state/test/replayPlayback.test.ts @@ -78,7 +78,7 @@ function withReplayDisabled(state: CoreState, action: () => T): T { } /** - * 用真实地图与勇士接口构造一个 3x3 小地图场景 + * 用真实地图与勇士接口构造一个 3x3 小地图场景,并返回创建出的地图 * @param state 顶层状态对象 * @param wireFinder 是否向寻路 finder 手动注入地图状态、事件层与通行谓词 */ @@ -113,6 +113,7 @@ function createSmallMapScene(state: CoreState, wireFinder: boolean = true) { ); } resetHero(state); + return map; } /** @@ -357,18 +358,21 @@ describe('small-map replay playback and second recording', () => { expect(state.hero.location.y).toBe(0); }); - // 疑似缺陷 #06-07-1:CoreState 未向寻路 finder 注入地图状态/事件层/通行谓词, - // 顶层录像瞬移恒返回 2005;本用例按正确预期编写,修复后取消 skip - it.skip('plays a teleport step without manual finder wiring', async () => { + // 顶层装配已提供 maps 与通行谓词,但事件层在切层后才设置, + // 本用例在楼层激活后由测试侧绑定事件层,验证顶层录像瞬移仍可解析出路径并到达目标 + it('plays a teleport step after the event layer is bound on floor activation', async () => { const state = createCoreState(); const replay = state.replaySystem; - withReplayDisabled(state, () => createSmallMapScene(state, false)); + const map = withReplayDisabled(state, () => + createSmallMapScene(state, false) + ); + state.pathfinding.finder.useMapLayer(map.eventLayer); await runHeroStep(state, FaceDirection.Right); - replay.record(ReplayCommandCode.Teleport, 1, 0); + replay.record(ReplayCommandCode.Teleport, 2, 0); await playRoute(state); - expect(state.hero.location.x).toBe(1); + expect(state.hero.location.x).toBe(2); expect(state.hero.location.y).toBe(0); }); });