You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complete unit test coverage for the CSAPIQueryBuilder class and helper functions by adding edge case tests, error case tests, pagination tests, and query parameter tests to achieve >80% statement and branch coverage for all CSAPI core modules.
ROADMAP Reference: Phase 4, Task 2 — Unit Tests Completion (~3-4 hours, Medium complexity)
Files to Create or Modify
File
Action
Est. Lines
Purpose
src/ogc-api/csapi/url_builder.spec.ts
Modify
~200-300
Add edge case, error, pagination, and query parameter tests to existing QueryBuilder test suite
src/ogc-api/csapi/helpers.spec.ts
Modify
~100-150
Complete coverage for all exported helper functions
Total: ~300-450 lines of additional test code across 2 files
Blueprint Reference
Follow the EDR test pattern in src/ogc-api/edr/model.spec.ts (42 lines) — uses Jest describe/test blocks, direct function imports, and assertion-per-behavior style. Also follow the upstream src/ogc-api/endpoint.spec.ts for integration-style unit test patterns with globalThis.fetch mocking.
Scope — What to Implement
1. QueryBuilder Edge Case Tests (url_builder.spec.ts)
Add tests for boundary conditions not covered by the per-resource method tests written in Phase 2 (Issues #5-#13):
Empty/minimal collections:
Collection with zero available resources → all methods throw EndpointError
Collection with exactly one resource type → only that resource's methods work
Minimal resource responses (required fields only, no optional fields)
Boundary conditions:
limit at boundaries: 0, 1, maximum allowed value
offset at boundaries: 0, negative (should error), very large values
Note: Per the Guide (L622), buildResourceUrl, buildQueryString, and extractAvailableResources are currently private helpers tested indirectly through public API tests. If they remain private when this task begins, add more public-API tests covering their edge cases. If they have been extracted as exported functions by then, add direct unit tests here.
JSDoc Requirements
Document all test describe blocks with a summary of what coverage category they provide
Add @see links to the relevant query parameter documentation in the Guide (§6 Query Parameters Reference)
Follow the JSDoc style in src/ogc-api/edr/model.spec.ts
❌ Do NOT modify implementation files (url_builder.ts, model.ts, helpers.ts) — if a bug is discovered, document it as a separate issue
❌ Do NOT add new test fixtures — reuse fixtures created in Phases 1-3
❌ Do NOT modify API documentation or JSDoc in implementation files — that belongs to Phase 4, Task 3: API Documentation #32 (GitHub) / Phase 4, Task 3: API Documentation
❌ Do NOT modify files outside the "Files to Create or Modify" table above
❌ Do NOT refactor existing test code unless required to complete this task
❌ Do NOT write tests that assert fixture data values (AP1 violation) or data shape (AP4 violation)
Acceptance Criteria
url_builder.spec.ts has additional edge case tests (~200-300 new lines)
helpers.spec.ts has complete coverage for all exported helpers (~100-150 new lines)
Edge case tests cover: empty collections, boundary values, minimal resources
Task
Complete unit test coverage for the CSAPIQueryBuilder class and helper functions by adding edge case tests, error case tests, pagination tests, and query parameter tests to achieve >80% statement and branch coverage for all CSAPI core modules.
ROADMAP Reference: Phase 4, Task 2 — Unit Tests Completion (~3-4 hours, Medium complexity)
Files to Create or Modify
src/ogc-api/csapi/url_builder.spec.tssrc/ogc-api/csapi/helpers.spec.tsTotal: ~300-450 lines of additional test code across 2 files
Blueprint Reference
Follow the EDR test pattern in
src/ogc-api/edr/model.spec.ts(42 lines) — uses Jestdescribe/testblocks, direct function imports, and assertion-per-behavior style. Also follow the upstreamsrc/ogc-api/endpoint.spec.tsfor integration-style unit test patterns withglobalThis.fetchmocking.Scope — What to Implement
1. QueryBuilder Edge Case Tests (
url_builder.spec.ts)Add tests for boundary conditions not covered by the per-resource method tests written in Phase 2 (Issues #5-#13):
Empty/minimal collections:
EndpointErrorBoundary conditions:
limitat boundaries: 0, 1, maximum allowed valueoffsetat boundaries: 0, negative (should error), very large valuesbboxedge cases: antimeridian crossing, zero-area bbox, reversed coordinatesdatetimeedge cases: open-ended intervals (../end,start/..), single instant, far-future/far-past datesid: '',parentId: ''Resource validation edge cases:
2. Error Case Tests (
url_builder.spec.ts)Invalid parameters:
getSystem()without an ID)Resource validation failures:
EndpointErrorthrown with correct message and available resources listavailableResourcesSet is correctly populated from conformance dataNetwork-adjacent error handling:
3. Pagination Tests (
url_builder.spec.ts)Offset-based pagination:
limitandoffsetparameters correctly appended to URLsCursor-based pagination:
4. Query Parameter Tests (
url_builder.spec.ts)Verify correct URL encoding for ALL query parameter categories:
Spatial parameters:
bboxwith 4 values (2D) and 6 values (3D)geomwith WKT string encodinglat/lon/radiusfor proximity queriesTemporal parameters:
datetimewith single instant, bounded interval, open-ended intervalphenomenonTime,resultTime,validTimefor observation queriesRelationship parameters:
parent,procedure,foi,observedProperty— correct URL encodingHierarchical parameters:
recursiveflag correctly appendedFormat parameters:
f(format) parameter for content negotiation5. Helper Function Tests (
helpers.spec.ts)Complete coverage for all exported helper functions:
URL building helpers:
buildResourceUrl()— all path segment combinationsbuildQueryString()— parameter encoding, special characters, empty paramsTemporal helpers:
Validation helpers:
extractAvailableResources()from conformance dataJSDoc Requirements
describeblocks with a summary of what coverage category they provide@seelinks to the relevant query parameter documentation in the Guide (§6 Query Parameters Reference)src/ogc-api/edr/model.spec.tsTesting Requirements
src/ogc-api/csapi/url_builder.spec.ts(~200-300 additional lines)src/ogc-api/csapi/helpers.spec.ts(~100-150 additional lines)globalThis.fetch = jest.fn()mocking — no nock, msw, or other librariessrc/ogc-api/edr/model.spec.ts(42 lines)npm test— all existing + new tests passurl_builder.ts,model.ts,helpers.tsScope — What NOT to Touch
url_builder.ts,model.ts,helpers.ts) — if a bug is discovered, document it as a separate issueAcceptance Criteria
url_builder.spec.tshas additional edge case tests (~200-300 new lines)helpers.spec.tshas complete coverage for all exported helpers (~100-150 new lines)npm test)Dependencies
Blocked by: #31 — Phase 4, Task 1: Integration Tests (integration test infrastructure must exist first)
Blocks: #32 (GitHub) — Phase 4, Task 3: API Documentation (all tests must pass before final doc review)
Operational Constraints
Key constraints for this task:
References
Read these documents before starting implementation. They are ordered by priority.
Primary References (must read)
docs/planning/csapi-implementation-guide.mddocs/planning/csapi-implementation-guide.mddocs/planning/csapi-implementation-guide.mdsrc/ogc-api/edr/model.spec.tsdocs/planning/ROADMAP.mdUpstream Type/Import References (files this task tests)
src/ogc-api/csapi/url_builder.tssrc/ogc-api/csapi/helpers.tssrc/ogc-api/csapi/model.tsResearch References (context, not required reading)
docs/research/testing/findings/06-meaningful-vs-trivial-definition.mddocs/research/testing/review/phase-0-lessons-from-failed-attempt.mddocs/research/testing/testing-strategy-research.mdSpecification References (for
@seelinks and test accuracy)docs/research/standards/ogcapi-connectedsystems-1.bundled.oas31.yamldocs/research/standards/ogcapi-connectedsystems-2.bundled.oas31.yamlConvention Quick Reference
.jsextension for relative importsimport { X } from './file.js'import typefor interfaces/typesimport type { Y } from './model.js'export interface Z { ... }as constarrays for enum-like valuesexport const XTypes = [...] as constglobalThis.fetch = jest.fn()