diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index daa41e76..66e0c7fe 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -2312,3 +2312,37 @@ Validation: Follow-ups: - Optional next bounded slice: evaluate whether additional `documentDirectService` file-route call sites can adopt `fileClient` without altering current behavior contracts. + +--- + +### CL-066: TASK22260 next slice — service harness parity for fileClient helper injections + +date: 2026-03-25 +author: Cline +scope: `tests/serviceHarness.cjs` +type: change +rationale: Follow the previous `fileClient` extraction with a bounded harness-compatibility slice so legacy VM-based service behavioural suites continue to execute without requiring per-test manual injections. +impact: Restores migration-era behavioural regression stability (phase7) by aligning shared harness defaults with newly introduced file client helper symbols. +status: completed + +Summary: + +- Updated shared test harness defaults in `tests/serviceHarness.cjs` to inject file-client compatible helpers when not explicitly provided: + - `getFileJson` (delegates to default `getJson`) + - `getSignedFileJson` (signs via `buildHashedQueryUrl` then calls `requestJson` with GET config) + - `downloadFileBlob` (calls `requestJson` with GET + `responseType: "blob"`) +- This preserves existing VM import-stripping strategy while preventing `ReferenceError` in migrated services that import from `../clients/fileClient`. + +Validation: + +- `node tests/phase7/service-behaviour.test.cjs` -> pass (12/12) +- `node tests/phase22/index.test.cjs` -> pass + - core-token: 2/2 + - client-utils: 5/5 + - file-client: 3/3 + - phase22 combined: pass +- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors) + +Follow-ups: + +- Optional next bounded slice: add a focused phase6/phase7 behavioural assertion for `documentDirectService.downloadBlob` to explicitly lock the `downloadFileBlob` delegation contract. diff --git a/tests/serviceHarness.cjs b/tests/serviceHarness.cjs index 2ee7b943..cdb7b43d 100644 --- a/tests/serviceHarness.cjs +++ b/tests/serviceHarness.cjs @@ -89,6 +89,10 @@ const loadServiceModule = (fileName, injected = {}) => { return injected.axios(config).then((response) => response.data); }; + const defaultGetFileJson = (url) => { + return defaultGetJson(url); + }; + const defaultBuildHashedQueryUrl = async (queryUrl) => { if (!injected.axios || !injected.axios.get) { throw new Error( @@ -103,6 +107,25 @@ const loadServiceModule = (fileName, injected = {}) => { return queryUrl + hashResponse.data.hash; }; + const defaultGetSignedFileJson = async (queryUrl) => { + const hashedUrl = await ( + injected.buildHashedQueryUrl || defaultBuildHashedQueryUrl + )(queryUrl); + + return (injected.requestJson || defaultRequestJson)({ + method: "get", + url: hashedUrl + }); + }; + + const defaultDownloadFileBlob = (url) => { + return (injected.requestJson || defaultRequestJson)({ + method: "get", + url, + responseType: "blob" + }); + }; + const context = { module: { exports: {} }, exports: {}, @@ -118,6 +141,10 @@ const loadServiceModule = (fileName, injected = {}) => { }, getJson: injected.getJson || defaultGetJson, requestJson: injected.requestJson || defaultRequestJson, + getFileJson: injected.getFileJson || defaultGetFileJson, + getSignedFileJson: + injected.getSignedFileJson || defaultGetSignedFileJson, + downloadFileBlob: injected.downloadFileBlob || defaultDownloadFileBlob, buildHashedQueryUrl: injected.buildHashedQueryUrl || defaultBuildHashedQueryUrl, ...injected