Skip to content

SRVOCF-846: Migrate remaining unit tests to MSW#44

Open
Cragsmann wants to merge 3 commits into
functions-dev:masterfrom
Cragsmann:SRVOCF-846--msw-migration
Open

SRVOCF-846: Migrate remaining unit tests to MSW#44
Cragsmann wants to merge 3 commits into
functions-dev:masterfrom
Cragsmann:SRVOCF-846--msw-migration

Conversation

@Cragsmann

@Cragsmann Cragsmann commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Migrate 4 test files from vi.mock service-level mocking to MSW (Mock Service Worker) network-level mocking
  • Real service code now runs in tests, with MSW intercepting HTTP calls at the network layer
  • useClusterService.test.tsx kept as-is since useK8sWatchResource is an SDK hook, not HTTP

Migrated files

File Tests Key changes
OcpClusterService.test.ts 4 Replaced mockGet/mockPost with consoleFetchJSON bridge + MSW handlers for K8s API
UserAvatar.test.tsx 14 Removed mockFetchUserInfo, real GithubService runs with MSW intercepting GitHub API
FunctionsListPage.test.tsx 19 Removed mockUseSourceControl, MSW handles /user and /search/repositories
FunctionCreatePage.test.tsx 5 Removed 3 service mocks, MSW handles full create flow (backend API + GitHub API + K8s API)

Pattern

The consoleFetchJSON bridge in the SDK mock converts the OpenShift SDK's consoleFetchJSON into real fetch calls so MSW can intercept them. useK8sWatchResource stays as vi.mock since it's an SDK React hook, not HTTP.

Test plan

  • All 125 tests pass (yarn test)
  • No regressions in existing test files

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.

1 participant