-
Notifications
You must be signed in to change notification settings - Fork 3
Tests for resources #360
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
Tests for resources #360
Conversation
andreaskienle
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.
A few remarks down below.
About the splitter: Have you tried wrapping the component in <SplitterLayout> in the mount function?
cy.mount(
<MemoryRouter>
<SplitterProvider>
<SplitterLayout>
…
</SplitterLayout>
</SplitterProvider>
</MemoryRouter>,
This way you can maybe open the YAML file in the aside panel and test the flow there.
If this is not possible, can we at least test the useHandleResourcePatch hook?
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 adds test coverage for the ManagedResources component by introducing dependency injection for hooks and creating comprehensive Cypress component tests. The changes enable easier testing of delete and edit operations by allowing mock implementations of hooks to be passed as props.
- Refactored
ManagedResourcescomponent to accept optional hook overrides via props - Added comprehensive Cypress component tests for delete and force delete operations
- Enhanced
ActionsMenucomponent with test identifiers and removed unused parameter
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/components/ControlPlane/ManagedResources.tsx | Added dependency injection pattern for useApiResourceMutation and useHandleResourcePatch hooks to enable testing |
| src/components/ControlPlane/ManagedResources.cy.tsx | Added comprehensive Cypress component tests covering delete, force delete, validation, and edit functionality |
| src/components/ControlPlane/ActionsMenu.tsx | Added data-testid attribute and data-component-name for test identification, removed unused buttonIcon parameter from function signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andreaskienle
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.
Much better without the cy.wait() calls! 👍🏻
|
Hey @lucasgoral, mind giving this a quick approve? 🙏 |
What this PR does / why we need it:
Why Edit functionality is not fully tested
Edit Resource tests are intentionally limited to basic initialization checks.
Multiple layers - The edit flow involves: openInAside, YamlSidePanel, YamlViewer, Monaco Editor, and onApply callback. Each layer requires complex setup and mocking.
Splitter Context complexity - Edit opens resources in a side panel managed by SplitterContext. This context cannot be easily mocked in Cypress component.
YAML editor (Monaco Editor) is a also complex to be mocked.
We verify the basics work, we should cover it in E2E
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: