Skip to content

test: add Playwright coverage and test ids for CpsFileUploadComponent - #793

Open
fateeand wants to merge 3 commits into
masterfrom
781-cover-file-upload-component-with-playwright-tests
Open

test: add Playwright coverage and test ids for CpsFileUploadComponent#793
fateeand wants to merge 3 commits into
masterfrom
781-cover-file-upload-component-with-playwright-tests

Conversation

@fateeand

Copy link
Copy Markdown
Collaborator

Summary

  • Added Playwright E2E coverage for CpsFileUploadComponent. The spec covers: real file selection through the actual hidden <input type="file"> (via setInputFiles(), the reliable substitute for an OS file picker - the existing Jest test only proved the synthetic drop-event path, never the change-event/file-input path real users on file-picker click actually use); real extension validation rejecting a mismatched file with a real error box and aria-live announcement; the real dragged-over visual state toggling on real dragenter/dragleave; the disabled dropzone (a native <button disabled>) genuinely blocking real pointer interaction; real focus restoration to the dropzone after removing an uploaded file; and the real async fileProcessingCallback pipeline actually reaching completion (progress bar visible and dropzone non-interactive while a real 3-second-delayed Observable is in flight, then the real success outcome landing after it resolves) and a real cancel genuinely stopping a pending operation well before that delay would have elapsed, proving takeUntil(cancelProcessing$) actually works, not just that a state flag flips.
  • Added data-testid attributes to the library component's template (root, dropzone and its title/file-desc/info-content, hidden file input, error box and its text, uploaded-files wrapper, uploaded-file row/title/status-icon/name, remove/cancel buttons, progress bar) so consumer apps have stable selectors for their own tests.
  • Added a "File upload component with a failing processing callback" example (processFailingUploadedFile, resolves false after a short delay) - the demo's only other fileProcessingCallback always succeeds, so the failure branch (errorMessage = 'File processing failed', fileProcessingFailed output, auto-removal of the file) was completely untested and unshowcased. Added a matching Playwright test proving the real failure outcome.
  • Expanded cps-file-upload.component.spec.ts (3 -> 37 tests) to cover everything logic-level that doesn't need a real browser.

TODO: Merge with feat: add test ids to file upload component to generate a release


Release notes:

  • added Playwright E2E coverage for cps-file-upload component
  • added test ids to cps-file-upload component

Copilot AI review requested due to automatic review settings July 29, 2026 14:15
@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 77.85% 6267/8050
🟡 Branches 66.98% 2889/4313
🟡 Functions 79.61% 1183/1486
🟡 Lines 78.83% 5859/7432

Test suite run success

2472 tests passing in 76 suites.

Report generated by 🧪jest coverage report action from 96f4883

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

Adds comprehensive automated coverage and stable selectors around CpsFileUploadComponent to validate real-user flows (native file input, drag/drop states, async processing, cancellation, and failure paths) across both unit tests and Playwright E2E.

Changes:

  • Greatly expands the component’s unit test suite to cover extension validation, drag state, focus restoration, cancel/remove flows, and the async fileProcessingCallback pipeline.
  • Adds data-testid attributes to CpsFileUploadComponent template for stable E2E/consumer selectors.
  • Adds a new “failing processing callback” composition example and introduces Playwright E2E coverage for real browser behavior.

Reviewed changes

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

Show a summary per file
File Description
projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.spec.ts Expands Jest coverage to validate key logic paths (validation, drag state, focus, processing success/failure/cancel).
projects/cps-ui-kit/src/lib/components/cps-file-upload/cps-file-upload.component.html Adds data-testid hooks across the template for stable E2E selectors.
projects/composition/src/app/pages/file-upload-page/file-upload-page.examples.ts Adds a new example demonstrating a failing fileProcessingCallback.
projects/composition/src/app/pages/file-upload-page/file-upload-page.component.ts Implements processFailingUploadedFile() used by the new composition example.
projects/composition/src/app/pages/file-upload-page/file-upload-page.component.html Adds test ids for specific composition examples and renders the new failing-processing example.
playwright/cps-ui-kit/components/cps-file-upload.spec.ts Adds Playwright E2E tests for real file input selection, validation, drag UI, disabled behavior, focus restoration, async processing, cancel, and failure outcomes.

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

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Playwright test results

passed  424 passed

Details

stats  424 tests across 13 suites
duration  14 minutes, 14 seconds
commit  96f4883
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 File Upload component with Playwright tests

2 participants