MCPcopy
hub / github.com/Fission-AI/OpenSpec / createTestChange

Function createTestChange

test/commands/artifact-workflow.test.ts:45–75  ·  view source on GitHub ↗

* Creates a test change with the specified artifacts completed. * Note: An "active" change requires at least a proposal.md file to be detected. * If no artifacts are specified, we create an empty proposal to make it detectable.

(
    changeName: string,
    artifacts: ('proposal' | 'design' | 'specs' | 'tasks')[] = []
  )

Source from the content-addressed store, hash-verified

43 * If no artifacts are specified, we create an empty proposal to make it detectable.
44 */
45 async function createTestChange(
46 changeName: string,
47 artifacts: ('proposal' | 'design' | 'specs' | 'tasks')[] = []
48 ): Promise<string> {
49 const changeDir = path.join(changesDir, changeName);
50 await fs.mkdir(changeDir, { recursive: true });
51
52 // Always create proposal.md for the change to be detected as active
53 // Content varies based on whether 'proposal' is in artifacts list
54 const proposalContent = artifacts.includes('proposal')
55 ? '## Why\nTest proposal content that is long enough.\n\n## What Changes\n- **test:** Something'
56 : '## Why\nMinimal proposal.\n\n## What Changes\n- **test:** Placeholder';
57 await fs.writeFile(path.join(changeDir, 'proposal.md'), proposalContent);
58
59 if (artifacts.includes('design')) {
60 await fs.writeFile(path.join(changeDir, 'design.md'), '# Design\n\nTechnical design.');
61 }
62
63 if (artifacts.includes('specs')) {
64 // specs artifact uses glob pattern "specs/*.md" - files directly in specs/ directory
65 const specsDir = path.join(changeDir, 'specs');
66 await fs.mkdir(specsDir, { recursive: true });
67 await fs.writeFile(path.join(specsDir, 'test-spec.md'), '## Purpose\nTest spec.');
68 }
69
70 if (artifacts.includes('tasks')) {
71 await fs.writeFile(path.join(changeDir, 'tasks.md'), '## Tasks\n- [ ] Task 1');
72 }
73
74 return changeDir;
75 }
76
77 describe('status command', () => {
78 it('shows status for scaffolded change without proposal.md', async () => {

Callers 1

Calls 1

writeFileMethod · 0.80

Tested by

no test coverage detected