Skip to content

Conversation

@marrobi
Copy link
Member

@marrobi marrobi commented Jun 30, 2025

Introduce unit and component tests using Vitest and React Testing Library, enhancing testing practices and ensuring better code coverage. Update project configuration to support testing and mock necessary global objects for a seamless testing experience.

Updated copilot instruction and docs.

This is a first batch to ensure aligned on approach.

@marrobi marrobi requested a review from jjgriff93 June 30, 2025 14:18
@marrobi
Copy link
Member Author

marrobi commented Jun 30, 2025

@jjgriff93 This PR is pretty much all copilot's work. Interested in your thoughts.

@github-actions
Copy link

github-actions bot commented Jun 30, 2025

Unit Test Results

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

Results for commit 8188e81.

♻️ This comment has been updated with latest results.

@marrobi marrobi marked this pull request as draft June 30, 2025 14:21
import { ResourceType } from "../../models/resourceType";

// Mock FluentUI components
vi.mock("@fluentui/react", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of Fluent UI mocking in each individual test, can this be consolidated and re-used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a go at sorting that. What you think?

@jjgriff93
Copy link
Contributor

jjgriff93 commented Jul 5, 2025

@jjgriff93 This PR is pretty much all copilot's work. Interested in your thoughts.

@marrobi Looks like a correct setup! Using vitest over jest is my preference also. Haven't combed through every individual test but something that jumps out is there's a lot of repeat mocking that might be able to be consolidated and re-used. If you're happy with the checks it's decided to do on each component and they all make sense (the ones I skimmed through seem to) then good to go

@marrobi marrobi requested a review from Copilot July 6, 2025 16:28

This comment was marked as outdated.

@marrobi marrobi requested a review from Copilot July 7, 2025 17:00
@marrobi marrobi marked this pull request as ready for review July 7, 2025 17:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Introduce initial UI tests and supporting configuration, mocks, and utilities to establish a testing baseline using Vitest and React Testing Library.

  • Add Vitest configuration with JS DOM environment, setup files, coverage reporter, and thresholds in vite.config.ts
  • Provide shared test utilities, global mocks, and FluentUI component stubs under src/test-utils/
  • Implement global test setup in src/setupTests.ts and add initial unit/component tests for core components

Reviewed Changes

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

File Description
ui/app/vite.config.ts Configure Vitest testing, coverage, and setup files
ui/app/src/setupTests.ts Initialize global mocks (ResizeObserver, crypto)
ui/app/src/test-utils/* Add test utilities, mock data, and FluentUI mocks
Comments suppressed due to low confidence (1)

ui/app/src/setupTests.ts:8

  • Use globalThis instead of global to assign mocks (e.g., globalThis.ResizeObserver) to ensure compatibility across environments.
  global.ResizeObserver = vi.fn().mockImplementation(() => ({

templateVersion: '1.0.0',
availableUpgrades: [],
deploymentStatus: 'deployed',
updatedWhen: Date.now(),
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using Date.now() at module initialization can lead to unstable mock timestamps; consider injecting a fixed timestamp or factory function for predictable test data.

Suggested change
updatedWhen: Date.now(),
updatedWhen: FIXED_TIMESTAMP,

Copilot uses AI. Check for mistakes.
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.

2 participants