chore(linkedin-studio): M0-13 — 4 D2 templates + scrub leak + scaffold fallback
This commit is contained in:
parent
29b139de11
commit
3797eaf6b1
7 changed files with 928 additions and 130 deletions
|
|
@ -83,3 +83,53 @@ describe('calculateScore — reads external instance data (M0-7)', () => {
|
|||
assert.equal(score, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateScore — scaffold categories read the external instance (M0-13)', () => {
|
||||
let dataDir, pluginRoot;
|
||||
const saved = { LINKEDIN_STUDIO_DATA: process.env.LINKEDIN_STUDIO_DATA };
|
||||
|
||||
afterEach(() => {
|
||||
for (const d of [dataDir, pluginRoot]) {
|
||||
if (d && existsSync(d)) rmSync(d, { recursive: true, force: true });
|
||||
}
|
||||
dataDir = pluginRoot = undefined;
|
||||
if (saved.LINKEDIN_STUDIO_DATA === undefined) delete process.env.LINKEDIN_STUDIO_DATA;
|
||||
else process.env.LINKEDIN_STUDIO_DATA = saved.LINKEDIN_STUDIO_DATA;
|
||||
});
|
||||
|
||||
test('a populated external high-engagement-posts instance earns the 10 points', () => {
|
||||
({ dataDir, pluginRoot } = makeRoots());
|
||||
process.env.LINKEDIN_STUDIO_DATA = dataDir;
|
||||
mkdirSync(join(dataDir, 'examples'), { recursive: true });
|
||||
const posts = ['## Post 1', '## Post 2', '## Post 3'].join('\n\n');
|
||||
writeFileSync(join(dataDir, 'examples', 'high-engagement-posts.md'), `# Posts\n\n${posts}\n`, 'utf-8');
|
||||
|
||||
const { score, personalized } = calculateScore(pluginRoot);
|
||||
|
||||
assert.equal(score, 10, '3+ saved posts in the external instance earn the 10 points');
|
||||
assert.equal(personalized, 1);
|
||||
});
|
||||
|
||||
test('the generic placeholder seed (no line-leading ## Post N) scores 0 — no crash', () => {
|
||||
({ dataDir, pluginRoot } = makeRoots());
|
||||
process.env.LINKEDIN_STUDIO_DATA = dataDir;
|
||||
mkdirSync(join(dataDir, 'examples'), { recursive: true });
|
||||
writeFileSync(join(dataDir, 'examples', 'high-engagement-posts.md'), `# Posts\n\nPlaceholder — add a ## Post N section per saved post.\n`, 'utf-8');
|
||||
|
||||
const { score, personalized } = calculateScore(pluginRoot);
|
||||
|
||||
assert.equal(score, 0, 'a placeholder with no ## Post [0-9] section scores 0');
|
||||
assert.equal(personalized, 0);
|
||||
});
|
||||
|
||||
test('scaffold absent at the external root → 0, no crash (graceful degradation)', () => {
|
||||
({ dataDir, pluginRoot } = makeRoots());
|
||||
process.env.LINKEDIN_STUDIO_DATA = dataDir;
|
||||
// examples/ dir never created — the category is simply skipped, never throws
|
||||
|
||||
const { score, personalized } = calculateScore(pluginRoot);
|
||||
|
||||
assert.equal(score, 0);
|
||||
assert.equal(personalized, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue