Enhance RuntimeHost unit tests to track and assert pressed keys state

This commit is contained in:
2026-04-27 19:35:11 +02:00
parent a2e1a31658
commit e7331529a6

View File

@@ -3979,6 +3979,7 @@ describe("RuntimeHost", () => {
}; };
runtimeScene: unknown; runtimeScene: unknown;
sceneReady: boolean; sceneReady: boolean;
pressedKeys: Set<string>;
activeRuntimeTargetReference: { activeRuntimeTargetReference: {
kind: "npc" | "interactable"; kind: "npc" | "interactable";
entityId: string; entityId: string;
@@ -4027,6 +4028,7 @@ describe("RuntimeHost", () => {
kind: "npc", kind: "npc",
entityId: "npc-active" entityId: "npc-active"
}; };
hostInternals.pressedKeys.add("Escape");
hostInternals.controllerContext.setPlayerControllerTelemetry({ hostInternals.controllerContext.setPlayerControllerTelemetry({
pointerLocked: true, pointerLocked: true,
hooks: { hooks: {
@@ -4047,6 +4049,7 @@ describe("RuntimeHost", () => {
kind: "npc", kind: "npc",
entityId: "npc-active" entityId: "npc-active"
}); });
expect(hostInternals.pressedKeys.size).toBe(0);
expect(exitPointerLock).not.toHaveBeenCalled(); expect(exitPointerLock).not.toHaveBeenCalled();
expect(escapeEvent.preventDefault).not.toHaveBeenCalled(); expect(escapeEvent.preventDefault).not.toHaveBeenCalled();
expect(escapeEvent.stopImmediatePropagation).toHaveBeenCalledTimes(1); expect(escapeEvent.stopImmediatePropagation).toHaveBeenCalledTimes(1);