test: add Playwright coverage and test ids for CpsButtonToggleComponent - #776
Open
fateeand wants to merge 3 commits into
Open
test: add Playwright coverage and test ids for CpsButtonToggleComponent#776fateeand wants to merge 3 commits into
fateeand wants to merge 3 commits into
Conversation
fateeand
requested review from
TerranceKhumalo-absa,
korel-san and
lukasmatta
as code owners
July 27, 2026 12:34
Contributor
Coverage report for library
Test suite run success2386 tests passing in 76 suites. Report generated by 🧪jest coverage report action from d8c169b |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds stable data-testid hooks and Playwright E2E coverage for CpsButtonToggleComponent, and updates the composition docs page to demonstrate additional usage patterns (radioNavigation off, ariaLabel-only, reactive forms).
Changes:
- Added
data-testidattributes throughoutcps-button-toggle’s internal template to support stable selectors. - Added new composition examples + page wiring for
radioNavigation=false, aria-label without visible caption, and reactive forms integration. - Introduced a new Playwright spec covering real browser interactions, keyboard navigation, layout measurement, accessibility name behavior, and binding readouts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/cps-ui-kit/src/lib/components/cps-button-toggle/cps-button-toggle.component.html | Adds internal data-testid attributes and passes option index into templates |
| projects/composition/src/app/pages/button-toggle-page/button-toggle-page.examples.ts | Adds new example definitions for radioNavigation, ariaLabel-only, and reactive forms |
| projects/composition/src/app/pages/button-toggle-page/button-toggle-page.component.ts | Adds FormBuilder injection + reactive form instance for the new example |
| projects/composition/src/app/pages/button-toggle-page/button-toggle-page.component.html | Adds example sections and data-testid attributes used by Playwright |
| playwright/cps-ui-kit/components/cps-button-toggle.spec.ts | New Playwright E2E suite for cps-button-toggle behavior in a real browser |
Comments suppressed due to low confidence (1)
playwright/cps-ui-kit/components/cps-button-toggle.spec.ts:177
- Same issue here: if the options aren't visible yet,
boundingBox()can benulland the0fallback can invalidate the width-difference assertion. Scroll into view and assert a non-null bounding box before computing widths.
const box = await option(
page,
'icons-unequal-widths-toggle',
index
).boundingBox();
Contributor
Playwright test resultsDetails
|
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.
Summary
CpsButtonToggleComponent, covering behavior that requires a real browser and isn't exercised by the existing Jest unit suite: real click-through selection in both radio and multi-select modes, real native radiogroup arrow-key navigation, realequalWidthslayout measurement, real disabled hit-testing within a partially-enabled group, real accessible-name computation, and real two-way-binding/reactive-form readouts.data-testidattributes tocps-button-toggle's internal template (group container, group label, info circle, and per-option label/button/radio input/icon/label) so consumer apps have stable selectors for their own tests./button-toggledocs page to showcase previously-undemonstrated functionality:radioNavigation=false, a component-levelariaLabelwithout a visible caption, and reactive-forms integration (formControlName).TODO: Merge with
feat: add test ids to button toggle componentto generate a releaseRelease notes: