-
Notifications
You must be signed in to change notification settings - Fork 9
test: re-import improved mock system from cloud-ui #1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@claude can you please do a deep review of this branch |
|
Claude finished @kantord's task in 2m 37s —— View job Deep Review of Mock System ChangesI've completed a thorough review of the mock system improvements. This is a well-architected refactoring that significantly enhances the testing infrastructure. Here's my detailed analysis: ✅ Strengths1. Excellent Architecture (autoAPIMock.ts)The new
2. Scenario System DesignThe scenario implementation is clever:
3. Migration StrategyThe fixture migration is consistent and backward-compatible:
4. Configuration UpdatesPath aliases properly configured:
🐛 Issues FoundHigh Priority
Medium Priority
Low Priority
💡 Suggestions for Future Improvements
📋 Test Coverage ObservationsLooking at install-group-button.test.tsx:
🎯 Overall AssessmentScore: 8.5/10 This is a high-quality refactoring that:
The issues identified are mostly minor edge cases. The architecture is solid and the implementation is production-ready. My main recommendation is to address the high-priority items (error handling consistency and circular dependency risk) before merging. Recommendation: Approve with minor changes ✨ |
There was a problem hiding this 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 PR re-imports an improved mock system from cloud-ui that enhances API mocking capabilities with type-safe test overrides and reusable scenarios. The new AutoAPIMock wrapper provides a cleaner API for test-scoped overrides while maintaining backward compatibility with existing fixtures.
Key changes:
- Introduces
AutoAPIMock<T>wrapper with.override(),.overrideHandler(), and.activateScenario()methods for flexible test customization - Migrates all mock fixtures from default exports to named exports with consistent naming convention (e.g.,
mockedGetApiV1BetaGroups) - Adds comprehensive documentation in
docs/mocks.mdand.github/copilot-instructions.md
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.setup.ts | Adds resetAllAutoAPIMocks() call in beforeEach to reset mock overrides between tests |
| vitest.config.ts | Adds @mocks path alias for convenient imports |
| tsconfig.json | Adds @mocks and @mocks/* path mappings for TypeScript resolution |
| tsconfig.app.json | Mirrors the @mocks path mappings from tsconfig.json |
| renderer/src/features/registry-servers/components/tests/install-group-button.test.tsx | Updates to use new named export mockedGetApiV1BetaGroups and accesses fixture data via .defaultValue |
| renderer/src/common/mocks/test.setup.ts | Adds standalone test setup file (appears to duplicate existing setup in root vitest.setup.ts) |
| renderer/src/common/mocks/scenarioNames.ts | Defines global scenario names (Empty, ServerError) with type safety |
| renderer/src/common/mocks/mocker.ts | Updates fixture generation to use AutoAPIMock wrapper and named exports; removes Ajv validation |
| renderer/src/common/mocks/mockTemplate.ts | Implements deriveMockName() function and updates buildMockModule() to generate fixtures with named exports |
| renderer/src/common/mocks/index.ts | Exports public API of the mock system |
| renderer/src/common/mocks/fixtures/workloads_restart/post.ts | Migrates to AutoAPIMock with named export mockedPostApiV1BetaWorkloadsRestart |
| renderer/src/common/mocks/fixtures/workloads_name_edit/post.ts | Migrates to AutoAPIMock with named export mockedPostApiV1BetaWorkloadsByNameEdit |
| renderer/src/common/mocks/fixtures/workloads_name/get.ts | Migrates to AutoAPIMock with named export mockedGetApiV1BetaWorkloadsByName |
| renderer/src/common/mocks/fixtures/workloads/post.ts | Migrates to AutoAPIMock with named export mockedPostApiV1BetaWorkloads |
| renderer/src/common/mocks/fixtures/groups_name/get.ts | Migrates to AutoAPIMock with named export mockedGetApiV1BetaGroupsByName |
| renderer/src/common/mocks/fixtures/groups_name/delete.ts | Migrates to AutoAPIMock with named export mockedDeleteApiV1BetaGroupsByName |
| renderer/src/common/mocks/fixtures/groups/post.ts | Migrates to AutoAPIMock with named export mockedPostApiV1BetaGroups |
| renderer/src/common/mocks/fixtures/groups/get.ts | Migrates to AutoAPIMock with named export mockedGetApiV1BetaGroups |
| renderer/src/common/mocks/fixtures/discovery_clients/get.ts | Migrates to AutoAPIMock with named export mockedGetApiV1BetaDiscoveryClients |
| renderer/src/common/mocks/fixtures/clients_register/post.ts | Migrates to AutoAPIMock with named export mockedPostApiV1BetaClientsRegister |
| renderer/src/common/mocks/fixtures/README.md | Removes outdated documentation (replaced by comprehensive docs/mocks.md) |
| renderer/src/common/mocks/autoAPIMock.ts | Implements the core AutoAPIMock wrapper with override capabilities, scenario support, and registry for bulk resets |
| docs/mocks.md | Adds comprehensive documentation covering fixture generation, test-scoped overrides, scenarios, and request recording |
| .github/copilot-instructions.md | Documents API mocking patterns and examples for GitHub Copilot |
peppescg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
re-import improved mocking system from the cloud ui repo. Note, this does not yet remove custom MSW mocks. in order to keep the PR reasonably small I just did the bare minimum changes to actual tests/fixtures here to support the new mocking system.