-
Notifications
You must be signed in to change notification settings - Fork 174
Initial UI tests #4794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Initial UI tests #4794
Conversation
* Initial UI tests * Move to shared mocks * Fix failing tests * fix costs tag * fix costs test failures * fix(ui): resolve test failures in App.test.tsx - Updated the MSAL mock in `App.test.tsx` to use a class-based mock, resolving the `TypeError: ... is not a constructor` error. - Wrapped asynchronous operations in `act()` in `ConfirmCopyUrlToClipboard.test.tsx`, `ConfirmDisableEnableResource.test.tsx`, `GenericErrorBoundary.test.tsx`, and `SecuredByRole.test.tsx` to fix warnings and ensure proper state updates. * fix(ui): resolve test failures in App.test.tsx - Updated the MSAL mock in `App.test.tsx` to use a class-based mock, resolving the `TypeError: ... is not a constructor` error. - Wrapped asynchronous operations in `act()` in `ResourceCard.test.tsx` to fix warnings and ensure proper state updates. * fix(ui): resolve test failures and act warnings - Updated the MSAL mock in `App.test.tsx` to use a class-based mock, resolving the `TypeError: ... is not a constructor` error. - Wrapped asynchronous operations in `act()` in `ResourceCard.test.tsx`, `ExceptionLayout.test.tsx`, and `ConfirmDeleteResource.test.tsx` to fix warnings and ensure proper state updates. * fix tests * fix warnings --------- Co-authored-by: Marcus Robinson <[email protected]> Co-authored-by: James Griffin <[email protected]> Co-authored-by: James Chapman <[email protected]> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Unit Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 3434019. ♻️ This comment has been updated with latest results. |
|
@marrobi I am not able to test the workflow |
marrobi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
There was a problem hiding this comment.
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 introduces comprehensive UI testing infrastructure for the Azure TRE UI using Vitest and React Testing Library. The implementation includes test utilities, component tests, and CI/CD integration to ensure code quality and maintainability.
Changes:
- Implements Vitest testing framework with 80% coverage thresholds for branches, functions, lines, and statements
- Creates reusable test utilities and FluentUI mocks to simplify test authoring
- Adds 27 test files covering core components, hooks, and models with 241 passing tests
- Fixes bugs discovered during testing (optional chaining issues in Footer, CostsTag, and missing React keys in CliCommand)
- Adds comprehensive documentation and GitHub Actions workflows for automated testing
Reviewed changes
Copilot reviewed 43 out of 45 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Adds Vitest configuration with coverage thresholds and exclusions |
| setupTests.ts | Configures global test environment, mocks browser APIs, and initializes FluentUI |
| test-utils/ | Provides reusable test utilities, FluentUI mocks, and common test data |
| **/*.test.tsx | Component and hook test files with comprehensive coverage |
| Footer.tsx | Fixes optional chaining for health.services to prevent undefined errors |
| CostsTag.tsx | Adds optional chaining for costs arrays and fixes shimmer loading logic |
| CliCommand.tsx | Adds missing React key prop to mapped elements |
| docs/tre-developers/ui-testing.md | New comprehensive testing documentation |
| .github/workflows/ui_tests.yml | GitHub Actions workflow for running tests on PR/push |
| .github/workflows/ui_test_results.yml | Workflow for publishing test results from forks |
| CHANGELOG.md | Documents the new UI testing feature |
| package.json | Bumps version to 0.8.21 and adds @vitest/ui dependency |
Files not reviewed (1)
- ui/app/package-lock.json: Language not supported
Resolves #4785 #3869
What is being addressed
There is currently no testing of the TRE UI
Testing showed a couple of ui issues which have also been fixed
How is this addressed