()
| 103 | |
| 104 | // Run tests |
| 105 | function runTests() { |
| 106 | let allPassed = true; |
| 107 | |
| 108 | try { |
| 109 | // Test 1: Changeset without codemod |
| 110 | console.log("\n=== Test 1: Changeset without codemod ==="); |
| 111 | createChangeset("patch-fix.md", "patch", "Fixed a bug in the rendering logic"); |
| 112 | let output = runChangesetVersion(); |
| 113 | |
| 114 | allPassed &= assertContains(output, "Fixed a bug in the rendering logic", "Should include description in changes list"); |
| 115 | allPassed &= assertContains(output, "Would add to CHANGELOG.md", "Should show changelog preview"); |
| 116 | allPassed &= assertNotContains(output, "Consolidated Codemod Instructions", "Should not show codemod section when none exist"); |
| 117 | |
| 118 | // Clean up for next test |
| 119 | fs.unlinkSync(path.join(CHANGESET_DIR, "patch-fix.md")); |
| 120 | |
| 121 | // Test 2: Single changeset with codemod |
| 122 | console.log("\n=== Test 2: Single changeset with codemod ==="); |
| 123 | createChangeset( |
| 124 | "minor-breaking.md", |
| 125 | "minor", |
| 126 | "Changed the workflow frontmatter field `engine` to require an object instead of a string.", |
| 127 | "If you have workflows using `engine: copilot`, update to:\n\n```yaml\nengine:\n id: copilot\n```" |
| 128 | ); |
| 129 | output = runChangesetVersion(); |
| 130 | |
| 131 | allPassed &= assertContains(output, "Consolidated Codemod Instructions", "Should show codemod section"); |
| 132 | allPassed &= assertContains(output, "The following breaking changes require code updates", "Should include codemod header"); |
| 133 | allPassed &= assertContains(output, "engine:\n id: copilot", "Should include codemod content"); |
| 134 | allPassed &= assertContains(output, "### Changed the workflow frontmatter field", "Should include description as heading in codemod"); |
| 135 | |
| 136 | // Verify codemod is NOT in raw form in the changelog section, but IS in the Migration Guide |
| 137 | const changelogSection = output.substring(output.indexOf("Would add to CHANGELOG.md"), output.indexOf("Consolidated Codemod")); |
| 138 | allPassed &= assertNotContains(changelogSection, "## Codemod", 'Changelog should not contain "## Codemod" heading'); |
| 139 | allPassed &= assertContains(changelogSection, "### Migration Guide", "Changelog should contain Migration Guide section"); |
| 140 | allPassed &= assertContains(changelogSection, "`````markdown", "Changelog should contain markdown code block with 5 backticks for codemods"); |
| 141 | |
| 142 | // Clean up for next test |
| 143 | fs.unlinkSync(path.join(CHANGESET_DIR, "minor-breaking.md")); |
| 144 | |
| 145 | // Test 3: Multiple changesets with codemods |
| 146 | console.log("\n=== Test 3: Multiple changesets with codemods ==="); |
| 147 | createChangeset("minor-engine.md", "minor", "Changed engine configuration format", "Update `engine: copilot` to `engine: { id: copilot }`"); |
| 148 | createChangeset("minor-tools.md", "minor", "Changed tools configuration format", "Update `tools: github` to `tools: [github]`"); |
| 149 | output = runChangesetVersion(); |
| 150 | |
| 151 | allPassed &= assertContains(output, "Consolidated Codemod Instructions", "Should show consolidated codemod section"); |
| 152 | allPassed &= assertContains(output, "Changed engine configuration format", "Should include first codemod"); |
| 153 | allPassed &= assertContains(output, "Changed tools configuration format", "Should include second codemod"); |
| 154 | allPassed &= assertContains(output, "Update `engine: copilot`", "Should include first codemod content"); |
| 155 | allPassed &= assertContains(output, "Update `tools: github`", "Should include second codemod content"); |
| 156 | |
| 157 | // Clean up for next test |
| 158 | fs.unlinkSync(path.join(CHANGESET_DIR, "minor-engine.md")); |
| 159 | fs.unlinkSync(path.join(CHANGESET_DIR, "minor-tools.md")); |
| 160 | |
| 161 | // Test 4: Mixed changesets (with and without codemods) |
| 162 | console.log("\n=== Test 4: Mixed changesets with and without codemods ==="); |
no test coverage detected