Skip to content

test(integration): add component-install helper, port REST query suite - #627

Merged
kriszyp merged 1 commit into
mainfrom
claude/api-tests-component-fixture
May 20, 2026
Merged

test(integration): add component-install helper, port REST query suite#627
kriszyp merged 1 commit into
mainfrom
claude/api-tests-component-fixture

Conversation

@kriszyp

@kriszyp kriszyp commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

Third slice of the api-tests migration on top of #597.

  • `integrationTests/apiTests/utils/components.mjs` — `installAppComponent(client, { project, files, probePath, restartTimeoutMs })`. Issues `add_component`, `set_component_file` per file, then `restartHttpWorkers` polling `probePath` until the route registers. Idempotent w.r.t. "Project already exists".
  • `integrationTests/apiTests/rest.test.mjs` (was `tests/20_restTests.mjs`) — exercises Harper's REST query syntax against the `appGraphQL` test schema. Self-contained: installs its own trimmed `appGraphQL` schema (`Related` + `SubObject` only — the types this suite reads) plus the canonical seed rows that the legacy `19_graphQlTests` step inserted.

Skipped on Windows — depends on `restart_service http_workers`, which crashes the Harper instance on Windows (#549). Matches the existing skip pattern in `headers.test.mjs`.

Purpose

Unlocks the remaining component-dependent suites. The legacy `17a_addComponents.mjs` step installed `computed`, `appGraphQL`, and `myApp111` components once for the whole sequential run; suites 18 (computed indexed props), 19 (graphQL), 20 (rest), and 22 (openapi) all assumed those components were present. With `installAppComponent` in place, each of those can be ported as a self-contained file with its own component install.

Where to look

  • `utils/components.mjs` — small new helper. Designed for reuse by the next ports; takes a generic `files` map so callers control schema + config + resources files. `probePath` is the route the test will exercise; `restartHttpWorkers` (test(integration): migrate api-tests foundation to harperLifecycle framework #555) polls it until non-404, which is how we sidestep the race between workers coming back online and route registration.
  • `rest.test.mjs` schema — trimmed down from the original 10-type schema in legacy `17a` to just `Related` + `SomeObject` + `SubObject`. Future ports of 19 will likely need the full schema; that can grow into a shared `appGraphQLFixture` helper if it's worth the abstraction.

Testing

All 49 tests across the 6 ported suites pass in parallel locally:

```
npm run test:integration -- "integrationTests/apiTests/*.test.mjs"

▶ System Information ✔ (2/2)

▶ Alter User ✔ (7/7)

▶ HTTP Header / Set-Cookie handling ✔ (2/2)

▶ Transaction Logs ✔ (7/7)

▶ Transactions / audit log ✔ (19/19)

▶ REST query syntax ✔ (12/12)

ℹ pass 49 fail 0 duration_ms ~12300

```

Gemini cross-review flagged two issues — both were hallucinations (claimed a long invented directive path and a leading space in an import that don't exist in the actual file). Substantive findings (faithful port, correct helper, correct Windows skip) check out.


🤖 Generated by Claude (Opus 4.7), see commit Co-Authored-By tag.

Third slice of the api-tests migration on top of #597.

- utils/components.mjs: installAppComponent(client, {project, files,
  probePath, restartTimeoutMs}). Issues add_component, set_component_file
  per file, then restartHttpWorkers polling probePath. Idempotent w.r.t.
  "Project already exists". Will be reused by upcoming ports of 18
  (computedIndexedProperties), 19 (graphQlTests), and 22 (openApi),
  which all rely on appGraphQL / computed / myApp111 components that the
  legacy 17a_addComponents step installed once for the whole sequential
  run.

- rest.test.mjs (from tests/20_restTests.mjs): exercises Harper's REST
  query syntax (?key==value&select(...), nested .related.subObject.any
  attribute paths, 413 on oversize POST) against the appGraphQL test
  schema. Self-contained: installs its own trimmed appGraphQL schema
  (Related + SubObject only, the types this suite reads) plus the
  canonical Related/SubObject seed rows that legacy 19_graphQlTests
  inserted.

- Skipped on Windows: depends on restart_service http_workers, which
  crashes the Harper instance on Windows (#549).
  Matches the existing per-suite skip pattern in headers.test.mjs.

All 49 tests across the 6 ported suites pass in parallel (~12s wall).
Legacy testSuite.mjs / tests/*.mjs are intentionally still in place;
full cutover happens after the remaining suites are migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kriszyp
kriszyp requested a review from a team as a code owner May 20, 2026 04:45
@claude

claude Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Reviewed; no blockers found.

@kriszyp
kriszyp merged commit 2eb84ac into main May 20, 2026
38 of 39 checks passed
@kriszyp
kriszyp deleted the claude/api-tests-component-fixture branch May 20, 2026 21:34
kriszyp added a commit that referenced this pull request May 21, 2026
Fourth slice of the api-tests migration. Independent of #627 (no
component-install dependency) — based directly on main.

- token-auth.test.mjs (from tests/14_tokenAuth.mjs): create_authentication_tokens
  happy path + missing/invalid credentials, bearer-token search_by_hash,
  refresh_operation_token with valid/invalid tokens.

- Self-contained: seeds a single northnwd.employees row in before() so
  the bearer-token search has a deterministic record. The legacy
  version inherited this from 2_dataLoad.mjs.

- Preserves the legacy isDevEnv() branching by reading
  authentication.authorizeLocal from get_configuration in before(). With
  authorizeLocal=true (the integration framework default for loopback
  callers), the no-credentials call mints a token; otherwise it returns
  401 "Must login". This matches the legacy test exactly.

All 46 tests across the 6 ported suites pass in parallel (this branch
omits the rest.test.mjs from PR #627; CI will see 49 once both land).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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