Skip to content

Consolidate TypeScript API type tests into dedicated test file - #1480

Merged
DZakh merged 5 commits into
mainfrom
claude/typescript-types-test-refactor-8hyozt
Jul 24, 2026
Merged

Consolidate TypeScript API type tests into dedicated test file#1480
DZakh merged 5 commits into
mainfrom
claude/typescript-types-test-refactor-8hyozt

Conversation

@DZakh

@DZakh DZakh commented Jul 24, 2026

Copy link
Copy Markdown
Member

Moves comprehensive TypeScript API type assertions from scattered locations into a new dedicated test file TypeScriptApiTypes_test.res, improving test organization and maintainability.

Summary

This change consolidates all TypeScript API type-checking tests into a single, self-contained test suite. Previously, type assertions were distributed across multiple test files (EventHandler.test.ts, CustomSelection.test.ts) and handler source files (EventHandlers.ts). The new test file provides a unified, well-documented home for all public API type contracts.

Key Changes

  • New test file: packages/envio-tests/test/TypeScriptApiTypes_test.res (1084 lines)

    • Comprehensive type assertions for EVM, Fuel, and SVM ecosystems
    • Self-contained mock indexer with schema, config, and type checks
    • Organized into describe blocks by ecosystem
    • Documents the full public TypeScript API surface
  • Removed from EventHandler.test.ts:

    • Removed ~370 lines of type assertions for EvmEvent, EvmOnEventOptions, EvmContractRegisterOptions, EvmOnEventHandler, EvmContractRegisterHandler, EvmOnEventContext, EvmContractRegisterContext, EvmOnBlockWhereResult, EvmOnBlockFilter, EvmOnBlockOptions, EvmOnBlockContext, EvmOnBlockHandler, EvmOnBlockHandlerArgs, EvmOnBlockWhereArgs
    • Removed unused imports related to these types
  • Removed from EventHandlers.ts:

    • Removed ~35 lines of type-only registration surface checks (guarded by if (0))
    • Removed ~70 lines of _typeCheckEvmWhereBlockShape() function with block filter type assertions
    • Removed unused imports
  • Removed from CustomSelection.test.ts:

    • Removed ~45 lines of compile-time type assertions for custom field selection
    • Removed unused imports (expectType, TypeEqual)
    • Kept only runtime assertion logic
  • New fixture file: packages/envio-tests/test/helpers/FuelAbiFixtures.res

    • Provides a known-good Fuel greeter ABI for type testing

Implementation Details

The new test file uses a pattern where check functions validate TypeScript code snippets against generated types:

  • check() for EVM configurations
  • checkFuel() for Fuel configurations with virtual ABI files
  • checkSvm() for SVM configurations

Each test case is a self-contained TypeScript snippet that exercises a specific API surface, with @ts-expect-error comments documenting type safety guarantees. This approach keeps type assertions close to the API they validate while remaining independent of runtime test execution.

https://claude.ai/code/session_01N8ssQQn6qQ2WMKCTci7iGJ

Summary by CodeRabbit

  • Tests
    • Added comprehensive compile-time coverage for EVM, Fuel, and SVM TypeScript APIs.
    • Added fixtures for Fuel ABI and shared GraphQL schema types.
    • Expanded validation of event handlers, registration options, filters, entities, enums, and effect utilities.
    • Updated runtime expectations for simulated event results.
    • Removed redundant type-check assertions from existing handler tests.

claude added 2 commits July 23, 2026 15:08
The public TypeScript API's type-surface assertions (EvmEvent narrowing,
onEvent/contractRegister option/handler/context shapes, custom field
selection, Entity/Enum lookups, the onBlock surface, and the registration
guards) were scattered across scenario test files and handler source,
coupled to the test_codegen config.

Move the self-contained checks into
packages/envio-tests/test/TypeScriptApiTypes_test.res, which drives the
TS compiler over handler snippets via InternalTestIndexer.fromUserApi
against a small purpose-built mock config. Delete the migrated checks
from EventHandler.test.ts (four type-only describe blocks + the EvmEvent
type block), CustomSelection.test.ts (custom-selection assertions), and
EventHandlers.ts (the if(0) registration block and the where.block type
guard). Runtime value tests and inline handler-body type asserts stay put.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N8ssQQn6qQ2WMKCTci7iGJ
The consolidated type-surface test only covered EVM, leaving nearly every
exposed Fuel and SVM type untested at the type level. Drive the same
InternalTestIndexer.fromUserApi harness over Fuel and SVM mock configs:

- Fuel: a small mock backed by a real Sway greeter ABI (fixture) covers
  FuelChainId/Name, FuelContractName, FuelEvent (+ height/id/time block,
  Fuel transaction), the onEvent/contractRegister option/handler/context
  types, the onBlock/where surface keyed on block.height, and the indexer
  registration guards (including block.number rejection).
- SVM: an inline program/instruction mock covers SvmChainId/Name, the
  onSlot surface, the config-independent instruction named types
  (SvmInstruction, SvmInstructionParams/Block, SvmLog, SvmTokenBalance),
  SvmTransaction field selection, and onInstruction option/handler with
  args/accounts narrowing.

Also close remaining EVM gaps: Effect/EffectOptions/RateLimit, getWhere
filters, the dynamic where callback (EvmOnEventWhereChain/Args/Filter and
indexed-param where.params narrowing), SingleOrMultiple, Logger, and the
Indexer/TestIndexer/TestHelpers instance surface. 86/90 exposed symbols
are now referenced; the remaining four (Global, Prettify, and the
IndexerFromConfig/TestIndexerFromConfig generics behind the Indexer/
TestIndexer aliases) are internal or exercised transitively.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N8ssQQn6qQ2WMKCTci7iGJ
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d913619a-5076-4265-a5de-405e95958950

📥 Commits

Reviewing files that changed from the base of the PR and between 657131b and a7ea38b.

📒 Files selected for processing (5)
  • packages/envio-tests/test/EvmHandlersApi_test.res
  • packages/envio-tests/test/FuelHandlersApi_test.res
  • packages/envio-tests/test/SvmHandlersApi_test.res
  • scenarios/test_codegen/src/handlers/EventHandlers.ts
  • scenarios/test_codegen/test/EventHandler.test.ts
📝 Walkthrough

Walkthrough

Adds comprehensive TypeScript API type tests for EVM, Fuel, and SVM configurations, introduces shared schema and Fuel ABI fixtures, and moves compile-time checks out of runtime-oriented tests.

Changes

TypeScript API type coverage

Layer / File(s) Summary
Harness and EVM API coverage
packages/envio-tests/test/helpers/ApiTypesFixtures.res, packages/envio-tests/test/TypeScriptApiTypesEvm_test.res
Adds shared schema/configuration fixtures and compile-time assertions for EVM APIs, entity bindings, effects, filters, handlers, and utilities.
Fuel API coverage
packages/envio-tests/test/helpers/FuelAbiFixtures.res, packages/envio-tests/test/TypeScriptApiTypesFuel_test.res
Adds a Greeter ABI fixture and validates Fuel event, handler, filter, registration, and schema-bound types.
SVM, effect, and utility coverage
packages/envio-tests/test/TypeScriptApiTypesSvm_test.res
Validates SVM chain, slot, instruction, registration, field-selection, and schema-bound types.
Legacy check migration and runtime alignment
scenarios/test_codegen/src/handlers/EventHandlers.ts, scenarios/test_codegen/test/CustomSelection.test.ts, scenarios/test_codegen/test/EventHandler.test.ts
Removes duplicated unreachable type checks, updates the custom-selection reference, simplifies runtime-test imports, and aligns imported types and simulation expectations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: consolidating TypeScript API type assertions into dedicated ecosystem-specific tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

Split the single TypeScriptApiTypes_test.res into per-ecosystem files
(EVM/Fuel/SVM), each with its own mock config and a shared schema fixture
(helpers/ApiTypesFixtures.res). The EVM file keeps the ecosystem-agnostic
Effect/utility block.

Deepen Fuel and SVM so every exposed type of each ecosystem is asserted:
- Fuel: decoded Sway struct params (NewGreeting/ClearGreeting), the
  contractRegister context's absence of entity ops, the dynamic where
  callback form, and schema-bound Entity/Enum under a Fuel config.
- SVM: instruction extras (instructionAddress, d1/d8, logs), the
  FieldNotSelected sentinel on unselected SvmTransaction fields, the
  onSlot context entity getter, a bad-instruction-name negative, and
  schema-bound Entity/Enum under an SVM config.

All 22 Fuel and 18 SVM exposed types are now covered (86/90 overall; the
remaining Global/Prettify/IndexerFromConfig/TestIndexerFromConfig are
internal or exercised transitively via the Indexer/TestIndexer aliases).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N8ssQQn6qQ2WMKCTci7iGJ
@DZakh
DZakh enabled auto-merge (squash) July 24, 2026 11:44
@DZakh
DZakh merged commit 59b75d5 into main Jul 24, 2026
7 of 8 checks passed
@DZakh
DZakh deleted the claude/typescript-types-test-refactor-8hyozt branch July 24, 2026 11:47
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