Files
get-shit-done/tests/windsurf-conversion.test.cjs
Tom Boucher 2703422be8 refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md (#1675)
* refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md

- Replace require('node:assert') with require('node:assert/strict') across
  all 73 test files to enforce strict equality (no type coercion)
- Replace try/finally cleanup blocks with t.after() hooks in core.test.cjs
  and hooks-opt-in.test.cjs per the test lifecycle standards
- Utility functions in codex-config and security-scan retain try/finally
  as that is appropriate for per-function resource guards, not lifecycle hooks

Closes #1674

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* perf(tests): add --test-concurrency=4 to test runner for parallel file execution

Node.js --test-concurrency controls how many test files run as parallel child
processes. Set to 4 by default, configurable via TEST_CONCURRENCY env var.
Fixes tests at a known level rather than inheriting os.availableParallelism()
which varies across CI environments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(security): allowlist verify.test.cjs in prompt-injection scanner

tests/verify.test.cjs uses <human>...</human> as GSD phase task-type
XML (meaning "a human should verify this step"), which matches the
scanner's fake-message-boundary pattern for LLM APIs. This is a
false positive — add it to the allowlist alongside the other test files
that legitimately contain injection-adjacent patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 14:29:03 -04:00

140 lines
4.8 KiB
JavaScript

/**
* Windsurf conversion regression tests.
*
* Ensures Windsurf frontmatter names are emitted as plain identifiers
* (without surrounding quotes), so Windsurf does not treat quotes as
* literal parts of skill/subagent names.
*/
process.env.GSD_TEST_MODE = '1';
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const {
convertClaudeCommandToWindsurfSkill,
convertClaudeAgentToWindsurfAgent,
convertClaudeToWindsurfMarkdown,
} = require('../bin/install.js');
describe('convertClaudeCommandToWindsurfSkill', () => {
test('writes unquoted Windsurf skill name in frontmatter', () => {
const input = `---
name: quick
description: Execute a quick task
---
<objective>
Test body
</objective>
`;
const result = convertClaudeCommandToWindsurfSkill(input, 'gsd-quick');
const nameMatch = result.match(/^name:\s*(.+)$/m);
assert.ok(nameMatch, 'frontmatter contains name field');
assert.strictEqual(nameMatch[1], 'gsd-quick', 'skill name is plain scalar');
assert.ok(!result.includes('name: "gsd-quick"'), 'quoted skill name is not emitted');
});
test('preserves slash for slash commands in markdown body', () => {
const input = `---
name: gsd:plan-phase
description: Plan a phase
---
Next:
/gsd:execute-phase 17
/gsd-help
gsd:progress
`;
const result = convertClaudeCommandToWindsurfSkill(input, 'gsd-plan-phase');
// Slash commands: /gsd:execute-phase -> /gsd-execute-phase
assert.ok(result.includes('/gsd-execute-phase 17'), 'slash command gsd: -> gsd-');
assert.ok(result.includes('/gsd-help'), '/gsd-help preserved');
assert.ok(result.includes('gsd-progress'), 'bare gsd: -> gsd-');
});
test('includes windsurf_skill_adapter block', () => {
const input = `---
name: test
description: A test skill
---
Body content.
`;
const result = convertClaudeCommandToWindsurfSkill(input, 'gsd-test');
assert.ok(result.includes('<windsurf_skill_adapter>'), 'adapter header present');
assert.ok(result.includes('</windsurf_skill_adapter>'), 'adapter footer present');
assert.ok(result.includes('Shell'), 'Shell tool mentioned');
assert.ok(result.includes('StrReplace'), 'StrReplace tool mentioned');
});
});
describe('convertClaudeAgentToWindsurfAgent', () => {
test('converts agent frontmatter with unquoted name', () => {
const input = `---
name: gsd-bugfix
description: "Fix bugs automatically"
color: blue
skills:
- debug
- test
---
Agent body content.
`;
const result = convertClaudeAgentToWindsurfAgent(input);
const nameMatch = result.match(/^name:\s*(.+)$/m);
assert.ok(nameMatch, 'name field present');
assert.strictEqual(nameMatch[1], 'gsd-bugfix', 'agent name is plain scalar');
// Should strip unsupported fields
assert.ok(!result.includes('color:'), 'color field stripped');
assert.ok(!result.includes('skills:'), 'skills field stripped');
});
});
describe('convertClaudeToWindsurfMarkdown', () => {
test('replaces Claude Code brand with Windsurf', () => {
const input = 'Claude Code is a great tool for development.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('Windsurf'), 'brand replaced');
assert.ok(!result.includes('Claude Code'), 'original brand removed');
});
test('replaces CLAUDE.md with .windsurf/rules (no trailing slash)', () => {
const input = 'See `CLAUDE.md` for configuration. Also check ./CLAUDE.md file.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('.windsurf/rules'), 'CLAUDE.md replaced');
assert.ok(!result.includes('.windsurf/rules/'), 'no trailing slash (Node v25 compat)');
});
test('replaces .claude/skills/ with .windsurf/skills/', () => {
const input = 'Skills are stored in .claude/skills/ directory.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('.windsurf/skills/'), 'skills path replaced');
});
test('replaces Bash( with Shell( and Edit( with StrReplace(', () => {
const input = 'Use Bash(command) and Edit(file) tools.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('Shell('), 'Bash -> Shell');
assert.ok(result.includes('StrReplace('), 'Edit -> StrReplace');
});
test('replaces $ARGUMENTS with {{GSD_ARGS}}', () => {
const input = 'Pass $ARGUMENTS to the command.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(result.includes('{{GSD_ARGS}}'), '$ARGUMENTS replaced');
});
test('removes classifyHandoffIfNeeded workarounds', () => {
const input = '**Known Claude Code bug (classifyHandoffIfNeeded):** Some workaround text here\nNext line.';
const result = convertClaudeToWindsurfMarkdown(input);
assert.ok(!result.includes('classifyHandoffIfNeeded'), 'workaround removed');
});
});