Skip to content

Add LSP, server-process, compiler-mode, and offset tests - #5

Merged
NullVoxPopuli merged 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:more-tests
Aug 26, 2026
Merged

Add LSP, server-process, compiler-mode, and offset tests#5
NullVoxPopuli merged 2 commits into
NullVoxPopuli:mainfrom
NullVoxPopuli-ai-agent:more-tests

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

Covers the three surfaces the suite did not exercise before. All of the editor bugs found so far were invisible to the CLI-only tests.

LSP end to end (test/lsp.js): spawns tsc --lsp --stdio with runExternalCode against examples/nvp-app and asserts on real requests: hover on <Counter> in a template, go-to-definition from a template into counter.gts and from a .ts import into a .gts module, completions after {{yield this. listing the component members, pull diagnostics at the exact template range, and rename. Rename is the strictest check: TypeScript writes edits only through length-preserving Verbatim mappings, so every edit range must cover exactly the identifier (it does: the import specifier becomes Counter as Tally and the opening tag is renamed; the closing tag has no counterpart in the transformed output).

The server process (test/server.js): lib/server.js had no tests; the unit tests call the handlers in-process. This spawns it over stdio with vscode-jsonrpc and runs initialize, openProject (config identity, option diagnostics), transform (template, passthrough, unparseable file), an unknown project handle (JSON-RPC error), and closeProject.

Compiler modes (test/modes.js, diagnostics-tests/):

  • Declaration emit: Greeting.gts emits Greeting.d.gts.ts with the TOC signature (snapshotted). Note TS 7 requires an explicit rootDir, and the emitted index.d.ts keeps the ./Greeting.gts specifier.
  • --build: the first build transforms the component once; the second, up-to-date build transforms nothing (it still sends openProject because the mapper declares dynamicConfig, as specified).
  • Invalid contentMappers[].options: TypeScript renders the mapper's optionDiagnostics at the offending values inside tsconfig.json (tsconfig.json(13,30): error glint0: 'additionalGlobals' must be an array of strings.).

Offsets: unicode.gts (emoji and non-ASCII before the error) and crlf.gts (kept CRLF via .gitattributes) pin UTF-16 position handling; both report at the correct column.

Counts: unit 20 → includes 7 server tests; typecheck suite 16 (five test-packages, three diagnostics projects, two mode tests, six LSP tests). test:unit/test:typecheck scripts updated; CI unchanged.

🤖 Generated with Claude Code

- test/lsp.js drives tsc --lsp with runExternalCode against the nvp-app
  example: hover, go-to-definition (template to component, .ts import
  to .gts), completions inside a template, pull diagnostics at the exact
  template range, and rename, whose edits must land only on
  length-preserving Verbatim mappings.
- test/server.js spawns lib/server.js over stdio with vscode-jsonrpc and
  exercises initialize, openProject (identity and option diagnostics),
  transform (templates, passthrough, parse failure), unknown handles,
  and closeProject.
- test/modes.js covers declaration emit (Greeting.gts emits
  Greeting.d.gts.ts, snapshotted) and --build: the first build transforms
  the component, the up-to-date build transforms nothing.
- diagnostics-tests/invalid-options records how TypeScript renders the
  mapper's option diagnostics inside tsconfig.json; unicode.gts and
  crlf.gts (kept CRLF via .gitattributes) pin UTF-16 position handling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces the hand-rolled JSON-RPC client with vscode-jsonrpc's
connection (already a runtime dependency) and the typed request
definitions from vscode-languageserver-protocol, which also type the
results.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@NullVoxPopuli
NullVoxPopuli merged commit 4b1bc39 into NullVoxPopuli:main Aug 26, 2026
5 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants