Skip to content

test: add Playwright coverage and test ids for CpsIconComponent - #812

Open
fateeand wants to merge 2 commits into
masterfrom
782-cover-icon-component-with-playwright-tests
Open

test: add Playwright coverage and test ids for CpsIconComponent#812
fateeand wants to merge 2 commits into
masterfrom
782-cover-icon-component-with-playwright-tests

Conversation

@fateeand

Copy link
Copy Markdown
Collaborator

Summary

  • Added Playwright E2E coverage for CpsIconComponent. Its Jest spec already thoroughly covers the role/aria-hidden/aria-label host-attribute logic and setClasses()'s CSS-class switching - pure Angular/DOM mechanics JSDOM handles reliably. Three genuinely real-browser-only gaps remained: real color resolution (getCSSColor/isValidCSSColor, the same real-browser-sensitive mechanism already covered for CpsDividerComponent/CpsExpansionPanelComponent), Jest only checked that component.iconColor changed, never the actual resolved value; real SVG sprite-asset rendering (<use href="...icons.svg#..."> depends on an external SVG sprite resolving, which JSDOM doesn't fetch/render); and real computed size dimensions - setClasses() only applies CSS class names, and Angular component stylesheets aren't loaded into the JSDOM test environment at all, so the actual pixel dimensions from cps-icon.component.scss were unverified anywhere, not just inconveniently but literally unable to be checked in Jest.
  • Added data-testid="cps-icon" to the library template's host <i> element.
  • Added two new examples: "Icon with a custom color token" (color="error", contrasting the existing raw var(--cps-text-primary) case) and "Icons at different sizes" (xsmall/small/normal/large in a row) - both inputs had zero live example showing their non-default/non-raw-value behavior before this.

TODO: Merge with feat: add test id to icon component to generate a release


Release notes:

  • added Playwright E2E coverage for cps-icon component
  • added test id to cps-icon component

Copilot AI review requested due to automatic review settings July 29, 2026 15:23
@fateeand fateeand linked an issue Jul 29, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Coverage report for library

St.
Category Percentage Covered / Total
🟡 Statements 78.32% 6209/7928
🟡 Branches 67.88% 2864/4219
🟡 Functions 79.27% 1170/1476
🟡 Lines 79.39% 5805/7312

Test suite run success

2438 tests passing in 76 suites.

Report generated by 🧪jest coverage report action from 6bfffa6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end Playwright coverage around CpsIconComponent behaviors that are difficult/impossible to validate in JSDOM (CSS color resolution, SVG sprite rendering, and real computed sizing), and updates the composition docs page with additional icon examples and stable test selectors.

Changes:

  • Added data-testid="cps-icon" to the icon’s internal rendered <i> element for stable E2E selection.
  • Expanded the icons composition page with new “token color” and “different sizes” examples (plus minimal styling for the size row).
  • Introduced a new Playwright spec validating computed color, sprite rendering, and pixel dimensions.

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/components/cps-icon/cps-icon.component.html Adds an internal data-testid for reliable E2E targeting of the rendered icon element.
projects/composition/src/app/pages/icons-page/icons-page/icons-page.examples.ts Adds two new example snippets for token colors and size variants.
projects/composition/src/app/pages/icons-page/icons-page/icons-page.component.scss Adds layout styling for the new “different sizes” row.
projects/composition/src/app/pages/icons-page/icons-page/icons-page.component.html Wires new examples into the icons page and adds test ids used by Playwright.
playwright/cps-ui-kit/components/cps-icon.spec.ts Adds Playwright coverage for computed color, SVG sprite resolution, and real sizing.

Comment thread playwright/cps-ui-kit/components/cps-icon.spec.ts Outdated
Comment thread playwright/cps-ui-kit/components/cps-icon.spec.ts
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Playwright test results

passed  412 passed

Details

stats  412 tests across 13 suites
duration  14 minutes, 21 seconds
commit  6bfffa6
info  For details, download the Playwright report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover Icon component with Playwright tests

2 participants