Skip to content

Add red-phase snapshot tests for REST and admin AJAX APIs#18

Open
datengraben wants to merge 1 commit into
masterfrom
claude/add-api-red-phase-tests-EuOrg
Open

Add red-phase snapshot tests for REST and admin AJAX APIs#18
datengraben wants to merge 1 commit into
masterfrom
claude/add-api-red-phase-tests-EuOrg

Conversation

@datengraben

Copy link
Copy Markdown
Owner

Adds a golden-master snapshot testing layer so the full response shape
of every public API endpoint is locked in before refactoring begins.

Infrastructure

  • ApiSnapshotTrait: normalises dynamic values (post IDs, timestamps,
    site/REST URLs) and compares live responses against stored JSON
    fixtures. On first run the fixture is auto-generated and the test is
    marked incomplete; from that point on any shape change turns the test
    Red.

REST snapshot tests (8 endpoints)

  • ItemsRouteSnapshotTest – list + single item
  • LocationsRouteSnapshotTest – list + single location
  • AvailabilityRouteSnapshotTest – all + single-item availability
  • ProjectsRouteSnapshotTest – project metadata
  • GBFS/DiscoveryRouteSnapshotTest
  • GBFS/SystemInformationRouteSnapshotTest
  • GBFS/StationInformationRouteSnapshotTest
  • GBFS/StationStatusRouteSnapshotTest

Admin AJAX snapshot tests (3 actions)

  • CalendarDataSnapshotTest – cb_calendar_data
  • BookingAjaxSnapshotTest – cb_get_bookable_location + cb_get_booking_code

All tests use deterministic test data (frozen clock, fixed lat/lon) and
share a single Fixtures/ directory under tests/php/API/.

https://claude.ai/code/session_017d1QyizC3FwU7Wa1KfCSM6

Adds a golden-master snapshot testing layer so the full response shape
of every public API endpoint is locked in before refactoring begins.

Infrastructure
- `ApiSnapshotTrait`: normalises dynamic values (post IDs, timestamps,
  site/REST URLs) and compares live responses against stored JSON
  fixtures. On first run the fixture is auto-generated and the test is
  marked incomplete; from that point on any shape change turns the test
  Red.

REST snapshot tests (8 endpoints)
- ItemsRouteSnapshotTest    – list + single item
- LocationsRouteSnapshotTest – list + single location
- AvailabilityRouteSnapshotTest – all + single-item availability
- ProjectsRouteSnapshotTest – project metadata
- GBFS/DiscoveryRouteSnapshotTest
- GBFS/SystemInformationRouteSnapshotTest
- GBFS/StationInformationRouteSnapshotTest
- GBFS/StationStatusRouteSnapshotTest

Admin AJAX snapshot tests (3 actions)
- CalendarDataSnapshotTest  – cb_calendar_data
- BookingAjaxSnapshotTest   – cb_get_bookable_location + cb_get_booking_code

All tests use deterministic test data (frozen clock, fixed lat/lon) and
share a single Fixtures/ directory under tests/php/API/.

https://claude.ai/code/session_017d1QyizC3FwU7Wa1KfCSM6
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