Repository navigation
test(extractor): lock sibling dynamic-as with props object (Prime regression) - #894
Draft
devfive-relay-c70423[bot] wants to merge 1 commit into
Conversation
…ression)
@devup-ui/wasm 1.0.78 - 1.0.81 wrote a file with two or more sibling
elements that take a non-literal `as` back as code that no longer parsed,
for example
<Center as={Link} props={{ href: '/privacy' }}>Privacy</Center>
<Text as={Link} props={{ href: '/terms' }}>Terms</Text>
#681 (4586885) fixed it by replacing such an element where it stands. The
tests of that change cover one dynamic `as` per parent and no `props`
object, so this shape was not locked.
- extractor: 11 files of that shape, with and without a source map. The
extracted code must parse as TSX without diagnostics, leave no component,
`as` or `props`, keep every href on its own element in source order, and
match a snapshot. 20 of the 22 cases fail on the parent of 4586885.
- wasm: the reported file through the functions `codeExtract` and
`codeExtractWithoutSourceMap` call, compared with the whole expected code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tests only. Locks the file shape that
@devup-ui/wasm1.0.78 – 1.0.81 wrote back as code that no longer parsed (reported from Prime, case 009). No source change: the defect is already fixed onmainby #681 (4586885), and I found no remaining defect.Repro
Two or more sibling elements in one file, each with a non-literal
as:@devup-ui/wasm1.0.78 – 1.0.81. The second element with a dynamicaswas placed where an earlier one stood, so the output had a syntax error (or kept a component that throws at runtime).asis replaced where it stands.main:Why new tests
The tests of #681 (
test_dynamic_as_where_the_element_stands,test_dynamic_as_elements,test_spreads_are_read_once) have one dynamicasper parent and nopropsobject, so this exact shape was not covered.What the tests assert
libs/extractor/src/dynamic_as_sibling_props_tests.rs— 11 files × with/without source map = 22 cases: two siblings (the report), self-closing siblings, three siblings with style props, siblings in a fragment, siblings of a plain element, nested dynamicas, conditionalas, URLs with/,?,#and more props, siblings in a list, two components in one file, memberasin an attribute.For each case the extracted code must:
as/propsattribute;hrefon its own element, in source order (read from the parsed AST, not matched as text);Checked against the parent of 4586885: 18 of the 22 cases fail there — 14 with
extracted code has syntax errors, 2 with a Devup component left in the output, 2 with anhreflost. The other two files (conditionalas, two components in one file) already compiled correctly before the fix and are kept as neighbours of the shape.bindings/devup-ui-wasm/src/dynamic_as_sibling_props_tests.rs— the reported file throughcode_extract_internalandcode_extract_without_source_map_internal, the functions thecodeExtractandcodeExtractWithoutSourceMapexports call (2 cases). The whole output is compared with the expected code.Checks
cargo test -p extractor -p devup-ui-wasm --lib dynamic_as_sibling— 24 passedcargo fmt --all -- --checkclean;cargo clippy --all-targets --all-features -- -D warningsreports nothing in the new fileslibs/**andbindings/devup-ui-wasm/src/**change, which.changepacks/config.jsonignores🤖 Generated with Claude Code
Submitted via Devfive hub. Employee: ; device:
3099154426bffbeef8b62999b80bb038