|
| 1 | +import { expect, test } from 'vitest'; |
| 2 | +import { armRepair, resolveScriptTarget } from '../session-script-publication-state.ts'; |
| 3 | + |
| 4 | +// The retention table for the per-target force model (#1258). The repair suites pin these |
| 5 | +// transitively through healed-sibling paths; this pins the transition itself, so a regression |
| 6 | +// names the rule it broke instead of a downstream path assertion. |
| 7 | + |
| 8 | +test('a bare re-arm keeps a materialized explicit target and its grant', () => { |
| 9 | + const previous = { kind: 'explicit', path: '/flows/a.healed.ad', force: true } as const; |
| 10 | + expect(resolveScriptTarget(previous, { force: false })).toEqual(previous); |
| 11 | +}); |
| 12 | + |
| 13 | +test('a bare re-arm with live force adds the grant without touching the path', () => { |
| 14 | + expect( |
| 15 | + resolveScriptTarget( |
| 16 | + { kind: 'explicit', path: '/flows/a.healed.ad', force: false }, |
| 17 | + { force: true }, |
| 18 | + ), |
| 19 | + ).toEqual({ kind: 'explicit', path: '/flows/a.healed.ad', force: true }); |
| 20 | +}); |
| 21 | + |
| 22 | +test('re-arming the same explicit path keeps an existing grant', () => { |
| 23 | + expect( |
| 24 | + resolveScriptTarget( |
| 25 | + { kind: 'explicit', path: '/flows/a.ad', force: true }, |
| 26 | + { path: '/flows/a.ad', force: false }, |
| 27 | + ), |
| 28 | + ).toEqual({ kind: 'explicit', path: '/flows/a.ad', force: true }); |
| 29 | +}); |
| 30 | + |
| 31 | +test('retargeting to a different explicit path without live force drops the grant', () => { |
| 32 | + expect( |
| 33 | + resolveScriptTarget( |
| 34 | + { kind: 'explicit', path: '/flows/a.ad', force: true }, |
| 35 | + { path: '/flows/b.ad', force: false }, |
| 36 | + ), |
| 37 | + ).toEqual({ kind: 'explicit', path: '/flows/b.ad', force: false }); |
| 38 | +}); |
| 39 | + |
| 40 | +test('moving from default to an explicit path keeps the grant (#1258 flagged retention)', () => { |
| 41 | + expect( |
| 42 | + resolveScriptTarget({ kind: 'default', force: true }, { path: '/flows/out.ad', force: false }), |
| 43 | + ).toEqual({ kind: 'explicit', path: '/flows/out.ad', force: true }); |
| 44 | +}); |
| 45 | + |
| 46 | +test('per-step repair re-arms never move the boundary or wipe the healed sibling', () => { |
| 47 | + const armed = armRepair( |
| 48 | + { kind: 'none' }, |
| 49 | + { |
| 50 | + requested: { path: '/flows/login.healed.ad', force: false }, |
| 51 | + boundary: 3, |
| 52 | + sourcePath: '/flows/login.ad', |
| 53 | + }, |
| 54 | + ); |
| 55 | + const rearmed = armRepair(armed, { requested: { force: false }, boundary: 0 }); |
| 56 | + expect(rearmed).toEqual(armed); |
| 57 | +}); |
0 commit comments