Skip to content

Commit 85f01d7

Browse files
author
DavidQ
committed
PR_26140_038-canonical-shared-utility-naming-final-pass
1 parent c8c425b commit 85f01d7

10 files changed

Lines changed: 222 additions & 179 deletions
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# PR_26140_038 Canonical Shared Utility Naming Final Pass
2+
3+
## Scope
4+
- Used PR_26140_037 as the prior delta.
5+
- Removed remaining cosmetic aliases from repo-owned touched code.
6+
- Kept behavior unchanged; no gameplay, runtime, schema, manifest, vendor, generated, archive, report snapshot, or tests/results artifact changes were made.
7+
8+
## Changes
9+
- Replaced Playwright `workspaceV2CoverageReporter as coverageReporter` imports with direct `workspaceV2CoverageReporter` imports/usages in affected browser specs.
10+
- Replaced the `import * as fs from "node:fs/promises"` namespace import in `tests/core/BackgroundImageAndFullscreenBezel.test.mjs` with canonical named fs/promises imports.
11+
- Verified the prior cosmetic coverage reporter alias no longer appears in repo-owned Playwright specs.
12+
13+
## Remaining Intentional Aliases
14+
- `tests/run-tests.mjs`: `run as run...` aliases remain because every test module exports the same `run` function name and the aggregate runner needs distinct callable names.
15+
- `src/engine/**/index.js` and `tools/shared/**/index.js`: `export { default as ... }` remains for public barrel APIs that expose default class/module exports under stable named exports.
16+
- `src/shared/index.js`: `export * as shared...` namespace exports remain as intentional top-level shared-family barrels.
17+
- `tests/core/EngineCoreBoundaryBaseline.test.mjs` and `tests/runtime/Phase19OverlayExpansionFramework.test.mjs`: namespace imports remain because these tests validate module/barrel surfaces as namespaces.
18+
- `tests/shared/SharedNumberStringIdCloseout.test.mjs` and `tests/shared/SharedFoundationCombinedPass.test.mjs`: `legacy...` aliases remain to compare legacy compatibility modules against canonical utilities.
19+
- `games/Asteroids/utils/math.js`: `wrap as sharedWrap` remains because the Asteroids local `wrap(value, max)` adapter preserves an existing two-argument gameplay API over the shared three-argument helper.
20+
21+
## Validation
22+
- PASS: changed JavaScript/MJS files passed `node --check`.
23+
- INFO: `npm run build` is not defined in `package.json`.
24+
- PASS: `npm run build:manifest` completed; generated `docs/build/sample-manifest.json` was removed after validation.
25+
- PASS: `node tests\core\BackgroundImageAndFullscreenBezel.test.mjs`.
26+
- PASS: `node tests\games\AsteroidsValidation.test.mjs`.
27+
- PASS: `node tests\games\AsteroidsManifestScreenDimensions.test.mjs`.
28+
- PASS: `node tests\games\AsteroidsPresentation.test.mjs`.
29+
- PASS: `node tests\tools\ObjectVectorFinalRuntimeCleanup.test.mjs`.
30+
- PASS: `node tests\tools\ObjectVectorStudioV2DeleteCleanup.test.mjs`.
31+
- PASS: `npx playwright test tests/playwright/tools/AsteroidsGameSceneCleanup.spec.mjs --project=playwright --workers=1 --reporter=list`.
32+
- PASS: `npx playwright test tests/playwright/tools/ObjectVectorStudioV2FirstClassToolStarter.spec.mjs --project=playwright --workers=1 --reporter=list`.
33+
- PASS: `npx playwright test tests/playwright/tools/CollisionInspectorV2.spec.mjs --project=playwright --workers=1 --reporter=list`.
34+
- PASS: `npx playwright test tests/playwright/games/GameIndexPreviewManifestResolution.spec.mjs --project=playwright --workers=1 --reporter=list`.
35+
- PASS: `npm run test:workspace-v2` (58 passed).
36+
- PASS: `git diff --check` returned no whitespace errors; Git reported line-ending normalization warnings only.
37+
- PASS: `rg -n "workspaceV2CoverageReporter\s+as\s+coverageReporter|\bcoverageReporter\b" tests/playwright -g "*.mjs"` returned no matches.
38+
- PASS: repo-owned alias scan found only the intentional categories documented above:
39+
- `rg -n "^\s*import\b.*\bas\b|^\s*export\b.*\bas\b" games tools src tests -g "*.js" -g "*.mjs" -g "!**/node_modules/**" -g "!**/tests/results/**" -g "!docs/dev/reports/**" -g "!docs/archive/**" -g "!tools/Vector Map Editor/**" -g "!**/generated/**" -g "!**/vendor/**" -g "!**/*.min.js"`
40+
- PASS: changed-file guard found no modified node_modules, tests/results, docs/dev/reports snapshots, archived tools, generated bundles, vendor files, bundled files, or minified JS files.
41+
42+
## Notes
43+
- Full samples smoke test was not run; this PR is limited to canonical naming cleanup and the requested targeted validations passed.

tests/core/BackgroundImageAndFullscreenBezel.test.mjs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from "node:assert/strict";
22
import os from "node:os";
33
import path from "node:path";
4-
import * as fs from "node:fs/promises";
4+
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
55
import Engine from "../../src/engine/core/Engine.js";
66
import backgroundImage from "../../src/engine/runtime/backgroundImage.js";
77
import fullscreenBezel, {
@@ -747,38 +747,38 @@ function testMalformedAndExtremeStretchConfigValuesAreSafe() {
747747
}
748748

749749
async function testBezelStretchConfigAutoCreate() {
750-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "bezel-stretch-config-"));
750+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "bezel-stretch-config-"));
751751
const configPath = "games/TestGame/assets/images/bezel.stretch.override.json";
752752

753753
try {
754754
const config = await ensureBezelStretchConfigFile(configPath, {
755755
cwd: tempRoot,
756-
fsModule: fs,
756+
fsModule: { mkdir, readFile, writeFile },
757757
pathModule: path
758758
});
759759
assert.deepEqual(config, { uniformEdgeStretchPx: 0 });
760760

761761
const absolutePath = path.resolve(tempRoot, configPath);
762-
const saved = JSON.parse(await fs.readFile(absolutePath, "utf8"));
762+
const saved = JSON.parse(await readFile(absolutePath, "utf8"));
763763
assert.deepEqual(saved, { uniformEdgeStretchPx: 0 });
764764

765765
const existingContent = { uniformEdgeStretchPx: 12 };
766-
await fs.writeFile(absolutePath, `${JSON.stringify(existingContent, null, 2)}\n`, "utf8");
766+
await writeFile(absolutePath, `${JSON.stringify(existingContent, null, 2)}\n`, "utf8");
767767
const loadedExisting = await ensureBezelStretchConfigFile(configPath, {
768768
cwd: tempRoot,
769-
fsModule: fs,
769+
fsModule: { mkdir, readFile, writeFile },
770770
pathModule: path
771771
});
772-
const savedAfterReload = JSON.parse(await fs.readFile(absolutePath, "utf8"));
772+
const savedAfterReload = JSON.parse(await readFile(absolutePath, "utf8"));
773773
assert.deepEqual(loadedExisting, existingContent);
774774
assert.deepEqual(savedAfterReload, existingContent);
775775
} finally {
776-
await fs.rm(tempRoot, { recursive: true, force: true });
776+
await rm(tempRoot, { recursive: true, force: true });
777777
}
778778
}
779779

780780
async function testBezelDetectionTriggersStretchConfigAutoCreate() {
781-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "bezel-detected-config-"));
781+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "bezel-detected-config-"));
782782
const documentRef = createDocumentStub("/games/_template/index.html");
783783
const host = createElement("div", documentRef);
784784
const canvas = createElement("canvas", documentRef);
@@ -796,7 +796,7 @@ async function testBezelDetectionTriggersStretchConfigAutoCreate() {
796796
providerCalls += 1;
797797
return ensureBezelStretchConfigFile(configPath, {
798798
cwd: tempRoot,
799-
fsModule: fs,
799+
fsModule: { mkdir, readFile, writeFile },
800800
pathModule: path
801801
});
802802
}
@@ -814,17 +814,17 @@ async function testBezelDetectionTriggersStretchConfigAutoCreate() {
814814
}
815815

816816
const createdPath = path.resolve(tempRoot, "games/_template/assets/images/bezel.stretch.override.json");
817-
const saved = JSON.parse(await fs.readFile(createdPath, "utf8"));
817+
const saved = JSON.parse(await readFile(createdPath, "utf8"));
818818
assert.deepEqual(saved, { uniformEdgeStretchPx: 0 });
819819
assert.equal(bezel.getState().stretchConfigPath, "games/_template/assets/images/bezel.stretch.override.json");
820820
assert.equal(bezel.getState().stretchConfigInitialized, true);
821821
} finally {
822-
await fs.rm(tempRoot, { recursive: true, force: true });
822+
await rm(tempRoot, { recursive: true, force: true });
823823
}
824824
}
825825

826826
async function testBezelDetectionDoesNotOverwriteExistingStretchConfig() {
827-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "bezel-detected-existing-config-"));
827+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "bezel-detected-existing-config-"));
828828
const documentRef = createDocumentStub("/games/_template/index.html");
829829
const host = createElement("div", documentRef);
830830
const canvas = createElement("canvas", documentRef);
@@ -836,16 +836,16 @@ async function testBezelDetectionDoesNotOverwriteExistingStretchConfig() {
836836
try {
837837
const expectedConfig = { uniformEdgeStretchPx: 14 };
838838
const configPath = path.resolve(tempRoot, "games/_template/assets/images/bezel.stretch.override.json");
839-
await fs.mkdir(path.dirname(configPath), { recursive: true });
840-
await fs.writeFile(configPath, `${JSON.stringify(expectedConfig, null, 2)}\n`, "utf8");
839+
await mkdir(path.dirname(configPath), { recursive: true });
840+
await writeFile(configPath, `${JSON.stringify(expectedConfig, null, 2)}\n`, "utf8");
841841

842842
const bezel = new fullscreenBezel({
843843
canvas,
844844
documentRef,
845845
stretchConfigProvider(runtimeConfigPath) {
846846
return ensureBezelStretchConfigFile(runtimeConfigPath, {
847847
cwd: tempRoot,
848-
fsModule: fs,
848+
fsModule: { mkdir, readFile, writeFile },
849849
pathModule: path
850850
});
851851
}
@@ -858,37 +858,37 @@ async function testBezelDetectionDoesNotOverwriteExistingStretchConfig() {
858858
await bezel.stretchConfigPromise;
859859
}
860860

861-
const savedAfterStartup = JSON.parse(await fs.readFile(configPath, "utf8"));
861+
const savedAfterStartup = JSON.parse(await readFile(configPath, "utf8"));
862862
assert.deepEqual(savedAfterStartup, expectedConfig);
863863
assert.equal(bezel.getState().uniformEdgeStretchPx, expectedConfig.uniformEdgeStretchPx);
864864
} finally {
865-
await fs.rm(tempRoot, { recursive: true, force: true });
865+
await rm(tempRoot, { recursive: true, force: true });
866866
}
867867
}
868868

869869
async function testMalformedStretchConfigFileFallsBackWithoutOverwrite() {
870-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "bezel-malformed-config-"));
870+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "bezel-malformed-config-"));
871871
const configPath = path.resolve(tempRoot, "games/TestGame/assets/images/bezel.stretch.override.json");
872872
try {
873-
await fs.mkdir(path.dirname(configPath), { recursive: true });
873+
await mkdir(path.dirname(configPath), { recursive: true });
874874
const malformedContent = "{not-valid-json";
875-
await fs.writeFile(configPath, malformedContent, "utf8");
875+
await writeFile(configPath, malformedContent, "utf8");
876876

877877
const loaded = await ensureBezelStretchConfigFile("games/TestGame/assets/images/bezel.stretch.override.json", {
878878
cwd: tempRoot,
879-
fsModule: fs,
879+
fsModule: { mkdir, readFile, writeFile },
880880
pathModule: path
881881
});
882-
const savedAfterLoad = await fs.readFile(configPath, "utf8");
882+
const savedAfterLoad = await readFile(configPath, "utf8");
883883
assert.deepEqual(loaded, { uniformEdgeStretchPx: 0 });
884884
assert.equal(savedAfterLoad, malformedContent);
885885
} finally {
886-
await fs.rm(tempRoot, { recursive: true, force: true });
886+
await rm(tempRoot, { recursive: true, force: true });
887887
}
888888
}
889889

890890
async function testSampleGameBezelDetectionCreatesStretchConfig() {
891-
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "bezel-detected-spaceinvaders-config-"));
891+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "bezel-detected-spaceinvaders-config-"));
892892
const documentRef = createDocumentStub("/games/SpaceInvaders/index.html");
893893
const host = createElement("div", documentRef);
894894
const canvas = createElement("canvas", documentRef);
@@ -904,7 +904,7 @@ async function testSampleGameBezelDetectionCreatesStretchConfig() {
904904
stretchConfigProvider(configPath) {
905905
return ensureBezelStretchConfigFile(configPath, {
906906
cwd: tempRoot,
907-
fsModule: fs,
907+
fsModule: { mkdir, readFile, writeFile },
908908
pathModule: path
909909
});
910910
}
@@ -919,11 +919,11 @@ async function testSampleGameBezelDetectionCreatesStretchConfig() {
919919
}
920920

921921
const createdPath = path.resolve(tempRoot, "games/SpaceInvaders/assets/images/bezel.stretch.override.json");
922-
const saved = JSON.parse(await fs.readFile(createdPath, "utf8"));
922+
const saved = JSON.parse(await readFile(createdPath, "utf8"));
923923
assert.deepEqual(saved, { uniformEdgeStretchPx: 0 });
924924
assert.equal(bezel.getState().stretchConfigPath, "games/SpaceInvaders/assets/images/bezel.stretch.override.json");
925925
} finally {
926-
await fs.rm(tempRoot, { recursive: true, force: true });
926+
await rm(tempRoot, { recursive: true, force: true });
927927
}
928928
}
929929

tests/playwright/games/GameIndexPreviewManifestResolution.spec.mjs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { expect, test } from "@playwright/test";
22
import path from "node:path";
33
import { readdir, readFile } from "node:fs/promises";
44
import { startRepoServer } from "../../helpers/playwrightRepoServer.mjs";
5-
import { workspaceV2CoverageReporter as coverageReporter } from "../../helpers/workspaceV2CoverageReporter.mjs";
5+
import { workspaceV2CoverageReporter } from "../../helpers/workspaceV2CoverageReporter.mjs";
66

77
const GAMES_DIR = "games";
88
const PONG_MANIFEST_PATH = "games/Pong/game.manifest.json";
99
const PONG_PREVIEW_PATH = "/games/Pong/assets/images/preview1.svg";
1010
const PONG_OLD_PREVIEW_PATH = "/games/Pong/assets/images/preview.svg";
1111

1212
test.afterAll(async () => {
13-
await coverageReporter.writeReport();
13+
await workspaceV2CoverageReporter.writeReport();
1414
});
1515

1616
async function readPongManifest() {
@@ -110,7 +110,7 @@ test("games index resolves every game thumbnail from manifest preview roles", as
110110
}
111111
});
112112

113-
await coverageReporter.start(page);
113+
await workspaceV2CoverageReporter.start(page);
114114
try {
115115
await page.goto(`${server.baseUrl}/games/index.html`, { waitUntil: "networkidle" });
116116
for (const [gameId, previewPath] of previewPaths) {
@@ -124,7 +124,7 @@ test("games index resolves every game thumbnail from manifest preview roles", as
124124
expect(imageNotFoundResponses).toEqual([]);
125125
expect(pageErrors).toEqual([]);
126126
} finally {
127-
await coverageReporter.stop(page);
127+
await workspaceV2CoverageReporter.stop(page);
128128
await server.close();
129129
}
130130
});
@@ -137,7 +137,7 @@ test("games index resolves Pong thumbnail from manifest preview role", async ({
137137
pageErrors.push(error.message);
138138
});
139139

140-
await coverageReporter.start(page);
140+
await workspaceV2CoverageReporter.start(page);
141141
try {
142142
await page.goto(`${server.baseUrl}/games/index.html`, { waitUntil: "networkidle" });
143143
const pongCard = page.locator('[data-game-id="Pong"]').first();
@@ -150,7 +150,7 @@ test("games index resolves Pong thumbnail from manifest preview role", async ({
150150
expect(requests.imageNotFoundResponses).not.toContain(PONG_OLD_PREVIEW_PATH);
151151
expect(pageErrors).toEqual([]);
152152
} finally {
153-
await coverageReporter.stop(page);
153+
await workspaceV2CoverageReporter.stop(page);
154154
await server.close();
155155
}
156156
});
@@ -163,7 +163,7 @@ test("Pong page resolves thumbnail from manifest preview role", async ({ page })
163163
pageErrors.push(error.message);
164164
});
165165

166-
await coverageReporter.start(page);
166+
await workspaceV2CoverageReporter.start(page);
167167
try {
168168
await page.goto(`${server.baseUrl}/games/Pong/index.html`, { waitUntil: "networkidle" });
169169
const previewImage = page.locator("#pong-preview-thumbnail");
@@ -175,7 +175,7 @@ test("Pong page resolves thumbnail from manifest preview role", async ({ page })
175175
expect(requests.imageNotFoundResponses).not.toContain(PONG_OLD_PREVIEW_PATH);
176176
expect(pageErrors).toEqual([]);
177177
} finally {
178-
await coverageReporter.stop(page);
178+
await workspaceV2CoverageReporter.stop(page);
179179
await server.close();
180180
}
181181
});
@@ -196,7 +196,7 @@ test("Pong page keeps safe placeholder when preview role is absent", async ({ pa
196196
});
197197
});
198198

199-
await coverageReporter.start(page);
199+
await workspaceV2CoverageReporter.start(page);
200200
try {
201201
await page.goto(`${server.baseUrl}/games/Pong/index.html`, { waitUntil: "networkidle" });
202202
await expect(page.locator("#pong-preview-placeholder")).toBeVisible();
@@ -208,7 +208,7 @@ test("Pong page keeps safe placeholder when preview role is absent", async ({ pa
208208
expect(requests.imageNotFoundResponses).not.toContain(PONG_OLD_PREVIEW_PATH);
209209
expect(pageErrors).toEqual([]);
210210
} finally {
211-
await coverageReporter.stop(page);
211+
await workspaceV2CoverageReporter.stop(page);
212212
await server.close();
213213
}
214214
});

0 commit comments

Comments
 (0)