Consolidate TypeScript API type tests into dedicated test file - #1480
Conversation
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
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds 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. ChangesTypeScript API type coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
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
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N8ssQQn6qQ2WMKCTci7iGJ
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)Removed from
EventHandler.test.ts:EvmEvent,EvmOnEventOptions,EvmContractRegisterOptions,EvmOnEventHandler,EvmContractRegisterHandler,EvmOnEventContext,EvmContractRegisterContext,EvmOnBlockWhereResult,EvmOnBlockFilter,EvmOnBlockOptions,EvmOnBlockContext,EvmOnBlockHandler,EvmOnBlockHandlerArgs,EvmOnBlockWhereArgsRemoved from
EventHandlers.ts:if (0))_typeCheckEvmWhereBlockShape()function with block filter type assertionsRemoved from
CustomSelection.test.ts:expectType,TypeEqual)New fixture file:
packages/envio-tests/test/helpers/FuelAbiFixtures.resImplementation Details
The new test file uses a pattern where
checkfunctions validate TypeScript code snippets against generated types:check()for EVM configurationscheckFuel()for Fuel configurations with virtual ABI filescheckSvm()for SVM configurationsEach test case is a self-contained TypeScript snippet that exercises a specific API surface, with
@ts-expect-errorcomments 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