Repository navigation
core: compare theme variants as an unordered set in assertTheme - #183
Merged
Merged
Conversation
Flow serializes every applied theme variant into a single `theme`
attribute in an order it controls, not the order the variants were
added, so a whole-string match flips whenever that order changes:
addThemeVariants(LUMO_PRIMARY, LUMO_SMALL) renders as `primary small`,
failing assertTheme("small primary").
assertTheme now builds a pattern with one anchored lookahead per
expected variant plus a token count, so the variants may come in any
order while an extra unexpected variant still fails. Playwright's
auto-retry is unchanged — it is still a hasAttribute(name, Pattern)
assertion. The hand-rolled metacharacter escaping is shared with the
single-variant pattern.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
assertTheme(...)matched the wholethemeattribute as a raw string. Flow serializes every applied theme variant into that single attribute in an order it controls — not the order the variants were added — so the match is brittle:button.addThemeVariants(LUMO_PRIMARY, LUMO_SMALL)renders assmall primaryon Vaadin 25.3.0-beta1 and asprimary smallon 25.3.0-rc1, breakingButtonViewIT.testHasThemeVariant. This PR is what unblocks the rc1 bump in #184.Fix
assertThemecompares the variants as an unordered set: it builds a pattern with one anchored lookahead per expected variant plus a token count, soassertTheme("small primary")andassertTheme("primary small")both pass,hasAttribute(name, Pattern).The hand-rolled metacharacter escaping (Playwright compiles patterns into a JS
RegExp, which does not understandPattern.quote's\Q...\E) is factored into a sharedescape()helper used by both the set pattern and the existing single-variant pattern.assertHasThemeVariant/assertHasNoThemeVariantare unchanged.Also updated: the "Theme Variant Order" pitfall in
AGENTS.md, theBadgeElement.mdspec wording, the regeneratedapi-reference.md, andButtonViewIT, which now asserts both orderings.Testing
mvn verifyon the current beta1: 717 tests, 0 failures. On rc1 (i.e. with #184 applied): 717 tests, 0 failures.🤖 Generated with Claude Code