feat(plugin-e2e): add missing components to the components fixture#2621
feat(plugin-e2e): add missing components to the components fixture#2621mckn wants to merge 8 commits into
Conversation
|
Marcus Andersson seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
Adds additional Grafana UI component wrappers to the components fixture in @grafana/plugin-e2e so tests can interact with common controls (Select, MultiSelect, Switch, RadioGroup, UnitPicker, ColorPicker) on arbitrary pages, using within(root) scoping similar to existing dataSourcePicker and timeRangePicker.
Changes:
- Add
getContainer()+within(root)support for six component models (Select, MultiSelect, Switch, RadioGroup, UnitPicker, ColorPicker). - Extend
Componentsfixture to expose these components and export them from the package public API. - Add e2e coverage for the new fixture entries (except MultiSelect, per PR notes).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-e2e/tests/as-admin-user/components/components.spec.ts | Adds e2e tests validating new components.*.within(...) helpers. |
| packages/plugin-e2e/src/models/components/UnitPicker.ts | Adds getContainer() + within() for UnitPicker scoping. |
| packages/plugin-e2e/src/models/components/Switch.ts | Adds version-conditional getContainer() + within() for Switch scoping. |
| packages/plugin-e2e/src/models/components/Select.ts | Adds getContainer() + within() for Select scoping. |
| packages/plugin-e2e/src/models/components/RadioGroup.ts | Adds version-conditional getContainer() + within() for RadioGroup scoping. |
| packages/plugin-e2e/src/models/components/MultiSelect.ts | Adds getContainer() + within() for MultiSelect scoping. |
| packages/plugin-e2e/src/models/components/ColorPicker.ts | Adds getContainer() + within() for ColorPicker scoping. |
| packages/plugin-e2e/src/models/Components.ts | Adds new component instances to the components fixture. |
| packages/plugin-e2e/src/index.ts | Exports the new component classes from the public API. |
17846f8 to
850a184
Compare
80752bf to
0e80786
Compare
eb99aae to
38d9b01
Compare
7ebd852 to
75fd524
Compare
367d123 to
8afe4ba
Compare
…and ColorPicker to components fixture Extends the components fixture introduced in #2583 with six additional Grafana UI components. Each component gets a static getContainer() for version-conditional container resolution and a within(root) method for DOM scoping. Uses CSS/structural fallback selectors for all Grafana versions; data-testid selectors will be added once grafana/grafana#124120 merges and @grafana/e2e-selectors is updated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
selectOption() and toHaveColor() both expect the element to be a parent container that wraps the swatch button, not the swatch itself. The colorswatch data-testid lives on the swatch element, so we traverse up one level to match the expected scope. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The toHaveSelected matcher uses CSS descendant queries that start from the value container class (e.g. div[class*="-grafana-select-value-container"]). Since Playwright's locator() searches descendants only, the element must be a parent that *contains* the value container, not the container itself. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Broad container selectors can match multiple elements on a page. Adding .first() prevents Playwright strict-mode errors when consumers use the unscoped component instance. When scoped via within(root), the root typically narrows to a single match so .first() is harmless. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ColorPicker: Pass root directly as element when within(root) is used. The swatch parent is too deep for toHaveColor() which expects the field-level container containing both the swatch button and color value input. This matches PanelEditOptionsGroup.getColorPicker() behavior. RadioGroup: Broaden the < 10.0 fallback selector to also match radio inputs as direct children (not just nested). The clock panel uses direct children with custom name attributes, not the Grafana core name="radiogroup-N" pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bumps @grafana/e2e-selectors to 13.1.0-25893932881 which includes the new stable container data-testids from grafana/grafana#124120. Each getContainer() now uses the data-testid selector for >= 13.1.0 and falls back to CSS/structural selectors for older versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The data-testid Select/MultiSelect container attribute is placed on the value container element itself. The toHaveSelected matcher uses a CSS descendant query starting from that class, so the element must be a parent. Add xpath=.. traversal for the data-testid path, matching the CSS class fallback approach. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8afe4ba to
5d83023
Compare
Playwright test results
Troubleshooting404 when clicking on
|
What this PR does / why we need it:
Follow-up to #2583. Adds six more Grafana UI components to the
componentsfixture: Select, MultiSelect, Switch, RadioGroup, UnitPicker, and ColorPicker. Each component gets astatic getContainer()method for version-conditional container resolution and awithin(root)method for DOM scoping, matching the pattern established bydataSourcePickerandtimeRangePicker.Uses CSS/structural fallback selectors that work across all supported Grafana versions (8.5+). Once grafana/grafana#124120 merges and
@grafana/e2e-selectorsis updated, a follow-up will adddata-testidcontainer selectors for Grafana >= 13.1.0. The six component classes are also now exported from the package public API.Which issue(s) this PR fixes:
Follows up on #2583 and depends on grafana/grafana#124120 for stable container selectors.
Special notes for your reviewer:
switchis used as a property name on theComponentsclass. It's a JS reserved word but valid as a property name in ES6+ class definitions.[class*="-grafana-select-value-container"]) rely on Grafana's Emotion-generated class naming convention and will be replaced by stabledata-testidselectors in a follow-up.📦 Published PR as canary version:
Canary Versions✨ Test out this PR locally via:
npm install @grafana/plugin-docs-cli@0.1.0-canary.2621.26576348885.0 npm install @grafana/plugin-docs-parser@0.1.0-canary.2621.26576348885.0 npm install @grafana/plugin-e2e@3.9.0-canary.2621.26576348885.0 # or yarn add @grafana/plugin-docs-cli@0.1.0-canary.2621.26576348885.0 yarn add @grafana/plugin-docs-parser@0.1.0-canary.2621.26576348885.0 yarn add @grafana/plugin-e2e@3.9.0-canary.2621.26576348885.0