Skip to content

test(history): add tests for History API v2 endpoints#2490

Open
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:test-history-api-v2
Open

test(history): add tests for History API v2 endpoints#2490
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:test-history-api-v2

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Mar 20, 2026

Description:

This adds tests for the History API v2 provider system (registerHistoryApiProvider) which was added in #2100.

Adds 7 tests covering the History API v2 surface:

  • Without provider: /history/values returns 501 with error message
  • With provider: registration appears in /_providers/history/values returns data with correct shape (context, range, values, data), /history/paths and /history/contexts return arrays from the provider, missing paths parameter returns 400

Response validation uses TypeBox schemas (ValuesResponseSchema, HistoryProvidersResponseSchema) from @signalk/server-api/typebox instead of hand-crafted assertions.

Manual Tests

  • GET /history/values?paths=navigation.position&from=...&to=... — 200, correct response shape
  • GET /history/_providers — 200, lists provider with isDefault
  • GET /history/_providers/_default — 200, returns provider id
  • GET /history/paths?from=...&to=... — 200, returns array
  • GET /history/contexts?from=...&to=... — 200, returns array
  • GET /history/values?from=...&to=... (missing paths) — 400, validation error

@dirkwa
Copy link
Contributor Author

dirkwa commented Mar 23, 2026

Verified that security is intact after merge

The History API v2 provider system (registerHistoryApiProvider) was added
in SignalK#2100 but had no test coverage. Add tests for:

- 501 response when no provider is registered
- Provider registration and discovery via _providers endpoint
- Values, paths, and contexts endpoints with a registered provider
- 400 response for missing required query parameters

Uses testplugin as a mock history provider returning static data.
@dirkwa dirkwa force-pushed the test-history-api-v2 branch from 3d67c35 to 8bc2fe2 Compare March 23, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants