Refactor ViewportPanel to use EditorSimulationController and add unit tests for player interact input bindings

This commit is contained in:
2026-04-27 15:43:26 +02:00
parent 775cbbb976
commit 2fbe69f243
2 changed files with 39 additions and 9 deletions

View File

@@ -1,7 +1,10 @@
import { describe, expect, it } from "vitest";
import { createPlayerStartInputBindings } from "../../src/entities/entity-instances";
import { resolvePlayerStartPauseInput } from "../../src/runtime-three/player-input-bindings";
import {
resolvePlayerStartInteractInput,
resolvePlayerStartPauseInput
} from "../../src/runtime-three/player-input-bindings";
function createMockGamepad(pressedButtons: number[] = []): Gamepad {
return {
@@ -51,3 +54,34 @@ describe("player-input-bindings pause input", () => {
).toBe(1);
});
});
describe("player-input-bindings interact input", () => {
it("resolves authored keyboard interact bindings", () => {
const bindings = createPlayerStartInputBindings({
keyboard: {
interact: "KeyE"
}
});
expect(resolvePlayerStartInteractInput(new Set(["MouseLeft"]), bindings, [])).toBe(
0
);
expect(resolvePlayerStartInteractInput(new Set(["KeyE"]), bindings, [])).toBe(
1
);
});
it("resolves the authored gamepad interact binding from the standard west button", () => {
const bindings = createPlayerStartInputBindings({
gamepad: {
interact: "buttonWest"
}
});
expect(
resolvePlayerStartInteractInput(new Set<string>(), bindings, [
createMockGamepad([2])
])
).toBe(1);
});
});