( value: unknown, label = 'FailureContext', )
| 117 | } |
| 118 | |
| 119 | function validateFailureContext( |
| 120 | value: unknown, |
| 121 | label = 'FailureContext', |
| 122 | ): asserts value is CliFailureContext { |
| 123 | expect(value, `${label}: must be an object`).toBeTypeOf('object'); |
| 124 | expect(value, `${label}: not null`).not.toBeNull(); |
| 125 | const obj = value as Record<string, unknown>; |
| 126 | expectRequired(obj, FAILURE_CONTEXT_REQUIRED, label); |
| 127 | expectKeysMatch(obj, new Set(FAILURE_CONTEXT_REQUIRED), label); |
| 128 | expect(typeof obj.snapshotId, `${label}.snapshotId`).toBe('string'); |
| 129 | expect(typeof obj.testId, `${label}.testId`).toBe('string'); |
| 130 | expect(typeof obj.projectId, `${label}.projectId`).toBe('string'); |
| 131 | validateFailureBlock(obj.failure, `${label}.failure`); |
| 132 | // result/steps/code shapes are validated in p4-schema.test.ts — |
| 133 | // here we only assert the cross-bundle identity invariants. |
| 134 | const result = obj.result as Record<string, unknown>; |
| 135 | expect(result.snapshotId, `${label}: result.snapshotId === bundle.snapshotId`).toBe( |
| 136 | obj.snapshotId, |
| 137 | ); |
| 138 | expect(Array.isArray(obj.steps), `${label}.steps array`).toBe(true); |
| 139 | } |
| 140 | |
| 141 | describe('P5 schema contract — FailureContext fixtures match the OpenAPI shape', () => { |
| 142 | it('failureContextFixture passes the FailureContext validator', () => { |
no test coverage detected