test(linkedin-studio): M0-3 — resolver twin-consistency test (R2)

This commit is contained in:
Kjell Tore Guttormsen 2026-06-18 11:12:50 +02:00
commit e5806b3890

View file

@ -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'));
});
});