Skip to content

test: add missing unit tests, fix polytype meta data lookup - #25

Open
mfal wants to merge 2 commits into
mainfrom
claude/missing-unit-tests-6e40c7
Open

mfal wants to merge 2 commits into
mainfrom
claude/missing-unit-tests-6e40c7

Conversation

@mfal

@mfal mfal commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Tests: add unit tests for the modules that had none (queries, resolveGhostChain, invalidate, reset, withEachGhost, hash, context, types, polytype), and extend metaData, asGhost and makeGhost tests (render(), reset(), generated query keys, query options, transform dependencies, error boundary). 25 → 115 tests.
  • The former queries.test.ts actually tested metaData.ts, so it's renamed to metaData.test.ts, and queries.test.ts now tests query key generation.
  • Fix: with the ./polytype entry point, getMetaData() returned undefined for every model with incomplete meta data (only name or only getId). The reason is that getPrototypeListOf(Object.prototype) returns [] instead of [null]. Meta data of multiple parent classes was also never merged, because the lookup stopped after the first parent branch.

Meta data precedence (new)

The lookup walks all parent classes depth-first and merges what it finds:

  1. The class itself wins over its parents.
  2. Earlier parents, including their ancestors, win over later ones.
class Both extends classes(Named, IdOnly) {}
getModelName(new Both()); // "Named"      (before: undefined)
getModelId(new Both());   // from IdOnly  (before: undefined)

Single inheritance without polytype behaves as before.

Not addressed

forwardQueryContext() throws away the result of ghostFnContext.bind(...) and calls fn() directly. It only works when called synchronously inside an active query context. The tests cover only that case.

Test plan

  • pnpm test in packages/react-ghostmaker (tsc, lint, build, vitest, licenses) passes locally
  • New polytype tests failed before the fix and pass after it

🤖 Generated with Claude Code

mfal and others added 2 commits September 28, 2026 16:20
Cover query key generation, meta data lookup (incl. dynamic models and
name conflicts), ghost chain resolution, invalidation/reset filters,
hashing, query context, render(), reset(), query options, transform
dependencies and error propagation.

The former queries.test.ts tested metaData.ts and is renamed accordingly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the ./polytype entry point, getPrototypeListOf(Object.prototype)
returns [] instead of [null], so incomplete meta data (only name or only
getId) was dropped and getMetaData() returned undefined. Meta data of
multiple parent classes was never merged either, as the lookup stopped
after the first parent branch.

The lookup now walks all parent classes depth-first and merges their
meta data: the class itself wins over its parents, earlier parents
(including their ancestors) win over later ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mfal mfal self-assigned this Sep 28, 2026
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.

1 participant