Skip to content

Add shared API conformance tests across mojidata backends #43

Description

@mandel59

Problem

The repository has API request tests, but they are not organized as a backend-shared conformance suite.

Current coverage is split across:

  • packages/mojidata-api/tests/mojidata.test.ts: HTTP API tests through the default Node app, or an external MOJIDATA_API_BASE_URL.
  • packages/mojidata-api/tests/app.test.ts: shared routing/query/header behavior with a fake DB.
  • packages/mojidata-api-d1/tests/d1-app.test.ts: D1-specific app request coverage.
  • backend runtime packages such as sql.js, better-sqlite3, node:sqlite, and sqlite-wasm: direct MojidataApiDb calls, not HTTP API calls.

This means backend-specific behavior can be covered at the DB interface level without also proving the same behavior through the public HTTP API surface for each backend.

Proposed Work

Add a shared API conformance test helper, for example runMojidataApiConformanceTests(name, createApp), and reuse it from supported backend packages.

Initial candidate cases:

  • GET /api/v1/mojidata?char=漢&select=char&select=UCS
  • GET /api/v1/mojidata?char=卍&select=ids_similar
  • GET /api/v1/mojidata?char=了&select=ids_similar
  • GET /api/v1/ivs-list?char=一
  • GET /api/v1/idsfind?ids=⿰亻言&limit=20

The ids_similar cases should verify the current IDS mirror and rotation operators:

  • returns with IDS ⿾卍
  • returns 𠄏 with IDS ⿿了

Backends to Consider

  • default Node app in @mandel59/mojidata-api
  • sql.js
  • better-sqlite3
  • node:sqlite
  • D1 app with fake D1 bindings or a realistic test fixture
  • sqlite-wasm where feasible, possibly with a fixture/minimal DB when full OPFS materialization is not practical in Node tests

Notes

Keep the shared suite focused and fast. Backend-specific executor tests should remain in their packages; this issue is about public API request behavior that should be consistent across backends.

Related: #42

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions