docs: final cleanup and accuracy pass before public push
- Fix const inference bug: wrap inferred contracts with status-code guards - Add integration test for status-guarded contract inference - Tighten and deduplicate docs across verify, qualify, getting-started, cli - Fix broken cross-references and TypeScript→JavaScript conversions - Fix factual errors: license, Date.now(), sampling defaults, cache env - Add missing features: --workspace, --generation-profile, json-summary formats - Move stale extension docs (AUTH-RATE-LIMIT-REVISED, HTTP-EXTENSIONS) to attic - Update PLUGIN_CONTRACTS_SPEC status to Implemented - Build: clean | Tests: 849 pass, 0 fail
This commit is contained in:
@@ -753,3 +753,40 @@ test('integration: route-level x-variants are extracted and executed', async ()
|
||||
await fastify.close()
|
||||
}
|
||||
})
|
||||
|
||||
test('integration: inferred contracts are guarded by status code', async () => {
|
||||
const fastify = Fastify() as unknown as TestFastifyInstance
|
||||
try {
|
||||
await fastify.register(swagger, {})
|
||||
await fastify.register(apophisPlugin, {})
|
||||
fastify.get('/status-guarded', {
|
||||
schema: {
|
||||
'x-category': 'observer',
|
||||
response: {
|
||||
200: {
|
||||
type: 'object',
|
||||
properties: { status: { type: 'string', const: 'success' } },
|
||||
required: ['status']
|
||||
},
|
||||
404: {
|
||||
type: 'object',
|
||||
properties: { error: { type: 'string' } },
|
||||
required: ['error']
|
||||
}
|
||||
}
|
||||
} as Record<string, unknown>
|
||||
}, async (request, reply) => {
|
||||
// Return 404 to verify the 200-schema const doesn't fail
|
||||
reply.status(404)
|
||||
return { error: 'not found' }
|
||||
})
|
||||
await fastify.ready()
|
||||
const result = await fastify.apophis.contract({ depth: 'quick' })
|
||||
// Should pass because the inferred const contract is guarded:
|
||||
// response_code(this) == 200 => response_body(this).status == "success"
|
||||
// The 404 response doesn't trigger the antecedent, so the implication holds.
|
||||
assert.strictEqual(result.summary.failed, 0, 'inferred 200-schema const should not fail on 404')
|
||||
} finally {
|
||||
await fastify.close()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user