(testResult)
| 317 | } |
| 318 | |
| 319 | completeCycle(testResult) { |
| 320 | if (this.disabled) return { ok: true, phase: 'idle', message: 'TDD gating disabled.' }; |
| 321 | if (this._phase !== PHASES.REFACTOR) { |
| 322 | return { ok: false, phase: this._phase, message: `completeCycle called but phase is "${this._phase}", expected "refactor".` }; |
| 323 | } |
| 324 | |
| 325 | const hasRegressions = testResult && (testResult.failed > 0 || testResult.errors > 0); |
| 326 | if (hasRegressions) { |
| 327 | const names = (testResult.failures || []).slice(0, 3).map(f => f.name).join(', '); |
| 328 | return { |
| 329 | ok: false, |
| 330 | phase: PHASES.REFACTOR, |
| 331 | message: `Regression: ${testResult.failed} failing test(s)${names ? ': ' + names : ''}. Fix before completing the cycle.`, |
| 332 | }; |
| 333 | } |
| 334 | |
| 335 | return this._finishCycle('refactor', testResult); |
| 336 | } |
| 337 | |
| 338 | skipRefactor() { |
| 339 | if (this.disabled) return { ok: true, phase: 'idle', message: 'TDD gating disabled.' }; |
no test coverage detected