React + Fastify · Easy · Api Integration
The supplied browser picker and HTTP directory both work. The connecting client adapter does not preserve query text and turns failed requests into successful empty lists. Repair that boundary and verify the result through the running screen and service.
Task
Connect the existing directory to the browser: encode queries, map items and propagate HTTP failures without changing either application.
Contract
- Browser — Starting data:
initialRowsis the supplied project list. Do not mutate it.ididentifies a project;titleis its visible name;archivedhides it from the active list.seatsis the available seat count;versionidentifies the last server version of that project. - Browser — User action: The user types into the existing Search projects control. Use the supplied initial list; this task does not require an API request.
- API — Request:
GET /projectsreads the supplied project repository. Query parameters are optional. - API — Query parameters:
q— title text to search for. Default: empty string. Trim whitespace; maximum length: 80 characters.limit— number of rows requested. Default:20; allowed integers:1..50.offset— number of matching rows to skip. Default:0; allowed integers:0..10000. Numeric parameters must contain digits only. For example,1.5,-1andabcare invalid. - API — Authentication:
Authorization: Bearer fixture-alphaidentifies tenantalpha;fixture-bravoidentifies tenantbravo. The supplied authentication helper resolves the tenant. A query/body field is not an identity source. - API — Repository records: Each project has
id,title,tenant,archived,seatsandversion. The fixture provides the data. Use its repository; no external database is required. - Connecting the two layers:
web/src/api-client.jsis the browser-to-HTTP adapter.api.listreads the HTTP response’sitemsarray.api.reservemaps the HTTP receipt’sremainingfield to the component’sseatsfield.
Acceptance criteria
- Show non-archived projects whose title contains the trimmed search text, ignoring letter case.
- An empty or whitespace-only query shows every active project.
- Order the visible projects by ASCII ID.
- Show
No projectswhen nothing matches. - Editing the query updates the list without replacing the whole screen or losing the input state.
- Keep the existing control labels and stable row identity.
- Return HTTP
200with{total, items, nextOffset}. itemscontains only{id, title, seats, version}. Do not expose the internal tenant field.- Keep only the authenticated tenant’s non-archived projects.
- Match the title against the trimmed query without regard to letter case.
- Sort matching projects by ASCII ID before taking the requested page.
totalis the number of all matching projects before pagination, not the page length.- Skip
offsetmatches and return at mostlimititems. nextOffsetisoffset + items.lengthonly when another matching item remains; otherwise it isnull.- An exhausted page has
items: []andnextOffset: null, while keeping the fulltotal. - Invalid query: HTTP
400with{code: "INVALID_QUERY"}. - Missing or unknown bearer token: HTTP
401with{code: "UNAUTHORIZED"}. - URL-encode search text; it must not become extra query parameters.
- Reject failed HTTP responses with their status. Do not hide errors as an empty successful list.
- Retry HTTP 503 at most once, with the exact same request body and key.
- Do not retry HTTP 400, 401 or 409, or an aborted operation.
Constraints
- At most 200 rows; IDs are unique ASCII strings and seats are non-negative integers. Input props must not be mutated.
- Keep the Search projects label, data-id row identity and accessible status messages.
- At most 10000 projects in the repository; query length at most 80; page size at most 50.
- Use the supplied repository and authenticated tenant resolver. No external database, network service or production credential is needed.
- Directory reads must not mutate stored records or expose the internal tenant field.
- All services run inside the test process on loopback. No external deployment, database or cloud account is required.
Editable files
web/tests/candidate.test.js— Add DOM-level regression tests using fixture(t), deferred() and assert.server/tests/candidate.test.js— Add the required regression tests here using fixture(t), assert and node:test.web/src/api-client.js— Repair URL encoding, error propagation and response DTO mapping.integration/candidate.test.js— Add cross-layer regressions; reuse the local integration fixture.