@roster-lock/match-agent 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/index-D2395vmC.css +1 -0
- package/client/dist/assets/index-DcKsa72V.js +125 -0
- package/client/dist/index.html +2 -2
- package/client/e2e/lib/env.ts +50 -0
- package/client/e2e/lib/fileDialog.ts +31 -0
- package/client/e2e/lib/mockGamepad.ts +71 -0
- package/client/e2e/lib/onscreenKeyboard.ts +32 -0
- package/client/e2e/playwright.config.ts +48 -0
- package/client/e2e/tests/gamepad-only.spec.ts +274 -0
- package/client/e2e/tests/keyboard-only.spec.ts +67 -0
- package/client/e2e/tsconfig.json +15 -0
- package/client/node_modules/.bin/playwright +17 -0
- package/client/node_modules/.bin/roster-lock-plugin-manager +17 -0
- package/client/node_modules/.vite/deps/@rjsf_core.js +95 -95
- package/client/node_modules/.vite/deps/@rjsf_validator-ajv8.js +4 -3
- package/client/node_modules/.vite/deps/@roster-lock_ts-client.js +25 -25
- package/client/node_modules/.vite/deps/@roster-lock_types.js +2 -1
- package/client/node_modules/.vite/deps/@roster-lock_utils.js +2 -1
- package/client/node_modules/.vite/deps/_metadata.json +27 -27
- package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js → chunk-3HBL6DQ6.js} +99 -98
- package/client/node_modules/.vite/deps/{chunk-NE7PXY4V.js.map → chunk-3HBL6DQ6.js.map} +3 -3
- package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js → chunk-3IRPLLFB.js} +498 -501
- package/client/node_modules/.vite/deps/{chunk-4D2L7OBZ.js.map → chunk-3IRPLLFB.js.map} +1 -1
- package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js → chunk-7DRNB6P7.js} +5 -5
- package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js → chunk-FFVS6IUX.js} +6 -6
- package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js → chunk-G44QLPFQ.js} +6 -6
- package/client/node_modules/.vite/deps/{chunk-IIDO6PKU.js → chunk-QTQN6EZX.js} +98 -98
- package/client/node_modules/.vite/deps/chunk-QTQN6EZX.js.map +7 -0
- package/client/node_modules/.vite/deps/chunk-WMTNK64S.js +1 -0
- package/client/node_modules/.vite/deps/react-dom.js +3 -2
- package/client/node_modules/.vite/deps/react-dom_client.js +12 -12
- package/client/node_modules/.vite/deps/react-dom_client.js.map +1 -1
- package/client/node_modules/.vite/deps/react-router-dom.js +42 -9
- package/client/node_modules/.vite/deps/react.js +2 -1
- package/client/node_modules/.vite/deps/react_jsx-dev-runtime.js +5 -5
- package/client/node_modules/.vite/deps/react_jsx-runtime.js +3 -2
- package/client/package.json +4 -1
- package/client/src/App.tsx +23 -14
- package/client/src/NavBar.tsx +15 -5
- package/client/src/api/matchAgent.ts +208 -5
- package/client/src/bridge/hostBridge.ts +39 -10
- package/client/src/components/FullScreenMenu.tsx +32 -0
- package/client/src/components/GameLauncherSettingsForm.tsx +80 -5
- package/client/src/components/InputHints.tsx +37 -0
- package/client/src/components/InstallGameLauncherLightbox.tsx +27 -14
- package/client/src/components/OnScreenFileDialog.tsx +83 -0
- package/client/src/components/OnScreenKeyboard.tsx +75 -0
- package/client/src/components/Selection/PieceCard.tsx +29 -4
- package/client/src/components/Selection/PiecePreviewPanel.tsx +48 -0
- package/client/src/components/Selection/PieceTypeSection.tsx +124 -46
- package/client/src/components/Selection/PlayerSelectionPanel.tsx +1 -5
- package/client/src/components/Selection/index.tsx +72 -47
- package/client/src/context/GlobalNavContext.tsx +340 -0
- package/client/src/context/SelectionSourceContext.tsx +26 -0
- package/client/src/hooks/useCursorInput.ts +66 -24
- package/client/src/hooks/useDownloadedPieceVersions.ts +39 -0
- package/client/src/hooks/useGridColumns.ts +29 -0
- package/client/src/hooks/useInView.ts +32 -0
- package/client/src/hooks/usePiecePreview.ts +124 -0
- package/client/src/pages/Controls/index.tsx +126 -0
- package/client/src/pages/Game/index.tsx +11 -15
- package/client/src/pages/MatchMaking/index.tsx +14 -7
- package/client/src/pages/PreviewRoster/index.tsx +118 -0
- package/client/src/styles/global.css +355 -6
- package/client/src/utils/inputLabels.ts +25 -0
- package/client/test-results/.last-run.json +4 -0
- package/client/tsconfig.tsbuildinfo +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/inputBindings.js +40 -0
- package/dist/config/inputBindings.js.map +1 -0
- package/dist/config/manage.js +1 -0
- package/dist/config/manage.js.map +1 -1
- package/dist/handle-room/version-1/game-launcher/binaries.js +36 -0
- package/dist/handle-room/version-1/game-launcher/binaries.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/listing.js +24 -0
- package/dist/handle-room/version-1/game-launcher/listing.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/preview.js +38 -0
- package/dist/handle-room/version-1/game-launcher/preview.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/process.js +52 -0
- package/dist/handle-room/version-1/game-launcher/process.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/router.js +32 -0
- package/dist/handle-room/version-1/game-launcher/router.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/settings.js +49 -0
- package/dist/handle-room/version-1/game-launcher/settings.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/shared.js +28 -0
- package/dist/handle-room/version-1/game-launcher/shared.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/start.js +76 -0
- package/dist/handle-room/version-1/game-launcher/start.js.map +1 -0
- package/dist/handle-room/version-1/game-launcher/version.js +63 -0
- package/dist/handle-room/version-1/game-launcher/version.js.map +1 -0
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js +22 -9
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.js.map +1 -1
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js +50 -1
- package/dist/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.js.map +1 -1
- package/dist/handle-room/version-1/index.js +15 -15
- package/dist/handle-room/version-1/index.js.map +1 -1
- package/dist/handle-room/version-1/input-bindings.js +22 -0
- package/dist/handle-room/version-1/input-bindings.js.map +1 -0
- package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js +2 -1
- package/dist/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/http-handler.js +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/http-handler.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/steps.js +2 -1
- package/dist/handle-room/version-1/room-handler-bridge/steps.js.map +1 -1
- package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js +2 -2
- package/dist/handle-room/version-1/room-handler-bridge/ws-handler.js.map +1 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/util-routers/file-system/env.js +3 -0
- package/dist/util-routers/file-system/env.js.map +1 -0
- package/dist/util-routers/file-system/index.js +31 -0
- package/dist/util-routers/file-system/index.js.map +1 -0
- package/dist/util-routers/file-system/list.js +50 -0
- package/dist/util-routers/file-system/list.js.map +1 -0
- package/dist/util-routers/file-system/resolve-within-root.js +18 -0
- package/dist/util-routers/file-system/resolve-within-root.js.map +1 -0
- package/dist/util-routers/file-system/roster-lock.js +56 -0
- package/dist/util-routers/file-system/roster-lock.js.map +1 -0
- package/dist/utils/pick-file.js +82 -0
- package/dist/utils/pick-file.js.map +1 -0
- package/dist/utils/pick-folder.js +84 -0
- package/dist/utils/pick-folder.js.map +1 -0
- package/package.json +10 -7
- package/src/config/index.ts +8 -3
- package/src/config/inputBindings.ts +56 -0
- package/src/config/manage.ts +7 -0
- package/src/handle-room/version-1/game-launcher/binaries.ts +52 -0
- package/src/handle-room/version-1/game-launcher/listing.ts +36 -0
- package/src/handle-room/version-1/game-launcher/preview.ts +54 -0
- package/src/handle-room/version-1/game-launcher/process.ts +75 -0
- package/src/handle-room/version-1/game-launcher/router.ts +42 -0
- package/src/handle-room/version-1/game-launcher/settings.ts +58 -0
- package/src/handle-room/version-1/game-launcher/shared.ts +34 -0
- package/src/handle-room/version-1/game-launcher/start.ts +113 -0
- package/src/handle-room/version-1/game-launcher/version.ts +85 -0
- package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/ensurePieceExists.ts +39 -14
- package/src/handle-room/version-1/globals/FolderDB/SQLFolderDB/schema.ts +83 -1
- package/src/handle-room/version-1/globals/FolderDB/types.ts +24 -0
- package/src/handle-room/version-1/globals/types.ts +24 -2
- package/src/handle-room/version-1/index.ts +27 -25
- package/src/handle-room/version-1/input-bindings.ts +19 -0
- package/src/handle-room/version-1/room-handler-bridge/exchange-and-download-selections.ts +4 -1
- package/src/handle-room/version-1/room-handler-bridge/http-handler.ts +4 -1
- package/src/handle-room/version-1/room-handler-bridge/steps.ts +8 -0
- package/src/handle-room/version-1/room-handler-bridge/ws-handler.ts +2 -2
- package/src/index.ts +42 -10
- package/src/util-routers/file-system/env.ts +7 -0
- package/src/util-routers/file-system/index.ts +23 -0
- package/src/util-routers/file-system/list.ts +62 -0
- package/src/util-routers/file-system/resolve-within-root.ts +25 -0
- package/src/util-routers/file-system/roster-lock.ts +74 -0
- package/src/utils/pick-file.ts +81 -0
- package/src/utils/pick-folder.ts +92 -0
- package/tests/integration/filesystem.test.ts +117 -0
- package/tests/integration/game-launcher-binaries.test.ts +263 -0
- package/tests/integration/game-launcher-game-complete.test.ts +111 -0
- package/tests/integration/game-launcher-preview.test.ts +107 -0
- package/tests/integration/game-launcher-settings.test.ts +123 -8
- package/tests/integration/game-processes-ws.test.ts +122 -0
- package/tests/integration/helpers/fakeFolderDB.ts +16 -0
- package/tests/integration/helpers/fakePluginRuntime.ts +10 -1
- package/tests/integration/helpers/relayHarness.ts +24 -0
- package/tests/integration/helpers/server.ts +23 -3
- package/tests/integration/input-bindings.test.ts +94 -0
- package/tests/integration/piece-ensure-ws.test.ts +1 -1
- package/tests/integration/piece-files.test.ts +1 -1
- package/tests/integration/relay-protocol.test.ts +100 -0
- package/tests/integration/roster-lock.test.ts +86 -0
- package/tests/integration/sync-dl.test.ts +1 -1
- package/vitest.config.ts +7 -1
- package/client/dist/assets/index-DeYshswm.js +0 -125
- package/client/dist/assets/index-gxAuIfGQ.css +0 -1
- package/client/node_modules/.vite/deps/chunk-IIDO6PKU.js.map +0 -7
- package/client/node_modules/.vite/deps_temp_ab51ebe9/package.json +0 -3
- package/dist/handle-room/version-1/game-launcher.js +0 -181
- package/dist/handle-room/version-1/game-launcher.js.map +0 -1
- package/src/handle-room/version-1/game-launcher.ts +0 -263
- /package/client/node_modules/.vite/deps/{chunk-I55GDNGV.js.map → chunk-7DRNB6P7.js.map} +0 -0
- /package/client/node_modules/.vite/deps/{chunk-77TXW5ZT.js.map → chunk-FFVS6IUX.js.map} +0 -0
- /package/client/node_modules/.vite/deps/{chunk-5KLROPUR.js.map → chunk-G44QLPFQ.js.map} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach, vi } from "vitest";
|
|
2
|
+
import { once } from "node:events";
|
|
3
|
+
import { WebSocket } from "ws";
|
|
4
|
+
import { MessageBridge } from "@roster-lock/utils";
|
|
5
|
+
import { startTestServer, TestServer } from "./helpers/server";
|
|
6
|
+
import { createFixturePluginDir } from "./helpers/plugin-dir";
|
|
7
|
+
import { makeTempFolder, cleanupFolder } from "./helpers/piece";
|
|
8
|
+
import { makeValidLockConfig } from "./helpers/validLockConfig";
|
|
9
|
+
|
|
10
|
+
const HEADLESS = "@roster-lock/game-launcher-headless";
|
|
11
|
+
|
|
12
|
+
// Covers gameProcessesWs (game-launcher/process.ts) - the WS counterpart to
|
|
13
|
+
// listGameProcesses that pushes a fresh snapshot on connect and again on
|
|
14
|
+
// every process start/exit, so match-agent-client's Game page doesn't have
|
|
15
|
+
// to poll /game-launcher/processes.
|
|
16
|
+
describe("WS /v1/game-launcher/processes", () => {
|
|
17
|
+
const cleanups: Array<() => Promise<void> | void> = [];
|
|
18
|
+
afterEach(async () => {
|
|
19
|
+
while (cleanups.length) await cleanups.pop()!();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
async function setup(): Promise<TestServer> {
|
|
23
|
+
const fixture = await createFixturePluginDir([HEADLESS]);
|
|
24
|
+
cleanups.push(fixture.cleanup);
|
|
25
|
+
const folder = await makeTempFolder();
|
|
26
|
+
cleanups.push(() => cleanupFolder(folder));
|
|
27
|
+
const server = await startTestServer(folder, undefined, fixture.pluginDir);
|
|
28
|
+
cleanups.push(() => server.close());
|
|
29
|
+
return server;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function auth(server: TestServer): HeadersInit {
|
|
33
|
+
return { Authorization: `Bearer ${server.authCode}` };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ProcessSummary = { handleId: string, pluginName: string, exited: false | { code: number } };
|
|
37
|
+
|
|
38
|
+
// Unlike piece-ensure-ws.test.ts's connectReady, there's no separate
|
|
39
|
+
// "ready" handshake to wait for here - gameProcessesWs never receives a
|
|
40
|
+
// request, so its first "processes" push already is the readiness signal.
|
|
41
|
+
// Registers one persistent listener so a test can inspect every push, not
|
|
42
|
+
// just the first.
|
|
43
|
+
async function connectAndCollect(server: TestServer) {
|
|
44
|
+
const ws = new WebSocket(`${server.wsUrl}/v1/game-launcher/processes`, {
|
|
45
|
+
headers: { Authorization: `Bearer ${server.authCode}` },
|
|
46
|
+
});
|
|
47
|
+
const bridge = new MessageBridge((message) => ws.send(JSON.stringify(message)));
|
|
48
|
+
const updates: Array<Array<ProcessSummary>> = [];
|
|
49
|
+
const firstUpdate = new Promise<Array<ProcessSummary>>((resolve) => {
|
|
50
|
+
bridge.onEvent("processes", (snapshot) => {
|
|
51
|
+
updates.push(snapshot);
|
|
52
|
+
if (updates.length === 1) resolve(snapshot);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
ws.on("message", (data) => bridge.handleMessage(JSON.parse(data.toString())));
|
|
56
|
+
|
|
57
|
+
await once(ws, "open");
|
|
58
|
+
const initialSnapshot = await firstUpdate;
|
|
59
|
+
return { ws, bridge, updates, initialSnapshot };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function startHeadlessMatch(server: TestServer, winners: Array<string>, resultDelayMs: number) {
|
|
63
|
+
await fetch(`${server.httpUrl}/v1/game-launcher/${encodeURIComponent(HEADLESS)}/settings`, {
|
|
64
|
+
method: "PUT",
|
|
65
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
66
|
+
body: JSON.stringify({ binaryLocation: "headless" }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const res = await fetch(`${server.httpUrl}/v1/game-launcher/${encodeURIComponent(HEADLESS)}/start`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
connectionConfig: { type: "internal" },
|
|
74
|
+
currentMachine: { machineId: "m1", publicKey: "pk-a", privateKey: "sk" },
|
|
75
|
+
allMachines: [],
|
|
76
|
+
selectionResult: {},
|
|
77
|
+
rosterConfig: makeValidLockConfig(),
|
|
78
|
+
gameConfig: { winners, resultDelayMs },
|
|
79
|
+
relayRoomId: "room-1",
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
expect(res.status).toBe(200);
|
|
83
|
+
const { handleId } = await res.json();
|
|
84
|
+
return handleId as string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
it("sends an empty snapshot as soon as a client connects, with no process started", async () => {
|
|
88
|
+
const server = await setup();
|
|
89
|
+
const { ws, initialSnapshot } = await connectAndCollect(server);
|
|
90
|
+
ws.close();
|
|
91
|
+
expect(initialSnapshot).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("terminates the connection with no auth, without ever sending a snapshot", async () => {
|
|
95
|
+
const server = await setup();
|
|
96
|
+
const ws = new WebSocket(`${server.wsUrl}/v1/game-launcher/processes`);
|
|
97
|
+
let receivedMessage = false;
|
|
98
|
+
ws.on("message", () => { receivedMessage = true; });
|
|
99
|
+
ws.on("error", () => {}); // abrupt terminate() can surface as ECONNRESET - not the point of this test
|
|
100
|
+
|
|
101
|
+
await once(ws, "close");
|
|
102
|
+
expect(receivedMessage).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("pushes a snapshot when a process starts, and another once it exits", async () => {
|
|
106
|
+
const server = await setup();
|
|
107
|
+
const { ws, updates } = await connectAndCollect(server);
|
|
108
|
+
try {
|
|
109
|
+
const handleId = await startHeadlessMatch(server, [], 10);
|
|
110
|
+
|
|
111
|
+
await vi.waitFor(() => {
|
|
112
|
+
expect(updates).toContainEqual([{ handleId, pluginName: HEADLESS, exited: false }]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
await vi.waitFor(() => {
|
|
116
|
+
expect(updates.at(-1)).toEqual([{ handleId, pluginName: HEADLESS, exited: { code: 0 } }]);
|
|
117
|
+
});
|
|
118
|
+
} finally {
|
|
119
|
+
ws.close();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -34,4 +34,20 @@ export class FakeFolderDB implements IFolderDB {
|
|
|
34
34
|
async searchPieces(): ReturnType<IFolderDB["searchPieces"]>{
|
|
35
35
|
throw new Error("not implemented in FakeFolderDB");
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
async recordBinaryDownloaded(): ReturnType<IFolderDB["recordBinaryDownloaded"]>{
|
|
39
|
+
throw new Error("not implemented in FakeFolderDB");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async recordBinaryUsed(): ReturnType<IFolderDB["recordBinaryUsed"]>{
|
|
43
|
+
throw new Error("not implemented in FakeFolderDB");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async getBinaryUsageFor(): ReturnType<IFolderDB["getBinaryUsageFor"]>{
|
|
47
|
+
throw new Error("not implemented in FakeFolderDB");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async removeBinaryUsage(): ReturnType<IFolderDB["removeBinaryUsage"]>{
|
|
51
|
+
throw new Error("not implemented in FakeFolderDB");
|
|
52
|
+
}
|
|
37
53
|
}
|
|
@@ -62,7 +62,16 @@ class FakeGameLauncher implements IGameLauncher {
|
|
|
62
62
|
getSupportedVersion(): ReturnType<IGameLauncher["getSupportedVersion"]>{
|
|
63
63
|
throw new Error("Not Implemented");
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
getBinary(): ReturnType<IGameLauncher["getBinary"]>{
|
|
66
|
+
throw new Error("Not Implemented");
|
|
67
|
+
}
|
|
68
|
+
listBinaries(): ReturnType<IGameLauncher["listBinaries"]>{
|
|
69
|
+
throw new Error("Not Implemented");
|
|
70
|
+
}
|
|
71
|
+
removeBinary(): ReturnType<IGameLauncher["removeBinary"]>{
|
|
72
|
+
throw new Error("Not Implemented");
|
|
73
|
+
}
|
|
74
|
+
resolveBinaryLocation(): ReturnType<IGameLauncher["resolveBinaryLocation"]>{
|
|
66
75
|
throw new Error("Not Implemented");
|
|
67
76
|
}
|
|
68
77
|
startGame(): ReturnType<IGameLauncher["startGame"]>{
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { dirname } from "path";
|
|
2
|
+
import { createProcessHarness, RelayHarness, RelayHarnessConfig } from "@roster-lock/relay-conformance";
|
|
3
|
+
|
|
4
|
+
// Same spawn recipe as single-host's own tests/harness.ts, but resolved from
|
|
5
|
+
// outside that package - this harness proves match-agent's real client works
|
|
6
|
+
// against a real single-host process, so it can't reuse single-host's
|
|
7
|
+
// __dirname-relative PACKAGE_DIR.
|
|
8
|
+
const PACKAGE_DIR = dirname(require.resolve("@roster-lock/relay-server-hosted/package.json"));
|
|
9
|
+
|
|
10
|
+
export function createSingleHostHarness(): RelayHarness {
|
|
11
|
+
return createProcessHarness((port: number, config: RelayHarnessConfig) => ({
|
|
12
|
+
command: "npx",
|
|
13
|
+
args: ["tsx", "src/index.ts"],
|
|
14
|
+
cwd: PACKAGE_DIR,
|
|
15
|
+
env: {
|
|
16
|
+
...process.env,
|
|
17
|
+
PORT: String(port),
|
|
18
|
+
JWT_SECRET: config.jwtSecret,
|
|
19
|
+
GAME_COORDINATOR_ENCRYPTION_KEY: config.gameCoordinatorEncryptionKey,
|
|
20
|
+
INITIAL_ADMIN_USERNAME: config.initialAdmin.username,
|
|
21
|
+
INITIAL_ADMIN_PASSWORD: config.initialAdmin.password,
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { AddressInfo } from "node:net";
|
|
2
2
|
import { once } from "node:events";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { join as pathJoin } from "node:path";
|
|
5
|
+
import { mkdir } from "node:fs/promises";
|
|
4
6
|
|
|
5
7
|
import { PluginManager } from "@roster-lock/plugin-runtime";
|
|
6
8
|
import { MatchAgentServer } from "../../../src/server";
|
|
7
9
|
import { authMiddleware, validateAuthCode } from "../../../src/authentication";
|
|
8
10
|
import { createV1Routers } from "../../../src/handle-room/version-1";
|
|
9
11
|
import { createEditorV1Router } from "../../../src/editor-support";
|
|
12
|
+
import { createFileSystemRouter } from "../../../src/util-routers/file-system";
|
|
10
13
|
import { getSQLite3FolderDB } from "../../../src/handle-room/version-1/globals/FolderDB";
|
|
11
14
|
|
|
12
15
|
// Mirrors the wiring in src/index.ts#startServer, but keeps a handle to the
|
|
13
16
|
// underlying MatchAgentServer/http.Server so tests can bind an ephemeral
|
|
14
17
|
// port and shut the server down - startServer() itself returns void.
|
|
15
|
-
export async function startTestServer(
|
|
18
|
+
export async function startTestServer(
|
|
19
|
+
folder: string, authCode: string = randomUUID(), pluginDir?: string, rosterLockFolder?: string
|
|
20
|
+
) {
|
|
16
21
|
const server = new MatchAgentServer();
|
|
17
22
|
server.httpRouter.get("/", ({ res }) => {
|
|
18
23
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -22,16 +27,25 @@ export async function startTestServer(folder: string, authCode: string = randomU
|
|
|
22
27
|
|
|
23
28
|
const pluginRuntime = await PluginManager.create(pluginDir ?? folder);
|
|
24
29
|
const fileDB = getSQLite3FolderDB(folder, pluginRuntime);
|
|
30
|
+
// No real match-agent.json is written for a test server - this just
|
|
31
|
+
// gives input-bindings.ts somewhere (inside the test's own temp folder)
|
|
32
|
+
// to resolve its sibling input-bindings.json against.
|
|
33
|
+
const configFilePath = pathJoin(folder, "match-agent.json");
|
|
34
|
+
const resolvedRosterLockFolder = rosterLockFolder ?? pathJoin(folder, "roster-locks");
|
|
35
|
+
await mkdir(resolvedRosterLockFolder, { recursive: true });
|
|
25
36
|
// port isn't known until the ephemeral listen() below resolves - getPort()
|
|
26
37
|
// is only ever called from a request handler, by which point `port` has
|
|
27
38
|
// already been assigned.
|
|
28
39
|
let port = 0;
|
|
29
|
-
const { httpRouter: v1HttpRouter, wsRouter: v1WsRouter } = createV1Routers(
|
|
30
|
-
fileDB, pluginRuntime, { authCode, getPort: () => port }
|
|
40
|
+
const { httpRouter: v1HttpRouter, wsRouter: v1WsRouter, env } = createV1Routers(
|
|
41
|
+
fileDB, pluginRuntime, { authCode, getPort: () => port }, configFilePath
|
|
31
42
|
);
|
|
32
43
|
server.httpRouter.use("/v1", authMiddleware(authCode), v1HttpRouter);
|
|
33
44
|
server.wsRouter.use("/v1", authMiddleware(authCode), v1WsRouter);
|
|
34
45
|
server.httpRouter.use("/editor/v1", authMiddleware(authCode), createEditorV1Router(pluginRuntime, fileDB));
|
|
46
|
+
server.httpRouter.use(
|
|
47
|
+
"/util/file-system", authMiddleware(authCode), createFileSystemRouter(resolvedRosterLockFolder)
|
|
48
|
+
);
|
|
35
49
|
|
|
36
50
|
const nodeServer = server.listen(0);
|
|
37
51
|
await once(nodeServer, "listening");
|
|
@@ -42,6 +56,12 @@ export async function startTestServer(folder: string, authCode: string = randomU
|
|
|
42
56
|
port,
|
|
43
57
|
httpUrl: `http://localhost:${port}`,
|
|
44
58
|
wsUrl: `ws://localhost:${port}`,
|
|
59
|
+
rosterLockFolder: resolvedRosterLockFolder,
|
|
60
|
+
// Exposes the same in-memory state the v1 routes themselves read/write
|
|
61
|
+
// (e.g. gameCompletionContext) - lets a test seed or inspect it directly
|
|
62
|
+
// rather than having to drive a real room negotiation (which needs an
|
|
63
|
+
// actual relay server) just to set up a later request.
|
|
64
|
+
env,
|
|
45
65
|
close(): Promise<void> {
|
|
46
66
|
return new Promise((resolve, reject) => {
|
|
47
67
|
server.close((err?: Error) => err ? reject(err) : resolve());
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { startTestServer, TestServer } from "./helpers/server";
|
|
5
|
+
import { makeTempFolder, cleanupFolder } from "./helpers/piece";
|
|
6
|
+
|
|
7
|
+
describe("input-bindings routes", () => {
|
|
8
|
+
const cleanups: Array<() => Promise<void> | void> = [];
|
|
9
|
+
afterEach(async () => {
|
|
10
|
+
while (cleanups.length) await cleanups.pop()!();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function setup(): Promise<{ server: TestServer, folder: string }> {
|
|
14
|
+
const folder = await makeTempFolder();
|
|
15
|
+
cleanups.push(() => cleanupFolder(folder));
|
|
16
|
+
const server = await startTestServer(folder);
|
|
17
|
+
cleanups.push(() => server.close());
|
|
18
|
+
return { server, folder };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function auth(server: TestServer): HeadersInit {
|
|
22
|
+
return { Authorization: `Bearer ${server.authCode}` };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
it("GET returns the defaults before anything has been saved", async () => {
|
|
26
|
+
const { server } = await setup();
|
|
27
|
+
const res = await fetch(`${server.httpUrl}/v1/input-bindings`, { headers: auth(server) });
|
|
28
|
+
expect(res.status).toBe(200);
|
|
29
|
+
expect(await res.json()).toEqual({
|
|
30
|
+
keyboard: { select: "Enter", back: "Backspace", menu: " " },
|
|
31
|
+
gamepad: { select: 0, back: 1, menu: 9 },
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("PUT round-trips through GET", async () => {
|
|
36
|
+
const { server } = await setup();
|
|
37
|
+
const bindings = {
|
|
38
|
+
keyboard: { select: "e", back: "q", menu: "Tab" },
|
|
39
|
+
gamepad: { select: 2, back: 3, menu: 8 },
|
|
40
|
+
};
|
|
41
|
+
const putRes = await fetch(`${server.httpUrl}/v1/input-bindings`, {
|
|
42
|
+
method: "PUT",
|
|
43
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
44
|
+
body: JSON.stringify(bindings),
|
|
45
|
+
});
|
|
46
|
+
expect(putRes.status).toBe(200);
|
|
47
|
+
|
|
48
|
+
const getRes = await fetch(`${server.httpUrl}/v1/input-bindings`, { headers: auth(server) });
|
|
49
|
+
expect(await getRes.json()).toEqual(bindings);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("PUT rejects a missing action", async () => {
|
|
53
|
+
const { server } = await setup();
|
|
54
|
+
const res = await fetch(`${server.httpUrl}/v1/input-bindings`, {
|
|
55
|
+
method: "PUT",
|
|
56
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
57
|
+
body: JSON.stringify({ keyboard: { select: "e", back: "q" }, gamepad: { select: 2, back: 3, menu: 8 } }),
|
|
58
|
+
});
|
|
59
|
+
expect(res.status).toBe(400);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("PUT rejects unknown fields", async () => {
|
|
63
|
+
const { server } = await setup();
|
|
64
|
+
const res = await fetch(`${server.httpUrl}/v1/input-bindings`, {
|
|
65
|
+
method: "PUT",
|
|
66
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
keyboard: { select: "e", back: "q", menu: "Tab" }, gamepad: { select: 2, back: 3, menu: 8 }, extra: true,
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
expect(res.status).toBe(400);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// The whole point of storing this next to match-agent.json rather than in
|
|
75
|
+
// browser localStorage (see docs/economics/machine-environments/
|
|
76
|
+
// pieces-usb.md/cafe.md) is that it lives under the same portable root a
|
|
77
|
+
// USB's --config-file points at - this checks it actually lands there as
|
|
78
|
+
// its own sibling file, not somewhere disconnected from that root.
|
|
79
|
+
it("persists as input-bindings.json next to the test server's config file", async () => {
|
|
80
|
+
const { server, folder } = await setup();
|
|
81
|
+
await fetch(`${server.httpUrl}/v1/input-bindings`, {
|
|
82
|
+
method: "PUT",
|
|
83
|
+
headers: { ...auth(server), "Content-Type": "application/json" },
|
|
84
|
+
body: JSON.stringify({
|
|
85
|
+
keyboard: { select: "e", back: "q", menu: "Tab" }, gamepad: { select: 2, back: 3, menu: 8 },
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const onDisk = JSON.parse(await readFile(join(folder, "input-bindings.json"), "utf8"));
|
|
90
|
+
expect(onDisk).toEqual({
|
|
91
|
+
keyboard: { select: "e", back: "q", menu: "Tab" }, gamepad: { select: 2, back: 3, menu: 8 },
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -53,7 +53,7 @@ describe("WS /v1/piece/ensure", () => {
|
|
|
53
53
|
const { ws, bridge } = await connectReady();
|
|
54
54
|
try {
|
|
55
55
|
await expect(bridge.sendRequest("ensure-piece", { not: "a valid ensure-piece request" }))
|
|
56
|
-
.rejects.
|
|
56
|
+
.rejects.toThrow(/^Bad Form/);
|
|
57
57
|
} finally {
|
|
58
58
|
ws.close();
|
|
59
59
|
}
|
|
@@ -43,7 +43,7 @@ describe("/v1/piece/asset-files and /v1/piece/file-contents", () => {
|
|
|
43
43
|
engine, pieceType: TEST_PIECE_TYPE, piece, assetName: "sprite",
|
|
44
44
|
});
|
|
45
45
|
expect(res.status).toBe(404);
|
|
46
|
-
expect((await errorBody(res)).error).toBe("Piece
|
|
46
|
+
expect((await errorBody(res)).error).toBe("Piece doesn't exist");
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it("409s when the piece exists but hasn't finished downloading", async () => {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import { SIGNATURE_ASYMMETRIC } from "@roster-lock/utils";
|
|
3
|
+
import { RosterLockV1Config, RosterLockV1SyncDLRequestClientToAgent } from "@roster-lock/types";
|
|
4
|
+
import {
|
|
5
|
+
RelayHarness, CONFORMANCE_CONFIG, generateMachineDef, registerMatchmaker, createRoom, MachineDef,
|
|
6
|
+
} from "@roster-lock/relay-conformance";
|
|
7
|
+
import { exchangeAndDownloadSelections } from "../../src/handle-room/version-1/room-handler-bridge/exchange-and-download-selections";
|
|
8
|
+
import { FakeFolderDB } from "./helpers/fakeFolderDB";
|
|
9
|
+
import { FakePluginManager } from "./helpers/fakePluginRuntime";
|
|
10
|
+
import { createSingleHostHarness } from "./helpers/relayHarness";
|
|
11
|
+
|
|
12
|
+
// A schema-valid RosterLockV1Config with zero piece types. runSelection
|
|
13
|
+
// (core/shared/.../validate-select) iterates config.engine.pieceDefinitions -
|
|
14
|
+
// empty means it resolves to an empty FinalSelection without ever calling
|
|
15
|
+
// runUntrustedScript, and handleDownloads then iterates that empty
|
|
16
|
+
// FinalSelection without ever touching fileDB. That's what lets this test
|
|
17
|
+
// drive match-agent's *real* relay-facing client - the actual signing,
|
|
18
|
+
// fetch, WebSocket, MessageBridge, encryption, and step state machine - while
|
|
19
|
+
// staying entirely out of match-agent's plugin/download machinery, which
|
|
20
|
+
// already has its own coverage (e.g. piece-ensure-ws.test.ts).
|
|
21
|
+
const EMPTY_LOCK_CONFIG: RosterLockV1Config = {
|
|
22
|
+
configIdentity: { namespace: "roster-lock", purpose: "lock", version: 1 },
|
|
23
|
+
author: "match-agent-conformance",
|
|
24
|
+
title: "match-agent-conformance-empty-config",
|
|
25
|
+
version: "1.0.0",
|
|
26
|
+
engine: { name: "conformance-engine", version: "1.0.0", pieceDefinitions: {} },
|
|
27
|
+
rosters: {},
|
|
28
|
+
selection: { piece: {}, globalValidation: [], scriptDictionary: {} },
|
|
29
|
+
pieceMeta: {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// The room protocol has every machine decrypt every other machine's
|
|
33
|
+
// contribution (steps.ts's "all-decryption-for-user-final"), so both sides
|
|
34
|
+
// of this test must submit genuine ciphertext - @roster-lock/relay-conformance's
|
|
35
|
+
// wireHonestMachine deliberately returns fixed placeholder strings instead
|
|
36
|
+
// (it exists to prove the *relay* drives the protocol correctly without
|
|
37
|
+
// caring about payload contents), which the real client would then try to
|
|
38
|
+
// decrypt as if they were real. So this test pairs two real match-agent
|
|
39
|
+
// clients against each other over a real relay, rather than a real client
|
|
40
|
+
// against that fake one.
|
|
41
|
+
async function buildRoomRequest(
|
|
42
|
+
baseUrl: string, roomId: string, machine: MachineDef,
|
|
43
|
+
): Promise<RosterLockV1SyncDLRequestClientToAgent> {
|
|
44
|
+
const timestamp = Date.now();
|
|
45
|
+
const signature = await SIGNATURE_ASYMMETRIC.createSignature(machine.keys.privateSigningKey, {
|
|
46
|
+
service: "room-ws",
|
|
47
|
+
roomId,
|
|
48
|
+
publicKey: machine.keys.publicVerificationKey,
|
|
49
|
+
timestamp,
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
relay: { url: baseUrl, roomId },
|
|
53
|
+
machine: { timestamp, publicKey: machine.keys.publicVerificationKey, signature },
|
|
54
|
+
rosterConfig: EMPTY_LOCK_CONFIG,
|
|
55
|
+
playerSelections: { 0: {} },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Proves a real relay-server (single-host) and match-agent's real client
|
|
60
|
+
// (exchangeAndDownloadSelections/bindStepsToBridge) actually agree on the
|
|
61
|
+
// room protocol end to end - real signing, fetch, WebSocket, MessageBridge,
|
|
62
|
+
// encryption, and step state machine, driven against a real relay process.
|
|
63
|
+
describe("match-agent real client vs a real single-host relay", () => {
|
|
64
|
+
let harness: RelayHarness;
|
|
65
|
+
let baseUrl: string;
|
|
66
|
+
|
|
67
|
+
beforeAll(async () => {
|
|
68
|
+
harness = createSingleHostHarness();
|
|
69
|
+
({ baseUrl } = await harness.start(CONFORMANCE_CONFIG));
|
|
70
|
+
}, 60_000);
|
|
71
|
+
|
|
72
|
+
afterAll(async () => {
|
|
73
|
+
await harness.stop();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("two real machines converge on an empty final selection", async () => {
|
|
77
|
+
const loginRes = await fetch(`${baseUrl}/api/v1/admin/login`, {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify(CONFORMANCE_CONFIG.initialAdmin),
|
|
81
|
+
});
|
|
82
|
+
const { token: adminToken } = await loginRes.json() as { token: string };
|
|
83
|
+
|
|
84
|
+
const matchmakerKeys = await registerMatchmaker(baseUrl, adminToken, "match-agent-conformance");
|
|
85
|
+
const machineA = await generateMachineDef("machine-a", "Machine A");
|
|
86
|
+
const machineB = await generateMachineDef("machine-b", "Machine B");
|
|
87
|
+
|
|
88
|
+
const roomId = await createRoom(baseUrl, matchmakerKeys, [machineA, machineB]);
|
|
89
|
+
|
|
90
|
+
const [resultA, resultB] = await Promise.all([machineA, machineB].map(async (machine) => {
|
|
91
|
+
const roomRequest = await buildRoomRequest(baseUrl, roomId, machine);
|
|
92
|
+
return exchangeAndDownloadSelections(new FakeFolderDB(), new FakePluginManager(), roomRequest);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
expect(resultA.finalSelection).toEqual({});
|
|
96
|
+
expect(resultA.downloadResults).toEqual({});
|
|
97
|
+
expect(resultB.finalSelection).toEqual({});
|
|
98
|
+
expect(resultB.downloadResults).toEqual({});
|
|
99
|
+
}, 20_000);
|
|
100
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
+
import { writeFile, mkdir } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { startTestServer, TestServer } from "./helpers/server";
|
|
5
|
+
import { makeTempFolder, cleanupFolder, makeEngine } from "./helpers/piece";
|
|
6
|
+
|
|
7
|
+
// pickRosterLockFile isn't covered here - it spawns a real native OS
|
|
8
|
+
// dialog (zenity/kdialog/osascript/powershell), same as
|
|
9
|
+
// game-launcher/settings.ts's pickGameLauncherBinaryLocation, which has no
|
|
10
|
+
// test of its own for the same reason.
|
|
11
|
+
describe("GET /util/file-system/roster-lock", () => {
|
|
12
|
+
const cleanups: Array<() => Promise<void> | void> = [];
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
while (cleanups.length) await cleanups.pop()!();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
async function setup(): Promise<{ server: TestServer, rosterLockFolder: string }> {
|
|
18
|
+
const folder = await makeTempFolder();
|
|
19
|
+
cleanups.push(() => cleanupFolder(folder));
|
|
20
|
+
const server = await startTestServer(folder);
|
|
21
|
+
cleanups.push(() => server.close());
|
|
22
|
+
return { server, rosterLockFolder: server.rosterLockFolder };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function auth(server: TestServer): HeadersInit {
|
|
26
|
+
return { Authorization: `Bearer ${server.authCode}` };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
it("400s when path is missing", async () => {
|
|
30
|
+
const { server } = await setup();
|
|
31
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock`, { headers: auth(server) });
|
|
32
|
+
expect(res.status).toBe(400);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// The actual fix for this feature's exposure - see
|
|
36
|
+
// src/util-routers/file-system/resolve-within-root.ts.
|
|
37
|
+
it("403s for a path outside the configured roster-lock folder", async () => {
|
|
38
|
+
const { server } = await setup();
|
|
39
|
+
const res = await fetch(
|
|
40
|
+
`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent("/etc/passwd")}`, { headers: auth(server) }
|
|
41
|
+
);
|
|
42
|
+
expect(res.status).toBe(403);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("404s for a path that doesn't exist, within the root", async () => {
|
|
46
|
+
const { server, rosterLockFolder } = await setup();
|
|
47
|
+
const path = join(rosterLockFolder, "nope.roster-lock.json");
|
|
48
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent(path)}`, { headers: auth(server) });
|
|
49
|
+
expect(res.status).toBe(404);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("400s when the file isn't valid JSON", async () => {
|
|
53
|
+
const { server, rosterLockFolder } = await setup();
|
|
54
|
+
const path = join(rosterLockFolder, "garbage.roster-lock.json");
|
|
55
|
+
await writeFile(path, "not json");
|
|
56
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent(path)}`, { headers: auth(server) });
|
|
57
|
+
expect(res.status).toBe(400);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("400s when the JSON doesn't look like a roster-lock config", async () => {
|
|
61
|
+
const { server, rosterLockFolder } = await setup();
|
|
62
|
+
const path = join(rosterLockFolder, "unrelated.json");
|
|
63
|
+
await writeFile(path, JSON.stringify({ hello: "world" }));
|
|
64
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent(path)}`, { headers: auth(server) });
|
|
65
|
+
expect(res.status).toBe(400);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("reads and returns a valid roster-lock config", async () => {
|
|
69
|
+
const { server, rosterLockFolder } = await setup();
|
|
70
|
+
const config = { version: 1, engine: makeEngine(), rosters: { character: [] } };
|
|
71
|
+
const path = join(rosterLockFolder, "fixture.roster-lock.json");
|
|
72
|
+
await writeFile(path, JSON.stringify(config));
|
|
73
|
+
|
|
74
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent(path)}`, { headers: auth(server) });
|
|
75
|
+
expect(res.status).toBe(200);
|
|
76
|
+
expect(await res.json()).toEqual(config);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("400s when path points at a directory", async () => {
|
|
80
|
+
const { server, rosterLockFolder } = await setup();
|
|
81
|
+
const dirPath = join(rosterLockFolder, "a-directory");
|
|
82
|
+
await mkdir(dirPath);
|
|
83
|
+
const res = await fetch(`${server.httpUrl}/util/file-system/roster-lock?path=${encodeURIComponent(dirPath)}`, { headers: auth(server) });
|
|
84
|
+
expect(res.status).toBe(400);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -54,7 +54,7 @@ describe("WS /v1/sync-dl", () => {
|
|
|
54
54
|
await readyPromise;
|
|
55
55
|
|
|
56
56
|
await expect(bridge.sendRequest("connect-to-relay", { not: "a valid room request" }))
|
|
57
|
-
.rejects.
|
|
57
|
+
.rejects.toThrow("Invalid request");
|
|
58
58
|
} finally {
|
|
59
59
|
ws.close();
|
|
60
60
|
}
|
package/vitest.config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
1
|
+
import { defineConfig, configDefaults } from 'vitest/config';
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
test: {
|
|
@@ -6,5 +6,11 @@ export default defineConfig({
|
|
|
6
6
|
environment: 'node',
|
|
7
7
|
testTimeout: 10000,
|
|
8
8
|
hookTimeout: 10000,
|
|
9
|
+
// client/ (match-agent-client) is its own package with its own test
|
|
10
|
+
// tooling (tsc/vite, and Playwright specs under client/e2e) - vitest's
|
|
11
|
+
// default excludes don't know to skip a nested package's own test
|
|
12
|
+
// files, so without this, running `pnpm test` here also tries (and
|
|
13
|
+
// fails) to execute client/e2e's Playwright specs as vitest tests.
|
|
14
|
+
exclude: [...configDefaults.exclude, 'client/**'],
|
|
9
15
|
}
|
|
10
16
|
});
|