Repository navigation
test(contract): expand API contract and backwards-compatibility E2E coverage - #762
Open
produckq-boop wants to merge 1 commit into
Open
produckq-boop wants to merge 1 commit into
produckq-boop wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #673
Expand end-to-end API contract and backwards-compatibility coverage in
tests/contract/api-contract.test.ts(18->62tests) across versioned 2xx response envelopes, structured error contracts, security and request-correlation headers, health endpoints, and/api/*->/api/v1/*redirection behavior:GET /api/v1/courses: verifies{ success: true, data: CourseSummary[], pagination: { page, limit, total }, meta: { version, timestamp, requestId } }, ISO-8601meta.timestamp, andCache-Control: public, max-age=30.GET /api/v1/courses/:id: verifiesCourseDetail+modulesarray schema, ISO-8601createdAtserialization, andmeta.requestId/X-Request-Idcorrelation.POST /api/v1/auth/challenge: verifies SEP-10{ challenge, challengeId, networkPassphrase }payload envelope andCache-Control: no-store.400,401,404,413):400:VALIDATION_ERRORwithdetails.bodyon invalid request body, plus structured400responses on invalid querystring parameters and malformed UUID route parameters (metaomitted,Cache-Control: no-store).401 UNAUTHORIZED: unauthenticated requests and malformed Bearer tokens across protected user (/api/v1/users/me), session (/api/v1/auth/sessions), credential (/api/v1/credentials), reward (/api/v1/rewards/history), and admin (/api/v1/admin/dashboard,/admin/auth-blocks) endpoints.404 NOT_FOUND: unknown/api/v1/*routes, unknown top-level routes, and static/uploads/avatars/*path-traversal, unsupported-extension, and missing-file requests.413 PAYLOAD_TOO_LARGE: request bodies exceedingREQUEST_BODY_LIMIT_BYTES(details.expectedSizeanddetails.actualSize).X-Request-Idecho preservation across 2xx,301redirect, and 4xx responses plus automatic UUID-v4 generation when omitted, OWASP@fastify/helmetsecurity headers (X-Powered-Byhidden),/docs/jsonOpenAPI 3.x specification, and/health,/health/live,/health/ready,/health/redis,/health/database,/health/ai, and/health/stellarpayload schemas.301permanent redirects across legacy/api/*prefixes (including/api/announcements,/api/rewards/leaderboard, and/api/admin/*), deeply nested route segments with encoded query strings,POST/PUT/DELETEredirect targets resolving in a single hop without redirect loops, and strict404isolation on unsupported API versions (/api/v0/*,/api/v2/*,/api/v10/*).Validation
npx eslint tests/contract/api-contract.test.ts --max-warnings=0: passed (0errors,0warnings)npx vitest run tests/contract/api-contract.test.ts:62/62tests passed