Skip to content

Replace mock heavy tests with DB API tests #502

Description

@conservationtimothy

Feature Request

Replace the mock-heavy view dataset endpoint unit tests with DB-backed API tests that use the existing Playwright test database setup.

User Stories & Acceptance Criteria

As a reviewer, I want the gallery/map dataset API tests to exercise the real config DB and warehouse DB path, so the tests prove endpoint behavior instead of only proving mocked function calls.

Acceptance criteria:

  • Add a Playwright API spec that calls the real gallery/map endpoints against seeded test data.
  • Use existing guardianconnector and warehouse fixtures from the e2e setup.
  • Assert that the endpoint returns primary_dataset.
  • Assert that table matches the resolved primary_dataset.
  • Assert that the response has the expected view payload shape.
  • Remove or reduce mock-heavy endpoint tests that only assert fetchViewTables / fetchData interactions.

UI Sketch (or Screenshot)

N/A. This is test coverage for API behavior.

Implementation Plan

Use the existing Playwright setup. Add a spec like tests/e2e/11-view-dataset-api.spec.ts that calls endpoints with page.request.get(...), using seeded rows from tests/db-seed/guardianconnector.sql and warehouse tables from tests/db-seed/warehouse.sql.

For gallery, call a seeded gallery endpoint such as /api/seed_survey_data/gallery and assert primary_dataset, table, and gallery payload shape. For map, call /api/bcmform_responses/map and assert the same dataset contract plus map payload shape. Keep helper-level unit tests only if they remain small and meaningful; move endpoint behavior coverage to Playwright.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions