From 7d2f8a2c277de9fd6f841d1a5b8de70e6d57251f Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 25 Mar 2026 10:07:25 +0000 Subject: [PATCH] test(phase6): align behavioural harness with client wrappers --- memory-bank/change-log.md | 27 +++++++++++++++++++++++++ tests/phase6/service-behaviour.test.cjs | 20 ++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index cf8423d9..459ad0e1 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -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. diff --git a/tests/phase6/service-behaviour.test.cjs b/tests/phase6/service-behaviour.test.cjs index e130c93f..9f5e7e5a 100644 --- a/tests/phase6/service-behaviour.test.cjs +++ b/tests/phase6/service-behaviour.test.cjs @@ -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 };