Skip to content

Conversation

@JC-wk
Copy link
Collaborator

@JC-wk JC-wk commented Dec 19, 2025

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

  • Creates Initial UI tests using vitest
  • Fixed components with issues which were reported by the tests.
  • Update documentation
  • Updated CHANGELOG.md
  • Incremented UI version
  • Added github workflows to run vitest and report results as pr comments <-- not able to fully test till it's in main (see comment)
yarn test:coverage
Test Files  27 passed (27)
      Tests  241 passed (241)
   Start at  10:24:37
   Duration  35.72s (transform 9.79s, setup 4.75s, collect 35.84s, tests 31.91s, environment 17.82s, prepare 2.18s)

 % Coverage report from v8
-------------------------------------|---------|----------|---------|---------|----------------------------------
File                                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                
-------------------------------------|---------|----------|---------|---------|----------------------------------
All files                            |   82.13 |    68.15 |   63.52 |   83.87 |                                  
 src                                 |   64.28 |      100 |   28.57 |   62.96 |                                  
  App.scss                           |       0 |        0 |       0 |       0 |                                  
  App.tsx                            |   64.28 |      100 |   28.57 |   62.96 | 59,82-142                        
 src/components/shared               |   91.86 |    80.81 |   81.11 |   91.76 |                                  
  CliCommand.tsx                     |      90 |     87.5 |   83.33 |      90 | 23,33                            
  ComplexItemDisplay.tsx             |    92.3 |      100 |   85.71 |    92.3 | 29                               
  ConfirmCopyUrlToClipboard.tsx      |    92.3 |      100 |      80 |    92.3 | 46                               
  ConfirmDeleteResource.tsx          |     100 |      100 |     100 |     100 |                                  
  ConfirmDisableEnableResource.tsx   |      92 |      100 |   66.66 |      92 | 93-102                           
  ConfirmUpgradeResource.tsx         |   97.05 |     87.5 |      80 |   96.96 | 123                              
  CostsTag.tsx                       |   93.54 |    95.23 |     100 |   93.54 | 58,87                            
  ErrorPanel.tsx                     |     100 |      100 |     100 |     100 |                                  
  ExceptionLayout.tsx                |     100 |    77.77 |     100 |     100 | 20                               
  Footer.tsx                         |   95.23 |       50 |   85.71 |   95.23 | 67                               
  GenericErrorBoundary.tsx           |     100 |      100 |     100 |     100 |                                  
  PowerStateBadge.tsx                |     100 |      100 |     100 |     100 |                                  
  ResourceBody.tsx                   |     100 |       75 |     100 |     100 | 54                               
  ResourceCard.tsx                   |   75.86 |     65.3 |      50 |   75.43 | 59-62,69-75,80-86,266-283        
  ResourceHeader.tsx                 |     100 |       75 |     100 |     100 | 55                               
  SecuredByRole.tsx                  |      95 |    89.47 |   83.33 |      95 | 49                               
  SharedServiceItem.tsx              |   90.47 |      100 |      60 |   90.47 | 31-32                            
  StatusBadge.tsx                    |     100 |    83.33 |     100 |     100 | 65                               
  TopNav.tsx                         |     100 |       50 |     100 |     100 | 23                               
  UserMenu.tsx                       |     100 |      100 |     100 |     100 |                                  
 src/components/shared/notifications |      25 |        0 |       0 |      25 |                                  
  operationsSlice.ts                 |      25 |        0 |       0 |      25 | 19-34                            
 src/contexts                        |     100 |      100 |       0 |     100 |                                  
  AppRolesContext.ts                 |     100 |      100 |       0 |     100 |                                  
  CostsContext.ts                    |     100 |      100 |       0 |     100 |                                  
  CreateUpdateResourceContext.ts     |     100 |      100 |       0 |     100 |                                  
  WorkspaceContext.ts                |     100 |      100 |       0 |     100 |                                  
 src/hooks                           |   72.72 |    56.66 |   81.81 |    73.4 |                                  
  customReduxHooks.ts                |     100 |      100 |     100 |     100 |                                  
  useAuthApiCall.ts                  |   84.84 |    74.35 |     100 |   84.12 | 90-91,130-134,159-161            
  useComponentManager.ts             |   45.16 |     23.8 |   66.66 |   48.27 | 44,47-84                         
 src/models                          |      68 |        0 |      50 |   80.95 |                                  
  apiEndpoints.ts                    |     100 |      100 |     100 |     100 |                                  
  exceptions.ts                      |     100 |      100 |     100 |     100 |                                  
  loadingState.ts                    |     100 |      100 |     100 |     100 |                                  
  operation.ts                       |     100 |      100 |     100 |     100 |                                  
  resource.ts                        |   27.27 |        0 |       0 |   42.85 | 61-64                            
  resourceType.ts                    |     100 |      100 |     100 |     100 |                                  
  roleNames.ts                       |     100 |      100 |     100 |     100 |                                  
 src/test-utils                      |   71.95 |    58.57 |   51.21 |   79.16 |                                  
  common-mocks.tsx                   |   47.36 |     7.14 |      15 |   58.62 | ...5,113-115,144,157-168,188-192 
  fluentui-mocks.tsx                 |   89.28 |    65.21 |   82.35 |   88.88 | 247,410,575                      
  index.tsx                          |     100 |      100 |     100 |     100 |                                  
-------------------------------------|---------|----------|---------|---------|----------------------------------

* 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 <marrobi@microsoft.com>
Co-authored-by: James Griffin <me@JamesGriff.in>
Co-authored-by: James Chapman <james.chapman@necsu.onmicrosoft.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@JC-wk JC-wk requested a review from a team as a code owner December 19, 2025 10:00
@github-actions
Copy link

github-actions bot commented Dec 19, 2025

Unit Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 05e312e.

♻️ This comment has been updated with latest results.

@JC-wk
Copy link
Collaborator Author

JC-wk commented Dec 19, 2025

@marrobi I am not able to test the workflow /workspaces/AzureTRE/.github/workflows/ui_test_results.yml because it does not exist on the main branch, but it should submit a comment with the code coverage summary if that is something we want. It would also publish a comment with the vitest results.
I couldn't find a way to cleanly incorporate this in .github/workflows/test_results.yml since it runs before the tests complete.

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.

npm test failures (jest is not defined)

1 participant