(value: unknown, label = 'LatestResult')
| 190 | } |
| 191 | |
| 192 | function validateLatestResult(value: unknown, label = 'LatestResult'): void { |
| 193 | expect(value, `${label}: must be an object`).toBeTypeOf('object'); |
| 194 | expect(value, `${label}: must not be null`).not.toBeNull(); |
| 195 | const obj = value as Record<string, unknown>; |
| 196 | expectRequired(obj, LATEST_RESULT_REQUIRED, label); |
| 197 | expectKeysMatch(obj, LATEST_RESULT_ALL, label); |
| 198 | expect(typeof obj.testId, `${label}.testId`).toBe('string'); |
| 199 | expect(PUBLIC_STATUSES, `${label}.status`).toContain(obj.status); |
| 200 | expectStringOrNull(obj.startedAt, `${label}.startedAt`); |
| 201 | expectStringOrNull(obj.finishedAt, `${label}.finishedAt`); |
| 202 | expectStringOrNull(obj.videoUrl, `${label}.videoUrl`); |
| 203 | expectStringOrNull(obj.failureAnalysisUrl, `${label}.failureAnalysisUrl`); |
| 204 | expect(typeof obj.snapshotId, `${label}.snapshotId`).toBe('string'); |
| 205 | expectStringOrNull(obj.runIdIfAvailable, `${label}.runIdIfAvailable`); |
| 206 | expectStringOrNull(obj.codeVersion, `${label}.codeVersion`); |
| 207 | expectStringOrNull(obj.targetUrl, `${label}.targetUrl`); |
| 208 | // D1 — optional provenance discriminator; when present must be a known enum |
| 209 | // value or null (a null `targetUrl` should carry 'unresolved' or null). |
| 210 | if ('targetUrlSource' in obj) { |
| 211 | expect(TARGET_URL_SOURCES.has(obj.targetUrlSource), `${label}.targetUrlSource`).toBe(true); |
| 212 | } |
| 213 | if (obj.failedStepIndex !== null) { |
| 214 | expect(typeof obj.failedStepIndex, `${label}.failedStepIndex`).toBe('number'); |
| 215 | expect((obj.failedStepIndex as number) >= 1, `${label}.failedStepIndex >= 1`).toBe(true); |
| 216 | } |
| 217 | expect(FAILURE_KINDS.has(obj.failureKind), `${label}.failureKind`).toBe(true); |
| 218 | validateResultSummary(obj.summary, `${label}.summary`); |
| 219 | } |
| 220 | |
| 221 | describe('P4 schema contract — fixtures match the OpenAPI shapes', () => { |
| 222 | it('TestCode (inline) — every required field present, no extras', () => { |
no test coverage detected