Skip to content

Conversation

@DonOmalVindula
Copy link
Contributor

@DonOmalVindula DonOmalVindula commented Feb 2, 2026

Purpose

This pull request refactors test and component code throughout the thunder-develop frontend to improve type safety and clarity when working with mock functions. The main change is replacing the use of ReturnType<typeof vi.fn> with the explicit Mock type imported from vitest. This makes mock variable types more accurate and consistent, especially in test files. Additionally, one minor improvement updates a useRef type for better compatibility.

The most important changes are:

Test type improvements:

  • Replaced all instances of ReturnType<typeof vi.fn> with the explicit Mock type for mock variables in test files across applications and flows features, including API and component tests.

Component type improvement:

  • Updated the type of applyTimeoutRef in EditTokenSettings.tsx from NodeJS.Timeout | null to ReturnType<typeof setTimeout> | null for better compatibility across environments.

These changes enhance code maintainability and reduce the risk of type errors when working with mocks in tests.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Copilot AI review requested due to automatic review settings February 2, 2026 06:19
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

This pull request migrates thunder-gate tests from @testing-library/react with JSDOM to Vitest Browser Mode with Playwright, running tests in actual Chromium browsers. This addresses limitations of JSDOM that don't fully reflect real browser behavior and eliminates the need for extensive DOM API mocking.

Changes:

  • Added browser-specific test utilities to @thunder/test-utils package (browser.ts, browser-test-utils.tsx, setup-browser.ts)
  • Configured Vitest with Playwright provider for thunder-gate tests
  • Migrated all 18 test files from @testing-library APIs to native Vitest Browser Mode APIs (page object, userEvent, expect.element, expect.poll)
  • Implemented vi.hoisted() pattern for proper mock function hoisting in browser mode
  • Removed @testing-library dependencies from thunder-gate and replaced with playwright and @vitest/browser packages

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
frontend/pnpm-workspace.yaml Added @vitest/browser, @vitest/browser-playwright, playwright, and vitest-browser-react to catalog
frontend/pnpm-lock.yaml Updated dependency resolution for new browser mode packages
frontend/packages/thunder-test-utils/src/setup-browser.ts Browser mode test setup with i18n and Asgardeo mocks
frontend/packages/thunder-test-utils/src/browser.ts Exports browser-specific test utilities and Vitest Browser Mode APIs
frontend/packages/thunder-test-utils/src/browser-test-utils.tsx Implements custom render and renderHook functions for browser mode with provider wrapping
frontend/packages/thunder-test-utils/rolldown.config.js Added build configuration for browser mode utilities (ESM only)
frontend/packages/thunder-test-utils/package.json Added package exports for ./browser and ./setup-browser, added vitest-browser-react dependency
frontend/apps/thunder-gate/vite.config.ts Configured browser mode with Playwright provider, chromium browser, and headless mode
frontend/apps/thunder-gate/src/test/setup.ts Updated to import setup-browser instead of jsdom setup
frontend/apps/thunder-gate/src/tests/**/*.test.tsx Migrated 18 test files to use page object queries, userEvent, expect.element, and expect.poll
frontend/apps/thunder-gate/package.json Removed @testing-library dependencies, added @vitest/browser, playwright, and vitest-browser-react
.gitignore Added screenshots directory to ignore Vitest Browser Mode screenshots
Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Language not supported

@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from 4e2dc4c to 82b5a29 Compare February 2, 2026 07:15
Copilot AI review requested due to automatic review settings February 2, 2026 07:42
@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from 82b5a29 to aba20f4 Compare February 2, 2026 07:42
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

Copilot reviewed 25 out of 27 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Language not supported

@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from aba20f4 to 10db431 Compare February 2, 2026 07:45
Copilot AI review requested due to automatic review settings February 2, 2026 07:48
@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from 10db431 to 851acd7 Compare February 2, 2026 07:48
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

Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Language not supported

@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch 2 times, most recently from 6394e1b to e4d67f0 Compare February 3, 2026 06:37
@DonOmalVindula DonOmalVindula changed the title Migrate thunder-gate tests to Vitest Browser Mode Migrate thunder-gate tests to Vitest Browser Mode and Vite v4 Feb 3, 2026
Copilot AI review requested due to automatic review settings February 3, 2026 06:42
@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from e4d67f0 to 7bc8dc6 Compare February 3, 2026 06:42
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

Copilot reviewed 53 out of 55 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Language not supported

@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from 7bc8dc6 to b50426a Compare February 3, 2026 08:21
Copilot AI review requested due to automatic review settings February 3, 2026 09:02
@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from b50426a to e579ed1 Compare February 3, 2026 09:02
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

Copilot reviewed 55 out of 57 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Language not supported

@DonOmalVindula DonOmalVindula force-pushed the feat/integrate-code-cov-thunder-gate branch from e579ed1 to 6f6f777 Compare February 3, 2026 10:37
@DonOmalVindula DonOmalVindula changed the title Migrate thunder-gate tests to Vitest Browser Mode and Vite v4 Migrate thunder-gate tests to Vitest Browser Mode and Vitest v4 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant