|
| 1 | +import { test } from 'node:test'; |
| 2 | +import assert from 'node:assert/strict'; |
| 3 | +import { outputIndicatesFlowFailure } from '../../dist/domain/maestro-error-parser.js'; |
| 4 | + |
| 5 | +// GH#249/B193: the exit-0 secondary guard was `output.includes('FAILED')` over combined |
| 6 | +// stdout+stderr — which contains app/console logs, so a passing flow whose app merely |
| 7 | +// logged the substring (FETCH_FAILED, LOGIN_FAILED, ...) was flagged failed and kicked |
| 8 | +// off pointless auto-repair. The guard must key on Maestro's own terminal status LINES. |
| 9 | +// (maestro-runner emits no uppercase FAILED at all — verified against the binary — so |
| 10 | +// the token only ever comes from the JVM Maestro fallback, e.g. the 'Test FAILED' line |
| 11 | +// already pinned in maestro-error-parser.test.js.) |
| 12 | + |
| 13 | +test('#249 matches Maestro terminal status lines', () => { |
| 14 | + assert.equal(outputIndicatesFlowFailure('Test FAILED'), true); |
| 15 | + assert.equal(outputIndicatesFlowFailure('[INFO] Tapping on "ok"\nTest FAILED\n'), true); |
| 16 | + assert.equal(outputIndicatesFlowFailure('Flow FAILED'), true); |
| 17 | + assert.equal(outputIndicatesFlowFailure('[FAILED] Tap on element with id "submit"'), true); |
| 18 | + assert.equal(outputIndicatesFlowFailure(' FAILED '), true); // bare status line, indented |
| 19 | +}); |
| 20 | + |
| 21 | +test('#249 does NOT match app/console log content that merely contains the substring', () => { |
| 22 | + assert.equal(outputIndicatesFlowFailure('[INFO] dispatching action FETCH_FAILED'), false); |
| 23 | + assert.equal(outputIndicatesFlowFailure('console.log: USER_REGISTRATION_FAILED event sent'), false); |
| 24 | + assert.equal(outputIndicatesFlowFailure('2026-06-10 12:00:01 upload FAILED midway, retrying'), false); |
| 25 | + assert.equal(outputIndicatesFlowFailure('FAILED to fetch user profile'), false); // line-leading but prose, not a status line |
| 26 | + assert.equal(outputIndicatesFlowFailure('All steps passed'), false); |
| 27 | + assert.equal(outputIndicatesFlowFailure(''), false); |
| 28 | +}); |
0 commit comments