From e5806b389042985d58312617727fad478897a37f Mon Sep 17 00:00:00 2001 From: Kjell Tore Guttormsen Date: Thu, 18 Jun 2026 11:12:50 +0200 Subject: [PATCH] =?UTF-8?q?test(linkedin-studio):=20M0-3=20=E2=80=94=20res?= =?UTF-8?q?olver=20twin-consistency=20test=20(R2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/scripts/__tests__/data-root.test.mjs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hooks/scripts/__tests__/data-root.test.mjs b/hooks/scripts/__tests__/data-root.test.mjs index d69063b..bf4b8a8 100644 --- a/hooks/scripts/__tests__/data-root.test.mjs +++ b/hooks/scripts/__tests__/data-root.test.mjs @@ -78,3 +78,43 @@ describe('data-root resolver', () => { }); }); }); + +// Twin consistency with scripts/analytics/src/utils/storage.ts:getDataRoot. +// The TS twin cannot be imported into this no-tsx .mjs run, so we assert this +// .mjs resolver against the SAME contract literals that storage-root.test.ts +// asserts for the TS twin (the behavioral-consistency model — a header-only +// "bit-identical" claim is not a test). Change one twin → update this block and +// its TS mirror in lockstep. R2's mitigation. +describe('twin consistency (storage.ts:getDataRoot)', () => { + const saved = { + HOME: process.env.HOME, + USERPROFILE: process.env.USERPROFILE, + LINKEDIN_STUDIO_DATA: process.env.LINKEDIN_STUDIO_DATA, + }; + + afterEach(() => { + for (const [k, v] of Object.entries(saved)) { + if (v === undefined) delete process.env[k]; + else process.env[k] = v; + } + }); + + // These literals are the shared contract — storage-root.test.ts asserts the + // identical strings for the TS twin; keep them character-for-character in sync. + test('default matches the TS twin contract literal (HOME-stubbed)', () => { + process.env.HOME = '/home/tester'; + delete process.env.USERPROFILE; + delete process.env.LINKEDIN_STUDIO_DATA; + + assert.equal( + getDataRoot('analytics'), + join('/home/tester', '.claude', 'linkedin-studio', 'analytics'), + ); + }); + + test('LINKEDIN_STUDIO_DATA override matches the TS twin contract literal', () => { + process.env.LINKEDIN_STUDIO_DATA = '/tmp/lis-data'; + + assert.equal(getDataRoot('analytics'), join('/tmp/lis-data', 'analytics')); + }); +});