Skip to content

Conversation

@pd-redis
Copy link
Collaborator

This pull request focuses on updating the MSW (Mock Service Worker) API usage throughout the codebase. It also upgrades related dependencies and adjusts the Jest configuration to support these changes.

MSW API Modernization and Type Cleanup:

  • update MSW version

  • updated calls to follow current API of MSW

Dependency and Jest Configuration Updates:

  • Upgraded msw to version ^2.11.5 and added jest-fixed-jsdom

  • Changed Jest configuration to use jest-fixed-jsdom as the test environment, added until-async to the transformIgnorePatterns, and included customExportConditions in testEnvironmentOptions. All of this is to support MSW 2 with jestdom

Code Cleanup:

  • Removed unused re-export of FormField in FormField.ts.

const handlers: HttpHandler[] = [
// useGetClusterDetailsQuery
rest.get<DatabaseInstanceResponse[]>(
http.get<any, DatabaseInstanceResponse[]>(
Copy link
Member

@valkirilov valkirilov Oct 17, 2025

Choose a reason for hiding this comment

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

Looking at the http.get call, I'm a bit confused about the generic types. From what I understand about MSW's type signature, the generics are <PathParams, ResponseBodyType, RequestBodyType>. So:

  1. Path params (any)
    Since we're not using any path parameters in this URL pattern, could we use Record<string, never> or just omit it instead of any?

  2. Response body type (DatabaseInstanceResponse[])
    We're actually returning CLUSTER_DETAILS_DATA_MOCK which is typed as ClusterDetails (a single object, not an array). Shouldn't this be:

    http.get<Record<string, never>, ClusterDetails>(...)

Or the ClusterDetails interface is actually a subset of DatabaseInstanceResponse, and it's fine.

  1. General question
    When I remove these type parameters entirely, I don't see any TypeScript errors. Are these types actually being validated somewhere, or are they more for documentation purposes? Maybe I'm missing some context about how MSW uses these in the testing setup?

I'm just trying to make sure I understand the pattern correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since this is purely test code, and TS types have no effect on actual results, I am in favor of omitting them overall

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.54% 20160/24426
🟡 Branches 67.74% 8708/12855
🟡 Functions 77.02% 5398/7009
🟢 Lines 82.96% 19738/23792

Test suite run success

5162 tests passing in 677 suites.

Report generated by 🧪jest coverage report action from 59098ed

Copy link
Collaborator

@ArtemHoruzhenko ArtemHoruzhenko left a comment

Choose a reason for hiding this comment

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

lgtm

@pd-redis pd-redis requested a review from valkirilov October 30, 2025 11:47
@pd-redis pd-redis merged commit dab802b into playground Oct 30, 2025
17 checks passed
@pd-redis pd-redis deleted the fe/bugfix/fix-test-runner branch October 30, 2025 12:10
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.

5 participants