Skip to content

test: add Playwright coverage and test ids for notifications - #824

Open
fateeand wants to merge 5 commits into
masterfrom
795-cover-notifications-component-with-playwright-tests
Open

test: add Playwright coverage and test ids for notifications#824
fateeand wants to merge 5 commits into
masterfrom
795-cover-notifications-component-with-playwright-tests

Conversation

@fateeand

@fateeand fateeand commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Added Playwright E2E coverage for CpsNotificationService's toast/notification overlay system, covering browser behavior: real document.body portal attachment, container reuse/creation across positions, real maxAmount truncation of the live DOM, real un-faked auto-dismiss timing, a real persistent (timeout: 0) notification, real hover- and keyboard-focus-driven pause/resume of the dismiss timer, real close-button removal and container teardown, real CSS animations (including prefers-reduced-motion), real aria-live announcement content/timing, real duplicate-notification suppression, and real clear() teardown across multiple containers.
  • Added a "Duplicate notification" demo example found missing during a full API audit, fixes a shared accessibility-scan fixture so it doesn't get blocked by its own accumulated toasts at mobile width.
  • Added test ids to the CpsToastComponent and CpsNotificationContainerComponent components' templates.
  • Updated CpsToastComponent/CpsNotificationContainerComponent dependency injection dropping two unused constructor params, ngClass/ngStyle -> native bindings, removing unused CommonModule imports.

TODO: Merge with feat: add test ids to notifications to generate a release


Release notes:

  • added Playwright E2E coverage for notifications
  • added test ids to notifications

@fateeand
fateeand requested a review from korel-san as a code owner August 5, 2026 10:01
Copilot AI lite review requested due to automatic review settings August 5, 2026 10:01
@fateeand fateeand linked an issue Aug 5, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Coverage report for library

St.
Category Percentage Covered / Total
🟡 Statements 77.84% 6263/8046
🟡 Branches 66.98% 2889/4313
🟡 Functions 79.61% 1183/1486
🟡 Lines 78.82% 5855/7428

Test suite run success

2474 tests passing in 76 suites.

Report generated by 🧪jest coverage report action from 7afbb16

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 improves the notification/toast system’s testability and regression protection by adding stable E2E coverage (Playwright) and introducing data-testid hooks across notification UI, plus updating the composition demo page and fixtures to support the new tests.

Changes:

  • Added Playwright E2E spec covering key notification behaviors (portal attachment, container reuse, maxAmount truncation, auto-dismiss, pause/resume, a11y announcements, clear/teardown).
  • Added data-testid attributes to toast and notification container templates to enable robust selectors in E2E tests.
  • Expanded the composition notification demo/examples (including duplicate suppression demo) and adjusted Playwright fixture setup.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
projects/cps-ui-kit/src/lib/services/cps-notification/internal/components/cps-toast/cps-toast.component.ts Switches to inject(NgZone) and removes unused module import to align with updated component dependencies.
projects/cps-ui-kit/src/lib/services/cps-notification/internal/components/cps-toast/cps-toast.component.html Adds data-testid hooks for toast elements used by Playwright selectors.
projects/cps-ui-kit/src/lib/services/cps-notification/internal/components/cps-notification-container/cps-notification-container.component.ts Cleans up DI (drops unused deps, uses inject), updates doc comment, and maintains z-index logic.
projects/cps-ui-kit/src/lib/services/cps-notification/internal/components/cps-notification-container/cps-notification-container.component.html Replaces ngClass/ngStyle with native bindings and adds data-testid hooks.
projects/composition/src/app/pages/notification-page/notification-page.examples.ts Adds a “Duplicate notification” code example to the composition page.
projects/composition/src/app/pages/notification-page/notification-page.component.ts Adds a handler method to trigger duplicate notifications for demo/test purposes.
projects/composition/src/app/pages/notification-page/notification-page.component.html Adds data-testid hooks to demo triggers and wires in the duplicate notification example.
playwright/fixtures/composition-components.ts Forces notification demo button clicks in the fixture setup to avoid interaction blockage during scans.
playwright/cps-ui-kit/components/cps-notification.spec.ts Adds comprehensive Playwright E2E coverage for notification behaviors using the new test ids.
Suppressed comments (1)

playwright/cps-ui-kit/components/cps-notification.spec.ts:143

  • Same issue as the hover test: toasts(page).first() will start pointing at the later toast once a second notification is triggered (new notifications are inserted first via unshift()). That means the focus pause/resume assertions may be checking a different toast than the one whose close button was focused.
      await trigger(page, 'timeout-warning-notification-trigger').click();
      const focusedToast = toasts(page).first();
      await expect(focusedToast).toBeVisible();
      await closeButton(focusedToast).focus();
      await expect(closeButton(focusedToast)).toBeFocused();

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

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Playwright test results

passed  538 passed

Details

stats  538 tests across 20 suites
duration  17 minutes, 10 seconds
commit  7afbb16
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 Notifications component with Playwright tests

2 participants