From decf15b5dad690d1869e5096859207d9679deb92 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Sun, 15 Feb 2026 11:27:49 -0500 Subject: [PATCH] Add more tests for Coderabbit --- test/test-codex-transform.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/test-codex-transform.js b/test/test-codex-transform.js index b372bf084..203a790d0 100644 --- a/test/test-codex-transform.js +++ b/test/test-codex-transform.js @@ -94,6 +94,25 @@ console.log(`\n${colors.cyan}CodexSetup.transformToSkillFormat tests${colors.res assert(parsed.name === 'my-custom-skill', 'name field matches skillName argument', `got name: ${JSON.stringify(parsed.name)}`); } +// --- Extra frontmatter keys are stripped --- +{ + const input = `---\ndescription: foo\ndisable-model-invocation: true\ncustom-field: bar\n---\n\nBody.`; + const result = setup.transformToSkillFormat(input, 'strip-extra'); + const desc = parseOutputDescription(result); + assert(desc === 'foo', 'description preserved when extra keys present', `got description: ${JSON.stringify(desc)}`); + const match = result.match(/^---\n([\s\S]*?)\n---/); + const parsed = yaml.parse(match[1]); + assert(parsed.name === 'strip-extra', 'name equals skillName after stripping extras', `got name: ${JSON.stringify(parsed.name)}`); + assert(!('disable-model-invocation' in parsed), 'disable-model-invocation stripped', `keys: ${Object.keys(parsed).join(', ')}`); + assert(!('custom-field' in parsed), 'custom-field stripped', `keys: ${Object.keys(parsed).join(', ')}`); + const keys = Object.keys(parsed).sort(); + assert( + keys.length === 2 && keys[0] === 'description' && keys[1] === 'name', + 'only name and description remain', + `keys: ${keys.join(', ')}`, + ); +} + // --- No frontmatter wraps content --- { const input = 'Just some content without frontmatter.'; @@ -103,6 +122,15 @@ console.log(`\n${colors.cyan}CodexSetup.transformToSkillFormat tests${colors.res assert(result.includes('Just some content without frontmatter.'), 'body preserved when no frontmatter'); } +// --- No frontmatter with single-quote in skillName --- +{ + const input = 'Body content for the skill.'; + const result = setup.transformToSkillFormat(input, "it's-a-task"); + const desc = parseOutputDescription(result); + assert(desc === "it's-a-task", 'no-frontmatter skillName with single quote round-trips', `got description: ${JSON.stringify(desc)}`); + assert(result.includes('Body content for the skill.'), 'body preserved for single-quote skillName'); +} + // --- CRLF frontmatter is parsed correctly (Windows line endings) --- { const input = '---\r\ndescription: windows line endings\r\n---\r\n\r\nBody.';