@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
package/client/dist/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Roster Lock - Match Agent</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DcKsa72V.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D2395vmC.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Shared by playwright.config.ts (which spins both servers up) and every
|
|
2
|
+
// spec (which needs to know where to point the browser/pre-seed settings,
|
|
3
|
+
// or - for CONFIG_FILE_PATH/ROSTER_LOCK_FOLDER - create fixtures the
|
|
4
|
+
// spawned match-agent will actually see).
|
|
5
|
+
import { mkdirSync } from "node:fs";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
|
|
9
|
+
export const MATCH_AGENT_PORT = 58799;
|
|
10
|
+
export const MATCH_AGENT_AUTH_CODE = "e2e-nav-test-auth-code";
|
|
11
|
+
export const MATCH_AGENT_URL = `http://localhost:${MATCH_AGENT_PORT}`;
|
|
12
|
+
|
|
13
|
+
export const CLIENT_PORT = 5199;
|
|
14
|
+
export const CLIENT_URL = `http://localhost:${CLIENT_PORT}`;
|
|
15
|
+
|
|
16
|
+
// This module gets loaded independently in several separate Node
|
|
17
|
+
// processes - playwright.config.ts's own loader, each test worker, and
|
|
18
|
+
// (indirectly) the spawned match-agent server never loads it at all but
|
|
19
|
+
// has to agree on where CONFIG_FILE_PATH/ROSTER_LOCK_FOLDER are regardless.
|
|
20
|
+
// A random mkdtemp() per load would give each process its own answer, so
|
|
21
|
+
// this has to be a fixed, deterministic path instead - safe here (unlike
|
|
22
|
+
// production use) because exactly one e2e run is ever expected on a
|
|
23
|
+
// machine at a time, same assumption MATCH_AGENT_PORT/CLIENT_PORT already
|
|
24
|
+
// make by being fixed rather than randomly chosen.
|
|
25
|
+
const CONFIG_DIR = join(tmpdir(), "roster-lock-match-agent-client-e2e");
|
|
26
|
+
export const CONFIG_FILE_PATH = join(CONFIG_DIR, "match-agent.json");
|
|
27
|
+
// match-agent's own default resolution of rosterLockFolder relative to
|
|
28
|
+
// CONFIG_FILE_PATH (a sibling "roster-locks" folder - see
|
|
29
|
+
// resolveConfigFolders), computed here rather than left implicit, so a
|
|
30
|
+
// spec can create fixtures inside the exact folder OnScreenFileDialog will
|
|
31
|
+
// browse by default, without needing its own --roster-lock-folder override.
|
|
32
|
+
export const ROSTER_LOCK_FOLDER = join(CONFIG_DIR, "roster-locks");
|
|
33
|
+
mkdirSync(ROSTER_LOCK_FOLDER, { recursive: true });
|
|
34
|
+
// Same reasoning as ROSTER_LOCK_FOLDER above, for match-agent's default
|
|
35
|
+
// pluginFolder (a sibling "plugins" folder - see resolveConfigFolders) -
|
|
36
|
+
// lets gamepad-only.spec.ts's binaries-list test install a real plugin
|
|
37
|
+
// straight onto disk (via @roster-lock/plugin-runtime's installPlugin)
|
|
38
|
+
// without needing a --plugin-folder override, and without match-agent
|
|
39
|
+
// ever needing a restart to see it: plugin-management's readManifest
|
|
40
|
+
// re-reads plugins.json fresh on every request, so a plugin dropped in
|
|
41
|
+
// after the server has already started is picked up by its very next
|
|
42
|
+
// request.
|
|
43
|
+
export const PLUGIN_FOLDER = join(CONFIG_DIR, "plugins");
|
|
44
|
+
mkdirSync(PLUGIN_FOLDER, { recursive: true });
|
|
45
|
+
|
|
46
|
+
// MatchAgentContext's own localStorage key/shape (core/match-agent/client/
|
|
47
|
+
// src/context/MatchAgentContext.tsx) - pre-seeding it lets a spec start
|
|
48
|
+
// already past the Connect page without a mouse *or* keyboard/gamepad text
|
|
49
|
+
// entry, for specs whose own point is something further into the app.
|
|
50
|
+
export const MATCH_AGENT_SETTINGS_STORAGE_KEY = "match-agent-client:match-agent";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
import { tapGamepadButton, GAMEPAD_BUTTON } from "./mockGamepad";
|
|
3
|
+
|
|
4
|
+
// Drives the on-screen file dialog (components/OnScreenFileDialog.tsx) the
|
|
5
|
+
// way a real gamepad-only player would: d-pad down to move to the next
|
|
6
|
+
// row, A to "press" the focused one (opening a folder or picking a file).
|
|
7
|
+
// Doesn't assume how many rows exist or what order they're in - unlike the
|
|
8
|
+
// on-screen keyboard's fixed layout, this is a real filesystem's own
|
|
9
|
+
// contents - so it looks the target row up by its accessible name and
|
|
10
|
+
// steps forward from wherever focus actually is, same approach as
|
|
11
|
+
// ./onscreenKeyboard.ts's typeViaOnscreenKeyboard.
|
|
12
|
+
export async function selectFileDialogEntry(page: Page, name: string): Promise<void> {
|
|
13
|
+
const rows = page.locator(".onscreen-file-dialog button");
|
|
14
|
+
const count = await rows.count();
|
|
15
|
+
|
|
16
|
+
let targetIndex = -1;
|
|
17
|
+
for (let i = 0; i < count; i++) {
|
|
18
|
+
const text = (await rows.nth(i).textContent())?.trim();
|
|
19
|
+
if (text === name) {
|
|
20
|
+
targetIndex = i;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (targetIndex === -1) throw new Error(`No file-dialog row found for ${JSON.stringify(name)}`);
|
|
25
|
+
|
|
26
|
+
const currentIndex = await rows.evaluateAll((buttons) => buttons.findIndex((b) => b === document.activeElement));
|
|
27
|
+
const from = currentIndex === -1 ? 0 : currentIndex;
|
|
28
|
+
const steps = (targetIndex - from + count) % count;
|
|
29
|
+
for (let i = 0; i < steps; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
30
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
31
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
const BUTTON_COUNT = 17;
|
|
4
|
+
|
|
5
|
+
// Matches GlobalNavContext's own DPAD_*/default gamepad bindings
|
|
6
|
+
// (core/match-agent/client/src/context/GlobalNavContext.tsx) - kept here
|
|
7
|
+
// too since a spec drives the mock gamepad by button index directly,
|
|
8
|
+
// rather than through the app's own (rebindable) config.
|
|
9
|
+
export const GAMEPAD_BUTTON = {
|
|
10
|
+
select: 0,
|
|
11
|
+
back: 1,
|
|
12
|
+
menu: 9,
|
|
13
|
+
dpadUp: 12,
|
|
14
|
+
dpadDown: 13,
|
|
15
|
+
dpadLeft: 14,
|
|
16
|
+
dpadRight: 15,
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
__mockGamepadState?: { buttons: Array<boolean>, axes: [number, number] };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// There's no real way to simulate a Gamepad API *connection* from outside
|
|
26
|
+
// the browser - neither Playwright nor CDP exposes a gamepad-injection
|
|
27
|
+
// protocol. But this app never listens for "gamepadconnected"; both
|
|
28
|
+
// GlobalNavContext and useCursorInput just poll navigator.getGamepads()
|
|
29
|
+
// every animation frame (see useGamepads.ts's own comment on why), so
|
|
30
|
+
// stubbing that one read is enough to drive the whole app with a fully
|
|
31
|
+
// scriptable fake controller. Must be called before page.goto() - an
|
|
32
|
+
// init script only applies to documents created after it's registered.
|
|
33
|
+
export async function installMockGamepad(page: Page): Promise<void> {
|
|
34
|
+
await page.addInitScript((buttonCount: number) => {
|
|
35
|
+
const state: { buttons: Array<boolean>, axes: [number, number] } = {
|
|
36
|
+
buttons: new Array(buttonCount).fill(false),
|
|
37
|
+
axes: [0, 0],
|
|
38
|
+
};
|
|
39
|
+
window.__mockGamepadState = state;
|
|
40
|
+
|
|
41
|
+
const fakePad = (): Gamepad => ({
|
|
42
|
+
id: "Mock Gamepad (Playwright)",
|
|
43
|
+
index: 0,
|
|
44
|
+
connected: true,
|
|
45
|
+
timestamp: performance.now(),
|
|
46
|
+
mapping: "standard",
|
|
47
|
+
axes: state.axes,
|
|
48
|
+
buttons: state.buttons.map((pressed) => ({ pressed, touched: pressed, value: pressed ? 1 : 0 })),
|
|
49
|
+
} as unknown as Gamepad);
|
|
50
|
+
|
|
51
|
+
navigator.getGamepads = () => [fakePad(), null, null, null] as Array<Gamepad | null>;
|
|
52
|
+
}, BUTTON_COUNT);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function setButton(page: Page, index: number, pressed: boolean): Promise<void> {
|
|
56
|
+
await page.evaluate(({ index, pressed }) => {
|
|
57
|
+
const state = window.__mockGamepadState;
|
|
58
|
+
if (state) state.buttons[index] = pressed;
|
|
59
|
+
}, { index, pressed });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Presses then releases, one frame apart - GlobalNavContext/useCursorInput
|
|
63
|
+
// both edge-detect (fire once per press, not once per frame a button reads
|
|
64
|
+
// held), so a tap has to actually transition false -> true -> false to
|
|
65
|
+
// read as one press rather than being held across every later assertion.
|
|
66
|
+
export async function tapGamepadButton(page: Page, index: number): Promise<void> {
|
|
67
|
+
await setButton(page, index, true);
|
|
68
|
+
await page.waitForTimeout(100);
|
|
69
|
+
await setButton(page, index, false);
|
|
70
|
+
await page.waitForTimeout(50);
|
|
71
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
import { tapGamepadButton, GAMEPAD_BUTTON } from "./mockGamepad";
|
|
3
|
+
|
|
4
|
+
// Drives the on-screen keyboard (core/match-agent/client/src/components/
|
|
5
|
+
// OnScreenKeyboard.tsx) the same way a real gamepad-only player would:
|
|
6
|
+
// d-pad right to move to the next key, A ("select") to press whichever
|
|
7
|
+
// one is focused. Doesn't assume ROWS' layout/order - looks each
|
|
8
|
+
// character's own button up by its text content and steps forward from
|
|
9
|
+
// wherever focus actually is, so it stays correct if that layout changes.
|
|
10
|
+
export async function typeViaOnscreenKeyboard(page: Page, text: string): Promise<void> {
|
|
11
|
+
const keys = page.locator(".onscreen-keyboard button");
|
|
12
|
+
const count = await keys.count();
|
|
13
|
+
|
|
14
|
+
for (const char of text) {
|
|
15
|
+
const label = char === " " ? "Space" : char;
|
|
16
|
+
let targetIndex = -1;
|
|
17
|
+
for (let i = 0; i < count; i++) {
|
|
18
|
+
const content = (await keys.nth(i).textContent())?.trim();
|
|
19
|
+
if (content === label) {
|
|
20
|
+
targetIndex = i;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (targetIndex === -1) throw new Error(`No on-screen-keyboard key found for ${JSON.stringify(char)}`);
|
|
25
|
+
|
|
26
|
+
const currentIndex = await keys.evaluateAll((buttons) => buttons.findIndex((b) => b === document.activeElement));
|
|
27
|
+
const from = currentIndex === -1 ? 0 : currentIndex;
|
|
28
|
+
const steps = (targetIndex - from + count) % count;
|
|
29
|
+
for (let i = 0; i < steps; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadRight);
|
|
30
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineConfig } from "@playwright/test";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { MATCH_AGENT_PORT, MATCH_AGENT_AUTH_CODE, MATCH_AGENT_URL, CLIENT_PORT, CLIENT_URL, CONFIG_FILE_PATH } from "./lib/env";
|
|
5
|
+
|
|
6
|
+
// This package's own root (one level up from e2e/) - both webServer
|
|
7
|
+
// commands below run from here, not from e2e/ itself.
|
|
8
|
+
const packageRoot = join(fileURLToPath(new URL(".", import.meta.url)), "..");
|
|
9
|
+
|
|
10
|
+
// Covers only the shell app's own pages - Connect, the full-screen
|
|
11
|
+
// menu/NavBar, Join Settings, Game Launchers list, Controls, and Match
|
|
12
|
+
// Making's own controls - navigated with the keyboard/gamepad schemes
|
|
13
|
+
// GlobalNavContext drives (see e2e/tests). No plugins, Docker, or real
|
|
14
|
+
// game binaries are needed, unlike examples/mugen/playwright's full-infra
|
|
15
|
+
// suite: the embedded matchmaker <iframe> (titled-room/client) and the
|
|
16
|
+
// piece-selection grid inside it are out of scope here.
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
testDir: "./tests",
|
|
19
|
+
timeout: 30_000,
|
|
20
|
+
expect: { timeout: 5_000 },
|
|
21
|
+
fullyParallel: true,
|
|
22
|
+
retries: 0,
|
|
23
|
+
reporter: [["list"]],
|
|
24
|
+
use: {
|
|
25
|
+
baseURL: CLIENT_URL,
|
|
26
|
+
trace: "retain-on-failure",
|
|
27
|
+
},
|
|
28
|
+
webServer: [
|
|
29
|
+
{
|
|
30
|
+
command: (
|
|
31
|
+
`node ../dist/index.js listen --port ${MATCH_AGENT_PORT} --auth-code ${MATCH_AGENT_AUTH_CODE} ` +
|
|
32
|
+
`--config-file ${CONFIG_FILE_PATH}`
|
|
33
|
+
),
|
|
34
|
+
url: `${MATCH_AGENT_URL}/health`,
|
|
35
|
+
reuseExistingServer: false,
|
|
36
|
+
timeout: 20_000,
|
|
37
|
+
cwd: packageRoot,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
command: `pnpm exec vite --port ${CLIENT_PORT} --strictPort`,
|
|
41
|
+
url: CLIENT_URL,
|
|
42
|
+
reuseExistingServer: false,
|
|
43
|
+
timeout: 30_000,
|
|
44
|
+
cwd: packageRoot,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
projects: [{ name: "chromium", use: { browserName: "chromium" } }],
|
|
48
|
+
});
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// Every interaction below goes through installMockGamepad/tapGamepadButton
|
|
2
|
+
// - no .click()/.fill()/page.keyboard anywhere in this file. This is the
|
|
3
|
+
// other half of "no mouse, keyboard or gamepad only": a mocked gamepad is
|
|
4
|
+
// the sole input device driving the whole test (see ../lib/mockGamepad.ts
|
|
5
|
+
// for why/how navigator.getGamepads() can be stubbed at all).
|
|
6
|
+
import { mkdir, writeFile, rm } from "node:fs/promises";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { test, expect, Page } from "@playwright/test";
|
|
10
|
+
import { installPlugin, PluginManager } from "@roster-lock/plugin-runtime";
|
|
11
|
+
import { installMockGamepad, tapGamepadButton, GAMEPAD_BUTTON } from "../lib/mockGamepad";
|
|
12
|
+
import { typeViaOnscreenKeyboard } from "../lib/onscreenKeyboard";
|
|
13
|
+
import { selectFileDialogEntry } from "../lib/fileDialog";
|
|
14
|
+
import {
|
|
15
|
+
MATCH_AGENT_URL, MATCH_AGENT_AUTH_CODE, MATCH_AGENT_SETTINGS_STORAGE_KEY, ROSTER_LOCK_FOLDER, PLUGIN_FOLDER,
|
|
16
|
+
} from "../lib/env";
|
|
17
|
+
|
|
18
|
+
// Seeds MatchAgentContext's own localStorage settings before the app's
|
|
19
|
+
// first script runs, so ConnectPage's autoSubmit effect connects on its
|
|
20
|
+
// own. Typing a URL/auth code via a gamepad is exactly what the second
|
|
21
|
+
// test in this file proves separately (through the on-screen keyboard) -
|
|
22
|
+
// re-proving it here would just make this test about something else.
|
|
23
|
+
async function seedConnectedSettings(page: Page): Promise<void> {
|
|
24
|
+
await page.addInitScript(
|
|
25
|
+
({ key, url, authCode }: { key: string, url: string, authCode: string }) => {
|
|
26
|
+
localStorage.setItem(key, JSON.stringify({ url, authCode }));
|
|
27
|
+
},
|
|
28
|
+
{ key: MATCH_AGENT_SETTINGS_STORAGE_KEY, url: MATCH_AGENT_URL, authCode: MATCH_AGENT_AUTH_CODE }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test("navigate pages using only a mocked gamepad", async ({ page }) => {
|
|
33
|
+
await installMockGamepad(page);
|
|
34
|
+
await seedConnectedSettings(page);
|
|
35
|
+
await page.goto("/");
|
|
36
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
37
|
+
|
|
38
|
+
// Menu (Start) - reaches NavBar's links in one press. NavBar itself
|
|
39
|
+
// renders the same links outside #page-content (see App.tsx), so
|
|
40
|
+
// locators below are scoped to .fullscreen-menu specifically - otherwise
|
|
41
|
+
// "Match Making"/"Controls"/"Join Settings" would each match two <a>
|
|
42
|
+
// elements.
|
|
43
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.menu);
|
|
44
|
+
const menu = page.locator(".fullscreen-menu");
|
|
45
|
+
await expect(menu).toBeVisible();
|
|
46
|
+
await expect(menu.getByRole("link", { name: "Match Making", exact: true })).toBeFocused();
|
|
47
|
+
|
|
48
|
+
// Move (d-pad down) - NAV_LINKS order is Match Making, Games, Join
|
|
49
|
+
// Settings, Game Launchers, Preview Roster, Controls, Connect - five
|
|
50
|
+
// presses reaches Controls, same as the keyboard spec's ArrowDown sequence.
|
|
51
|
+
for (let i = 0; i < 5; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
52
|
+
await expect(menu.getByRole("link", { name: "Controls", exact: true })).toBeFocused();
|
|
53
|
+
|
|
54
|
+
// Select (A)
|
|
55
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
56
|
+
await expect(page).toHaveURL(/\/controls$/);
|
|
57
|
+
await expect(page.getByRole("heading", { name: "Controls" })).toBeVisible();
|
|
58
|
+
|
|
59
|
+
// Back (B) - browser-back, since neither the menu nor the on-screen
|
|
60
|
+
// keyboard is open.
|
|
61
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.back);
|
|
62
|
+
await expect(page).toHaveURL(/\/match-making$/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("confirming a text field with the gamepad opens the on-screen keyboard, which can type into it", async ({ page }) => {
|
|
66
|
+
await installMockGamepad(page);
|
|
67
|
+
await seedConnectedSettings(page);
|
|
68
|
+
await page.goto("/");
|
|
69
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
70
|
+
|
|
71
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.menu);
|
|
72
|
+
const menu = page.locator(".fullscreen-menu");
|
|
73
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
74
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
75
|
+
await expect(menu.getByRole("link", { name: "Join Settings", exact: true })).toBeFocused();
|
|
76
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
77
|
+
await expect(page).toHaveURL(/\/join-settings$/);
|
|
78
|
+
|
|
79
|
+
const labelInput = page.locator(".player-slot-row input").first();
|
|
80
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
81
|
+
await expect(labelInput).toBeFocused();
|
|
82
|
+
|
|
83
|
+
// Select on a focused text field opens the on-screen keyboard instead of
|
|
84
|
+
// clicking it - a controller has no other way to type.
|
|
85
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
86
|
+
await expect(page.locator(".onscreen-keyboard")).toBeVisible();
|
|
87
|
+
|
|
88
|
+
await typeViaOnscreenKeyboard(page, "hi");
|
|
89
|
+
await expect(labelInput).toHaveValue(/hi$/);
|
|
90
|
+
|
|
91
|
+
// Back closes the on-screen keyboard rather than navigating away.
|
|
92
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.back);
|
|
93
|
+
await expect(page.locator(".onscreen-keyboard")).toBeHidden();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("a focused <select> doesn't trap Move - gamepad only", async ({ page }) => {
|
|
97
|
+
await installMockGamepad(page);
|
|
98
|
+
await seedConnectedSettings(page);
|
|
99
|
+
await page.goto("/");
|
|
100
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
101
|
+
|
|
102
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.menu);
|
|
103
|
+
const menu = page.locator(".fullscreen-menu");
|
|
104
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
105
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
106
|
+
await expect(menu.getByRole("link", { name: "Join Settings", exact: true })).toBeFocused();
|
|
107
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
108
|
+
await expect(page).toHaveURL(/\/join-settings$/);
|
|
109
|
+
|
|
110
|
+
// First Move press lands on the first focusable control (nothing was
|
|
111
|
+
// focused after navigating) - the default single slot's own label input.
|
|
112
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
113
|
+
await expect(page.locator(".player-slot-row input").first()).toBeFocused();
|
|
114
|
+
|
|
115
|
+
// Second press reaches the input-device <select>. A gamepad has no
|
|
116
|
+
// Tab-equivalent fallback the way a keyboard does (see
|
|
117
|
+
// keyboard-only.spec.ts's comment on why this scenario doesn't need a
|
|
118
|
+
// keyboard version at all) - before GlobalNavContext split Move into
|
|
119
|
+
// up/down (always move) vs left/right (adjust a focused select, else
|
|
120
|
+
// also move), a further d-pad-down here would forward into stepSelect
|
|
121
|
+
// and - since this select has only one option ("Keyboard") before any
|
|
122
|
+
// gamepad is assigned as a player's own input source - silently do
|
|
123
|
+
// nothing, permanently trapping focus on it.
|
|
124
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
125
|
+
await expect(page.locator(".player-slot-row select").first()).toBeFocused();
|
|
126
|
+
|
|
127
|
+
// Third press must move *past* the select - this is the actual
|
|
128
|
+
// regression check. The default slot's own Remove button is disabled
|
|
129
|
+
// (only one slot exists) and so isn't part of the focusable list at all,
|
|
130
|
+
// so this lands on "Add local player" instead.
|
|
131
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
132
|
+
await expect(page.getByRole("button", { name: "Add local player" })).toBeFocused();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("picks a file through the on-screen file dialog using only a mocked gamepad", async ({ page }) => {
|
|
136
|
+
// The dialog lists match-agent's own host filesystem, bounded to its
|
|
137
|
+
// configured rosterLockFolder (see util-routers/file-system/
|
|
138
|
+
// resolve-within-root.ts) - a real fixture folder/file inside that exact
|
|
139
|
+
// folder, not a native dialog's own canned state, is what proves
|
|
140
|
+
// navigating it with the gamepad actually works. Placed via a nested
|
|
141
|
+
// folder (rather than typed in via the on-screen keyboard) because
|
|
142
|
+
// typing a long path one on-screen keypress at a time is slow enough to
|
|
143
|
+
// risk the test's own timeout - navigating two short folder hops by
|
|
144
|
+
// d-pad is both faster and closer to this dialog's actual point.
|
|
145
|
+
const folderName = "roster-lock-e2e-filedialog-fixture";
|
|
146
|
+
const folder = join(ROSTER_LOCK_FOLDER, folderName);
|
|
147
|
+
const fixturePath = join(folder, "fixture.roster-lock.json");
|
|
148
|
+
await mkdir(folder, { recursive: true });
|
|
149
|
+
await writeFile(fixturePath, JSON.stringify({ version: 1, engine: { name: "x" }, rosters: {} }));
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
await installMockGamepad(page);
|
|
153
|
+
await seedConnectedSettings(page);
|
|
154
|
+
await page.goto("/");
|
|
155
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
156
|
+
|
|
157
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.menu);
|
|
158
|
+
const menu = page.locator(".fullscreen-menu");
|
|
159
|
+
// NAV_LINKS order is Match Making, Games, Join Settings, Game
|
|
160
|
+
// Launchers, Preview Roster, Controls, Connect - four presses reaches
|
|
161
|
+
// Preview Roster.
|
|
162
|
+
for (let i = 0; i < 4; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
163
|
+
await expect(menu.getByRole("link", { name: "Preview Roster", exact: true })).toBeFocused();
|
|
164
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
165
|
+
await expect(page).toHaveURL(/\/preview-roster$/);
|
|
166
|
+
|
|
167
|
+
// Two Move presses: first lands on the (empty) path input, second on
|
|
168
|
+
// "Browse..." - confirming it opens the dialog instead of a native OS
|
|
169
|
+
// one, which a gamepad could never reach at all.
|
|
170
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
171
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
172
|
+
await expect(page.getByRole("button", { name: "Browse..." })).toBeFocused();
|
|
173
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
174
|
+
const dialog = page.locator(".onscreen-file-dialog");
|
|
175
|
+
await expect(dialog).toBeVisible();
|
|
176
|
+
|
|
177
|
+
// The path input was left empty, so the dialog opened at match-agent's
|
|
178
|
+
// own host home directory - navigate into the fixture folder, then
|
|
179
|
+
// pick the fixture file, by accessible name rather than any assumed
|
|
180
|
+
// position (a real home directory's own other contents are outside
|
|
181
|
+
// this test's control).
|
|
182
|
+
await selectFileDialogEntry(page, `${folderName}/`);
|
|
183
|
+
const pathInput = page.locator('input[placeholder="Path to a .roster-lock.json file"]');
|
|
184
|
+
await expect(dialog.getByRole("button", { name: "fixture.roster-lock.json", exact: true })).toBeVisible();
|
|
185
|
+
await selectFileDialogEntry(page, "fixture.roster-lock.json");
|
|
186
|
+
|
|
187
|
+
await expect(dialog).toBeHidden();
|
|
188
|
+
await expect(pathInput).toHaveValue(fixturePath);
|
|
189
|
+
} finally {
|
|
190
|
+
await rm(folder, { recursive: true, force: true });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// The only test in this suite that installs a real plugin - everything
|
|
195
|
+
// else deliberately avoids plugins/Docker/real binaries (see
|
|
196
|
+
// playwright.config.ts's own comment on why). Removing a downloaded
|
|
197
|
+
// binary needs a real, loadable GameLauncherPlugin to list in the first
|
|
198
|
+
// place, so this is the one exception. Kept to this file only (not
|
|
199
|
+
// duplicated into keyboard-only.spec.ts): it's the sole test anywhere in
|
|
200
|
+
// this suite that mutates the shared match-agent instance's game-launcher
|
|
201
|
+
// settings/binaries for one plugin, and fullyParallel:true means another
|
|
202
|
+
// copy of this same test running concurrently in a second file would race
|
|
203
|
+
// it over that same shared state.
|
|
204
|
+
const HEADLESS_PLUGIN_NAME = "@roster-lock/game-launcher-headless";
|
|
205
|
+
const HEADLESS_PLUGIN_DIR = join(
|
|
206
|
+
fileURLToPath(new URL(".", import.meta.url)), "../../../../../plugins/game-launcher/headless"
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
test("removes a downloaded binary through the game-launcher settings page using only a mocked gamepad", async ({ page }) => {
|
|
210
|
+
// Installed straight onto match-agent's own already-running plugin
|
|
211
|
+
// folder (plugin-management's readManifest re-reads plugins.json fresh
|
|
212
|
+
// per request - no restart needed, see PLUGIN_FOLDER's own comment in
|
|
213
|
+
// ../lib/env.ts) - headless chosen because it needs no real binary and
|
|
214
|
+
// its getLocalVersion always succeeds, so listBinaries has something
|
|
215
|
+
// real to report once a folder exists under its dataDir below.
|
|
216
|
+
await installPlugin(PLUGIN_FOLDER, HEADLESS_PLUGIN_DIR);
|
|
217
|
+
|
|
218
|
+
// Stands in for what getBinary would have produced for a plugin that
|
|
219
|
+
// actually implements it (headless doesn't) - same trick as
|
|
220
|
+
// core/match-agent/tests/integration/game-launcher-binaries.test.ts's
|
|
221
|
+
// identically-purposed regression test. Stored *relative* to
|
|
222
|
+
// PLUGIN_FOLDER deliberately, matching what a real download would
|
|
223
|
+
// persist (see relativizeBinaryLocation) rather than an absolute path.
|
|
224
|
+
const relativeBinaryLocation = join("data", HEADLESS_PLUGIN_NAME, "binaries", "v1");
|
|
225
|
+
await mkdir(join(PLUGIN_FOLDER, relativeBinaryLocation), { recursive: true });
|
|
226
|
+
const pluginManager = await PluginManager.create(PLUGIN_FOLDER);
|
|
227
|
+
await pluginManager.gameLauncher.setLocalSettings(HEADLESS_PLUGIN_NAME, { binaryLocation: relativeBinaryLocation });
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
await installMockGamepad(page);
|
|
231
|
+
await seedConnectedSettings(page);
|
|
232
|
+
await page.goto("/");
|
|
233
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
234
|
+
|
|
235
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.menu);
|
|
236
|
+
const menu = page.locator(".fullscreen-menu");
|
|
237
|
+
// NAV_LINKS order is Match Making, Games, Join Settings, Game
|
|
238
|
+
// Launchers, Preview Roster, Controls, Connect - three presses
|
|
239
|
+
// reaches Game Launchers.
|
|
240
|
+
for (let i = 0; i < 3; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
241
|
+
await expect(menu.getByRole("link", { name: "Game Launchers", exact: true })).toBeFocused();
|
|
242
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
243
|
+
await expect(page).toHaveURL(/\/game-launcher$/);
|
|
244
|
+
|
|
245
|
+
// One Move press reaches the list's only link (this plugin is the
|
|
246
|
+
// only one ever installed into PLUGIN_FOLDER across the whole suite).
|
|
247
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
248
|
+
const launcherLink = page.getByRole("link", { name: "Headless (Test Fixture)" });
|
|
249
|
+
await expect(launcherLink).toBeFocused();
|
|
250
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
251
|
+
await expect(page).toHaveURL(`/game-launcher/${encodeURIComponent(HEADLESS_PLUGIN_NAME)}`);
|
|
252
|
+
|
|
253
|
+
// Wait for both async loads (GameLauncherSettingsForm's own load() and
|
|
254
|
+
// loadBinaries()) to settle before counting Move presses below -
|
|
255
|
+
// otherwise "Check version" may still be disabled (no binaryLocation
|
|
256
|
+
// yet) and the binaries <ul> may not have rendered, both of which
|
|
257
|
+
// would shift the focusable list's order.
|
|
258
|
+
await expect(page.getByLabel("Binary location")).toHaveValue(relativeBinaryLocation);
|
|
259
|
+
const binariesList = page.locator(".game-launcher-binaries-list");
|
|
260
|
+
await expect(binariesList.locator("li")).toHaveCount(1);
|
|
261
|
+
|
|
262
|
+
// Six Move presses: Binary location input, Browse..., Save, Check
|
|
263
|
+
// version, Download / update, then this one downloaded binary's own
|
|
264
|
+
// Remove button.
|
|
265
|
+
for (let i = 0; i < 6; i++) await tapGamepadButton(page, GAMEPAD_BUTTON.dpadDown);
|
|
266
|
+
await expect(binariesList.getByRole("button", { name: "Remove" })).toBeFocused();
|
|
267
|
+
|
|
268
|
+
await tapGamepadButton(page, GAMEPAD_BUTTON.select);
|
|
269
|
+
await expect(binariesList).toBeHidden();
|
|
270
|
+
} finally {
|
|
271
|
+
await rm(join(PLUGIN_FOLDER, relativeBinaryLocation), { recursive: true, force: true });
|
|
272
|
+
await pluginManager.gameLauncher.setLocalSettings(HEADLESS_PLUGIN_NAME, {});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Every interaction below uses page.keyboard only - no .click()/.fill()
|
|
2
|
+
// anywhere in this file. That's the actual thing under test: a player who
|
|
3
|
+
// has only a keyboard (no mouse, no gamepad) must be able to reach and
|
|
4
|
+
// operate every page this suite covers via GlobalNavContext's Select/Back/
|
|
5
|
+
// Menu/Move scheme (core/match-agent/client/src/context/GlobalNavContext.tsx).
|
|
6
|
+
import { test, expect } from "@playwright/test";
|
|
7
|
+
import { MATCH_AGENT_URL, MATCH_AGENT_AUTH_CODE } from "../lib/env";
|
|
8
|
+
|
|
9
|
+
async function connect(page: import("@playwright/test").Page): Promise<void> {
|
|
10
|
+
await page.goto("/");
|
|
11
|
+
// Waits for the field to actually be there before tabbing to it - a bare
|
|
12
|
+
// Tab immediately after goto() can race the app's first render.
|
|
13
|
+
await expect(page.getByLabel("Match Agent URL")).toBeVisible();
|
|
14
|
+
await page.keyboard.press("Tab");
|
|
15
|
+
await expect(page.getByLabel("Match Agent URL")).toBeFocused();
|
|
16
|
+
await page.keyboard.press("Control+A");
|
|
17
|
+
await page.keyboard.type(MATCH_AGENT_URL);
|
|
18
|
+
await page.keyboard.press("Tab");
|
|
19
|
+
await expect(page.getByLabel("Auth Code")).toBeFocused();
|
|
20
|
+
await page.keyboard.press("Control+A");
|
|
21
|
+
await page.keyboard.type(MATCH_AGENT_AUTH_CODE);
|
|
22
|
+
// Submits the form natively - GlobalNavContext's own Enter handling is
|
|
23
|
+
// skipped while a text field is focused (see isTyping in useCursorInput.ts).
|
|
24
|
+
await page.keyboard.press("Enter");
|
|
25
|
+
await expect(page).toHaveURL(/\/match-making$/, { timeout: 15_000 });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
test("connect, then open the menu and navigate pages - keyboard only", async ({ page }) => {
|
|
29
|
+
await connect(page);
|
|
30
|
+
|
|
31
|
+
// Menu (Space) - reaches NavBar's links in one press rather than
|
|
32
|
+
// Tab-ing all the way up to them. NavBar itself renders the same links
|
|
33
|
+
// outside #page-content (see App.tsx), so locators below are scoped to
|
|
34
|
+
// .fullscreen-menu specifically - otherwise "Match Making"/"Controls"
|
|
35
|
+
// would each match two <a> elements.
|
|
36
|
+
await page.keyboard.press("Space");
|
|
37
|
+
const menu = page.locator(".fullscreen-menu");
|
|
38
|
+
await expect(menu).toBeVisible();
|
|
39
|
+
await expect(menu.getByRole("link", { name: "Match Making", exact: true })).toBeFocused();
|
|
40
|
+
|
|
41
|
+
// Move (arrow keys) - NAV_LINKS order is Match Making, Games, Join
|
|
42
|
+
// Settings, Game Launchers, Preview Roster, Controls, Connect - five
|
|
43
|
+
// presses reaches Controls.
|
|
44
|
+
for (let i = 0; i < 5; i++) await page.keyboard.press("ArrowDown");
|
|
45
|
+
await expect(menu.getByRole("link", { name: "Controls", exact: true })).toBeFocused();
|
|
46
|
+
|
|
47
|
+
// Select (Enter) - follows the focused link and closes the menu.
|
|
48
|
+
await page.keyboard.press("Enter");
|
|
49
|
+
await expect(page).toHaveURL(/\/controls$/);
|
|
50
|
+
await expect(page.getByRole("heading", { name: "Controls" })).toBeVisible();
|
|
51
|
+
await expect(page.locator(".fullscreen-menu")).toBeHidden();
|
|
52
|
+
|
|
53
|
+
// Back (Backspace) - browser-back, since neither the menu nor the
|
|
54
|
+
// on-screen keyboard is open.
|
|
55
|
+
await page.keyboard.press("Backspace");
|
|
56
|
+
await expect(page).toHaveURL(/\/match-making$/);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// No keyboard equivalent of "a focused <select> doesn't trap Move" below -
|
|
60
|
+
// GlobalNavContext's isTyping guard (see useCursorInput.ts) hands off to
|
|
61
|
+
// native browser behaviour entirely while a <select> (or any form control)
|
|
62
|
+
// is focused, for a physical keyboard: arrow keys natively cycle its value
|
|
63
|
+
// without our code running at all, and Tab (never intercepted) always
|
|
64
|
+
// escapes it regardless. There's nothing for our own stepSelect/Move
|
|
65
|
+
// split to fix on this device - see gamepad-only.spec.ts, where a
|
|
66
|
+
// controller has no Tab-equivalent fallback and the same scenario was a
|
|
67
|
+
// real focus trap before that split existed.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["lib", "tests", "playwright.config.ts"],
|
|
14
|
+
"exclude": ["node_modules", "test-results", "playwright-report"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules/@playwright/test/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules/@playwright/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules/@playwright/test/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules/@playwright/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/@playwright+test@1.62.1/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../@playwright/test/cli.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../@playwright/test/cli.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/sam/Programming/games/match-lock/core/plugin-runtime/dist/node_modules:/home/sam/Programming/games/match-lock/core/plugin-runtime/node_modules:/home/sam/Programming/games/match-lock/core/node_modules:/home/sam/Programming/games/match-lock/node_modules:/home/sam/Programming/games/node_modules:/home/sam/Programming/node_modules:/home/sam/node_modules:/home/node_modules:/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/sam/Programming/games/match-lock/core/plugin-runtime/dist/node_modules:/home/sam/Programming/games/match-lock/core/plugin-runtime/node_modules:/home/sam/Programming/games/match-lock/core/node_modules:/home/sam/Programming/games/match-lock/node_modules:/home/sam/Programming/games/node_modules:/home/sam/Programming/node_modules:/home/sam/node_modules:/home/node_modules:/node_modules:/home/sam/Programming/games/match-lock/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../@roster-lock/plugin-runtime/dist/index.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../@roster-lock/plugin-runtime/dist/index.js" "$@"
|
|
17
|
+
fi
|