test: add Playwright coverage and test ids for CpsTooltipDirective - #841
test: add Playwright coverage and test ids for CpsTooltipDirective#841fateeand wants to merge 3 commits into
Conversation
Coverage report for library
Test suite run success2474 tests passing in 76 suites. Report generated by 🧪jest coverage report action from 087072c |
There was a problem hiding this comment.
Pull request overview
This PR expands automated coverage and improves testability for CpsTooltipDirective by adding Playwright E2E tests and stable selectors (data-testid) on the dynamically created tooltip DOM, plus composition examples to exercise previously under-covered inputs.
Changes:
- Added
data-testidattributes to the tooltip popup container and content nodes created byCpsTooltipDirective. - Updated unit tests to reflect the new tooltip content markup.
- Added new tooltip examples in the composition app and introduced a new Playwright E2E spec covering multiple real interaction modes and behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/cps-ui-kit/src/lib/directives/cps-tooltip/cps-tooltip.directive.ts | Adds data-testid attributes to the tooltip popup and its content for stable E2E selection. |
| projects/cps-ui-kit/src/lib/directives/cps-tooltip/cps-tooltip.directive.spec.ts | Updates assertions to account for the new tooltip content attributes. |
| projects/composition/src/app/pages/tooltip-page/tooltip-page.examples.ts | Adds new composition examples demonstrating focus-only trigger and custom offset/max-width. |
| projects/composition/src/app/pages/tooltip-page/tooltip-page.component.html | Adds data-testid hooks and renders the new examples on the tooltip docs page. |
| playwright/cps-ui-kit/directives/cps-tooltip.spec.ts | Introduces new Playwright E2E coverage for tooltip behaviors (trigger modes, delays, sizing, offset, teardown, aria-live). |
Suppressed comments (1)
projects/cps-ui-kit/src/lib/directives/cps-tooltip/cps-tooltip.directive.spec.ts:109
- Avoid asserting exact
innerHTMLstrings for tooltip content; this is brittle due to DOM serialization differences (e.g., attribute ordering). Assert on the content element, itsdata-testid, and the presence of the expected HTML instead.
expect(tooltipElement).toBeTruthy();
expect(tooltipElement?.innerHTML).toBe(
'<div class="cps-tooltip-content" data-testid="cps-tooltip-content"><h1>Legit tooltip</h1></div>'
);
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Playwright test resultsDetails
Flaky testswebkit › cps-ui-kit/components/cps-info-circle.spec.ts › cps-info-circle › Real Tab-trapping into persistent tooltip content › tabbing from the icon moves focus into the tooltip real focusable content |
Summary
tooltipDisabledrenders nothing,tooltipMaxWidthenforcement,tooltipOffsetdistance, click-triggeraria-liveannounce, destroy-on-scroll and destroy-on-resize.cps-tooltip,cps-tooltip-content).@Inputgaps: "Open on focus only" (tooltipOpenOn="focus") and "Custom offset and max width" (tooltipOffset,tooltipMaxWidth).TODO: Merge with
feat: add test ids to tooltip directiveRelease notes: