From 0a8ca104e0f98484d1ebbbd3e378a08d34f076ed Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Fri, 24 Jul 2026 19:04:48 +0700 Subject: [PATCH] test(e2e): cover the flag-outranks-sequence rule in the cassette matcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deleting `eligible`'s second line — the one that makes a newly-enabled flagged entry outrank the unflagged candidates — left the whole unit tier green. The existing cases use two entries, where the consumed-index cursor lands on the flagged entry anyway, so sequencing alone reproduced every asserted progression. Add a three-candidate case where the two disagree: it passes as written and fails with that line removed. Co-Authored-By: Claude Opus 4.8 --- frontend/e2e/mocks/world.unit.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/e2e/mocks/world.unit.test.ts b/frontend/e2e/mocks/world.unit.test.ts index dba376e5..8435174f 100644 --- a/frontend/e2e/mocks/world.unit.test.ts +++ b/frontend/e2e/mocks/world.unit.test.ts @@ -67,6 +67,26 @@ describe('MockWorld matching', () => { expect(world.matchGraphQL('info', {})?.data).toEqual({ role: 'user' }); }); + it('prefers the newly-enabled entry over the next unserved one, not merely the next in order', () => { + // Three candidates, so sequencing and the flag rule disagree: with the rule the raised flag + // jumps straight to `flagged`; without it the cursor would just hand out `second`. The + // two-entry cases above cannot tell the two apart. + const world = new MockWorld({ + mutations: { go: [{ data: {}, setFlag: 'go' }] }, + queries: { + stage: [ + { data: { stage: 'first' } }, + { data: { stage: 'second' } }, + { data: { stage: 'flagged' }, whenFlag: 'go' }, + ], + }, + }); + + expect(world.matchGraphQL('stage', {})?.data).toEqual({ stage: 'first' }); + world.matchGraphQL('go', {}); + expect(world.matchGraphQL('stage', {})?.data).toEqual({ stage: 'flagged' }); + }); + it('advances to the newly-enabled entry after a second flag, without replaying the first', () => { const world = new MockWorld({ mutations: { f1: [{ data: {}, setFlag: 'f1' }], f2: [{ data: {}, setFlag: 'f2' }] },