test(harness): add fileClient default helper injections
This commit is contained in:
@@ -2312,3 +2312,37 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Optional next bounded slice: evaluate whether additional `documentDirectService` file-route call sites can adopt `fileClient` without altering current behavior contracts.
|
- 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.
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ const loadServiceModule = (fileName, injected = {}) => {
|
|||||||
return injected.axios(config).then((response) => response.data);
|
return injected.axios(config).then((response) => response.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const defaultGetFileJson = (url) => {
|
||||||
|
return defaultGetJson(url);
|
||||||
|
};
|
||||||
|
|
||||||
const defaultBuildHashedQueryUrl = async (queryUrl) => {
|
const defaultBuildHashedQueryUrl = async (queryUrl) => {
|
||||||
if (!injected.axios || !injected.axios.get) {
|
if (!injected.axios || !injected.axios.get) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -103,6 +107,25 @@ const loadServiceModule = (fileName, injected = {}) => {
|
|||||||
return queryUrl + hashResponse.data.hash;
|
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 = {
|
const context = {
|
||||||
module: { exports: {} },
|
module: { exports: {} },
|
||||||
exports: {},
|
exports: {},
|
||||||
@@ -118,6 +141,10 @@ const loadServiceModule = (fileName, injected = {}) => {
|
|||||||
},
|
},
|
||||||
getJson: injected.getJson || defaultGetJson,
|
getJson: injected.getJson || defaultGetJson,
|
||||||
requestJson: injected.requestJson || defaultRequestJson,
|
requestJson: injected.requestJson || defaultRequestJson,
|
||||||
|
getFileJson: injected.getFileJson || defaultGetFileJson,
|
||||||
|
getSignedFileJson:
|
||||||
|
injected.getSignedFileJson || defaultGetSignedFileJson,
|
||||||
|
downloadFileBlob: injected.downloadFileBlob || defaultDownloadFileBlob,
|
||||||
buildHashedQueryUrl:
|
buildHashedQueryUrl:
|
||||||
injected.buildHashedQueryUrl || defaultBuildHashedQueryUrl,
|
injected.buildHashedQueryUrl || defaultBuildHashedQueryUrl,
|
||||||
...injected
|
...injected
|
||||||
|
|||||||
Reference in New Issue
Block a user