Skip to content

test(transform): cover hydrate trigger validation with Angular's cases - #502

Open
Cayan wants to merge 1 commit into
voidzero-dev:mainfrom
Cayan:test-hydrate-block-validation
Open

Cayan wants to merge 1 commit into
voidzero-dev:mainfrom
Cayan:test-hydrate-block-validation

Conversation

@Cayan

@Cayan Cayan commented Sep 29, 2026

Copy link
Copy Markdown

Adds 8 tests to crates/oxc_angular_compiler/tests/r3_template_transform_test.rs, one for each hydrate validation case in Angular's packages/compiler/test/render3/r3_template_transform_spec.ts (lines 1698-1757 on angular/angular main) that had no coverage here. The conformance fixture lists these cases with empty assertions because they use toThrowError(...) / not.toThrow(), which the extractor does not handle (crates/angular_conformance/src/extractor/assertion_handlers.rs).

Each test uses the upstream template and expected message:

  • parameter on a hydrate trigger with a reference-based equivalent: Hydration trigger "interaction" cannot have parameters
  • no missing-reference error on hydrate on viewport
  • never without hydrate (also with prefetch): Unrecognized trigger
  • hydrate never followed by extra characters: Unrecognized trigger
  • hydrate never with additional blocks, with spaces, and after another block: no Unrecognized trigger
  • hydrate never before or after another hydrate trigger: Cannot specify additional `hydrate` triggers if `hydrate never` is present

Evidence:

  • All 8 pass on current main, so no validator change was needed.
  • cargo test -p oxc_angular_compiler: 2856 passed, 0 failed. cargo fmt --check is clean.
  • To check that the tests can fail, I mutated transform/control_flow.rs locally. Making is_hydrate_never_pattern always return false fails the three "no error with hydrate never" tests and the combined-trigger test. Renaming the three error messages fails the four tests that expect an error. Together the two mutations fail 7 of the 8 tests; should_not_report_missing_reference_on_hydrate_trigger is not exercised by either.

- Each test uses the template and expected error of the matching `hydrate` case in Angular's
  `r3_template_transform_spec.ts`, which the conformance fixture extracts without assertions.
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