Skip to content

#141 Part 2: Update integration test call sites for parseCollectionResponse parseItem callback #155

@Sam-Bolling

Description

@Sam-Bolling

Parent Issue

Split from #141parseCollectionResponse casts raw JSON to T[] without element validation.

This is Part 2 of 2. See also: #154 (Part 1 — core implementation + unit tests).


Scope — Part 2 Only

This part updates all integration test call sites to pass the parseItem callback that Part 1 (#154) added to parseCollectionResponse. After Part 1, these tests fail because the function signature changed. This part fixes them.

Files to Modify

File Action Est. Call Sites
src/ogc-api/csapi/integration/discovery.spec.ts Update parseCollectionResponse calls to pass parser callback ~10
src/ogc-api/csapi/integration/command.spec.ts Update calls — pass parseCommand / parseControlStream / parseCommandStatus ~10
src/ogc-api/csapi/integration/navigation.spec.ts Update calls — pass appropriate parser per resource type ~5
src/ogc-api/csapi/integration/observation.spec.ts Update calls — pass parseObservation / parseDatastream ~8
src/ogc-api/csapi/integration/pipeline.spec.ts Integrate parseItem into existing two-step pipeline (currently does separate .map(parseDatastream)) ~3
Any other spec files with parseCollectionResponse calls Update similarly TBD

Pattern

Each call site changes from:

const result = parseCollectionResponse<Datastream>(body);

to:

const result = parseCollectionResponse(body, parseDatastream);

The correct parser for each call site depends on the resource type being tested:

Resource Type Parser Callback
Systems parseSystem (from sensorml/)
Deployments parseDeployment (from part2.ts)
Procedures parseProcedure (from sensorml/)
SamplingFeatures parseSamplingFeature (from geojson.ts)
Datastreams parseDatastream (from part2.ts)
Observations parseObservation (from part2.ts)
ControlStreams parseControlStream (from part2.ts)
Commands parseCommand (from part2.ts)
CommandStatus parseCommandStatus (from part2.ts)
CSAPI Features extractCSAPIFeature (from geojson.ts)

Each call site requires semantic judgment about which parser to pass — this is NOT a mechanical find-and-replace.

Special case: pipeline.spec.ts

pipeline.spec.ts already demonstrates the correct two-step pattern:

const collection = parseCollectionResponse(DATASTREAMS_COLLECTION);
const datastreams: Datastream[] = collection.items.map(parseDatastream);

After Part 1, this becomes the one-step:

const collection = parseCollectionResponse(DATASTREAMS_COLLECTION, parseDatastream);
// collection.items is already Datastream[] — no separate .map() needed

What NOT to Touch

  • response.ts — already modified in Part 1
  • response.spec.ts — already modified in Part 1
  • ❌ Production code — this part is test-only
  • ❌ Any file outside src/ogc-api/csapi/

Acceptance Criteria (Part 2)

  • All parseCollectionResponse call sites across integration tests pass the correct parseItem callback
  • No call sites use the old parseCollectionResponse<T>(body) signature (without callback)
  • npm test — all tests pass (full suite, including Part 1's unit tests)
  • tsc --noEmit — zero errors
  • npm run lint — zero errors
  • npx prettier --check src/ — all formatted

Dependencies

Blocked by: #154 (Part 1 — must be completed first)
Blocks: Nothing

References

All references from #141 apply. Key ones for this part:

  • #141 Part 1: Implement parseItem callback in parseCollectionResponse + unit tests #154 — Part 1 (core implementation this part depends on)
  • src/ogc-api/csapi/formats/part2.tsparseDatastream, parseObservation, parseCommand, parseControlStream, parseCommandStatus
  • src/ogc-api/csapi/formats/geojson.tsextractCSAPIFeature, parseSamplingFeature
  • src/ogc-api/csapi/formats/sensorml/parseSystem, parseProcedure
  • src/ogc-api/csapi/integration/pipeline.spec.ts lines 81–89 — existing two-step pattern precedent

Operational Constraints

⚠️ MANDATORY: Before starting work on this issue, review docs/governance/AI_OPERATIONAL_CONSTRAINTS.md.

Upstream Isolation Constraint

Per the upstream maintainer's comment on PR #136: all files in this part are within src/ogc-api/csapi/ — purely internal to the isolated CSAPI module.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions