test: add Playwright coverage and test ids for CpsInputComponent - #814
Open
fateeand wants to merge 1 commit into
Open
test: add Playwright coverage and test ids for CpsInputComponent#814fateeand wants to merge 1 commit into
fateeand wants to merge 1 commit into
Conversation
fateeand
requested review from
TerranceKhumalo-absa,
korel-san and
lukasmatta
as code owners
July 30, 2026 12:49
Contributor
Coverage report for library
Test suite run success2438 tests passing in 76 suites. Report generated by 🧪jest coverage report action from 6875e52 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves end-to-end testability and real-browser verification for CpsInputComponent by adding stable data-testid hooks, extending the composition input page with new examples, and introducing Playwright E2E coverage that validates behaviors not reliably provable in JSDOM.
Changes:
- Added
data-testidattributes throughoutcps-input’s template to enable robust Playwright selectors. - Added new composition examples and wired them into the input composition page for demo + E2E targets.
- Introduced a new Playwright spec covering focus modality behavior, native
type="number"filtering, action-button focus retention,valueToDisplaynon-interactivity, ARIA relationships, and keyboard reachability.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.ts | Uses type-only imports for IconType/iconSizeType (no runtime import impact). |
| projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.html | Adds data-testid hooks to key internal elements (input, display input, buttons, hint/error, etc.). |
| projects/composition/src/app/pages/input-page/input-page.examples.ts | Adds 3 new documented examples used by the composition input page. |
| projects/composition/src/app/pages/input-page/input-page.component.html | Adds data-testid hooks to specific demo instances and renders the new examples. |
| playwright/cps-ui-kit/components/cps-input.spec.ts | New Playwright E2E coverage for real-browser behaviors and accessibility relationships. |
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
Added Playwright E2E coverage for
CpsInputComponentisKeyboardFocused(driving the.keyboard-focusedCSS class / visible focus ring) is set from a realmousedown-before-focusvs.Tab-only-focusevent-ordering distinction (onInputMousedown()sets a flag consumed by the very nextonFocus()) - unprovable by JSDOM's direct method calls.type="number"keystroke filtering: real browsers reject non-numeric keystrokes entirely, which JSDOM can't simulate. Found a genuinely surprising real-browser behavior while verifying this empirically:'e'is a valid number-input character (scientific notation), and typing it after an incomplete number (e.g.12->12e) doesn't just get rejected — the browser clears the entire field the moment the intermediate value becomes syntactically invalid.(mousedown)="$event.preventDefault()"specifically to stop the browser's default focus-stealing behavior when clicked - neither button's click handler (onClear()/togglePassword()) explicitly calls.focus()back, so focus retention is proof the trick works, not an assumption. Also verifiesfocus()is synchronous (nowaitForTimeoutneeded) after the clear button click, unlike the siblingfocusElement()helper elsewhere in the codebase which wraps in asetTimeout.valueToDisplaynon-interactive display input: this swaps in a second<input>with zero event handlers and harddisabled+readonly.aria-describedbyonly proves anything if it resolves to a real DOM node - Jest only regex-checks the attribute string format. Added two tests: aloadinginput'saria-describedby/hint relationship plusaria-busy+role="progressbar", and a real focus->blur cycle on an empty required field driving the component's own_checkErrors()to produce a real"Field is required"error wired intoaria-describedby- a genuine browser event sequence, not a mockedNgControl.prefixIconClicked- Angular's(keydown.enter)/(keydown.space)bindings are on the same node Jest already dispatches synthetic events against (not real-browser-exclusive), and observing the effect in the demo page means asserting on the composition page's own notification toast, which is composition-page logic, not the component's own behavior.Added test ids to the component's template.
Added three examples ("Input with a display-only formatted value", "Input with hidden hint/error details", "Unlabeled input with an accessible name").
TODO: Merge with
feat: add test ids to input componentto generate a releaseRelease notes: