test(phase6): align behavioural harness with client wrappers
This commit is contained in:
@@ -2049,3 +2049,30 @@ Validation:
|
||||
Follow-ups:
|
||||
|
||||
- Optional next bounded slice: add a small shared test utility for service harness client mocks to reduce future per-file drift as façade migration continues.
|
||||
|
||||
---
|
||||
|
||||
### CL-058: TASK22260 next slice — phase6 behavioural harness compatibility parity
|
||||
|
||||
date: 2026-03-25
|
||||
author: Cline
|
||||
scope: `tests/phase6/service-behaviour.test.cjs`
|
||||
type: change
|
||||
rationale: Keep older phase6 behavioural harness aligned with service client-wrapper migration by adding default helper injections required by `getJson`/`requestJson`-based direct services.
|
||||
impact: Restores phase6 behavioural regression execution parity (8/8) with no runtime code changes.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Updated `loadServiceModule` default context in `tests/phase6/service-behaviour.test.cjs`:
|
||||
- added default `getJson(...)` mock backed by `axios.get(...).then(res.data)`
|
||||
- added default `requestJson(...)` mock backed by `axios(config).then(res.data)`
|
||||
- Preserved existing test assertions and behavior semantics; this is harness-compatibility only.
|
||||
|
||||
Validation:
|
||||
|
||||
- `node tests/phase6/service-behaviour.test.cjs` -> pass (8/8)
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Optional consolidation: extract shared phase6/phase7 VM loader helpers into a single test utility to reduce duplication.
|
||||
|
||||
@@ -72,6 +72,24 @@ const loadServiceModule = (fileName, injected = {}) => {
|
||||
source = source.replace(/export const\s+/g, "const ");
|
||||
source += `\nmodule.exports = { ${exportNames.join(", ")} };\n`;
|
||||
|
||||
const defaultGetJson = (url, config) => {
|
||||
if (!injected.axios || !injected.axios.get) {
|
||||
throw new Error("Missing axios.get for default getJson mock");
|
||||
}
|
||||
|
||||
return injected.axios
|
||||
.get(url, config)
|
||||
.then((response) => response.data);
|
||||
};
|
||||
|
||||
const defaultRequestJson = (config) => {
|
||||
if (!injected.axios) {
|
||||
throw new Error("Missing axios for default requestJson mock");
|
||||
}
|
||||
|
||||
return injected.axios(config).then((response) => response.data);
|
||||
};
|
||||
|
||||
const context = {
|
||||
module: { exports: {} },
|
||||
exports: {},
|
||||
@@ -85,6 +103,8 @@ const loadServiceModule = (fileName, injected = {}) => {
|
||||
warn: () => {},
|
||||
error: () => {}
|
||||
},
|
||||
getJson: injected.getJson || defaultGetJson,
|
||||
requestJson: injected.requestJson || defaultRequestJson,
|
||||
...injected
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user