test: add Playwright coverage and test ids for CpsFileUploadComponent - #793
Open
fateeand wants to merge 3 commits into
Open
test: add Playwright coverage and test ids for CpsFileUploadComponent#793fateeand wants to merge 3 commits into
fateeand wants to merge 3 commits into
Conversation
fateeand
requested review from
TerranceKhumalo-absa,
korel-san and
lukasmatta
as code owners
July 29, 2026 14:15
Contributor
Coverage report for library
Test suite run success2472 tests passing in 76 suites. Report generated by 🧪jest coverage report action from 96f4883 |
Contributor
There was a problem hiding this comment.
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
fileProcessingCallbackpipeline. - Adds
data-testidattributes toCpsFileUploadComponenttemplate 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. |
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
CpsFileUploadComponent. The spec covers: real file selection through the actual hidden<input type="file">(viasetInputFiles(), the reliable substitute for an OS file picker - the existing Jest test only proved the syntheticdrop-event path, never thechange-event/file-input path real users on file-picker click actually use); real extension validation rejecting a mismatched file with a real error box andaria-liveannouncement; the realdragged-overvisual state toggling on realdragenter/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 asyncfileProcessingCallbackpipeline 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, provingtakeUntil(cancelProcessing$)actually works, not just that a state flag flips.data-testidattributes 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.processFailingUploadedFile, resolvesfalseafter a short delay) - the demo's only otherfileProcessingCallbackalways succeeds, so the failure branch (errorMessage = 'File processing failed',fileProcessingFailedoutput, auto-removal of the file) was completely untested and unshowcased. Added a matching Playwright test proving the real failure outcome.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 componentto generate a releaseRelease notes: