( actual: readonly RoutedAction[], expected: readonly RoutedAction[] | undefined, )
| 48 | } |
| 49 | |
| 50 | export function assertScenarioActions( |
| 51 | actual: readonly RoutedAction[], |
| 52 | expected: readonly RoutedAction[] | undefined, |
| 53 | ): readonly ScenarioMismatch[] { |
| 54 | if (expected === undefined) return Object.freeze([]); |
| 55 | const mismatches: ScenarioMismatch[] = []; |
| 56 | if (actual.length !== expected.length) { |
| 57 | mismatches.push({ |
| 58 | code: "ZR_SCENARIO_ACTION_COUNT_MISMATCH", |
| 59 | path: "expectedActions", |
| 60 | detail: `Expected ${String(expected.length)} actions, observed ${String(actual.length)}`, |
| 61 | expected: expected.length, |
| 62 | actual: actual.length, |
| 63 | }); |
| 64 | } |
| 65 | const max = Math.max(actual.length, expected.length); |
| 66 | for (let index = 0; index < max; index++) { |
| 67 | const want = expected[index]; |
| 68 | const got = actual[index]; |
| 69 | if (want === undefined || got === undefined) continue; |
| 70 | if (actionEquals(want, got)) continue; |
| 71 | mismatches.push({ |
| 72 | code: "ZR_SCENARIO_ACTION_MISMATCH", |
| 73 | path: `expectedActions[${String(index)}]`, |
| 74 | detail: `Observed action does not match expected action at index ${String(index)}`, |
| 75 | expected: want, |
| 76 | actual: got, |
| 77 | }); |
| 78 | } |
| 79 | return Object.freeze(mismatches); |
| 80 | } |
| 81 | |
| 82 | export function assertScreenRegion( |
| 83 | screen: ScenarioScreenSnapshot, |
no test coverage detected