-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7618] - Delete Placement Group Modal #10162
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5abaa6d
Initial commit: save work
abailly-akamai 351e267
Wrap up comment and add test
abailly-akamai bb0a976
Cleanup
abailly-akamai 0d905d6
Error handling
abailly-akamai 75b3039
Cleanup and more error handling
abailly-akamai 8cf4085
Add linode list
abailly-akamai 6140c41
Add unassign logic
abailly-akamai a5dbf27
error handling
abailly-akamai 0946e12
Test
abailly-akamai 154da26
Restore initial mock data
abailly-akamai 4fc9f1a
Cleanup
abailly-akamai edd6ecb
Test and story for changes in removable selection list
abailly-akamai c01bec1
Added changeset: Add Delete Placement Group Modal
abailly-akamai cde4ef9
Invalidate related linode when removed from PG
abailly-akamai b7168f5
Feedback
abailly-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10162-upcoming-features-1708036002117.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add Delete Placement Group Modal ([#10162](https://github.com/linode/manager/pull/10162)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
packages/manager/src/features/PlacementGroups/PlacementGroupsDeleteModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { linodeFactory, placementGroupFactory } from 'src/factories'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { PlacementGroupsDeleteModal } from './PlacementGroupsDeleteModal'; | ||
|
||
const queryMocks = vi.hoisted(() => ({ | ||
useAllLinodesQuery: vi.fn().mockReturnValue({}), | ||
useDeletePlacementGroup: vi.fn().mockReturnValue({ | ||
mutateAsync: vi.fn().mockResolvedValue({}), | ||
reset: vi.fn(), | ||
}), | ||
useParams: vi.fn().mockReturnValue({}), | ||
usePlacementGroupQuery: vi.fn().mockReturnValue({}), | ||
})); | ||
|
||
vi.mock('react-router-dom', async () => { | ||
const actual = await vi.importActual('react-router-dom'); | ||
return { | ||
...actual, | ||
useParams: queryMocks.useParams, | ||
}; | ||
}); | ||
|
||
vi.mock('src/queries/placementGroups', async () => { | ||
const actual = await vi.importActual('src/queries/placementGroups'); | ||
return { | ||
...actual, | ||
useDeletePlacementGroup: queryMocks.useDeletePlacementGroup, | ||
usePlacementGroupQuery: queryMocks.usePlacementGroupQuery, | ||
}; | ||
}); | ||
|
||
vi.mock('src/queries/linodes/linodes', async () => { | ||
const actual = await vi.importActual('src/queries/linodes/linodes'); | ||
return { | ||
...actual, | ||
useAllLinodesQuery: queryMocks.useAllLinodesQuery, | ||
}; | ||
}); | ||
|
||
const props = { | ||
onClose: vi.fn(), | ||
open: true, | ||
}; | ||
|
||
describe('PlacementGroupsDeleteModal', () => { | ||
beforeAll(() => { | ||
queryMocks.useParams.mockReturnValue({ | ||
id: '1', | ||
}); | ||
queryMocks.useAllLinodesQuery.mockReturnValue({ | ||
data: [ | ||
linodeFactory.build({ | ||
id: 1, | ||
label: 'test-linode', | ||
}), | ||
], | ||
}); | ||
}); | ||
|
||
it('should render the right form elements', () => { | ||
queryMocks.usePlacementGroupQuery.mockReturnValue({ | ||
data: placementGroupFactory.build({ | ||
affinity_type: 'anti_affinity', | ||
id: 1, | ||
label: 'PG-to-delete', | ||
linode_ids: [1], | ||
}), | ||
}); | ||
|
||
const { getByRole, getByTestId, getByText } = renderWithTheme( | ||
<PlacementGroupsDeleteModal {...props} /> | ||
); | ||
|
||
expect( | ||
getByRole('heading', { | ||
name: 'Delete Placement Group PG-to-delete (Anti-affinity)', | ||
}) | ||
).toBeInTheDocument(); | ||
expect( | ||
getByText( | ||
'Linodes assigned to Placement Group PG-to-delete (Anti-affinity)' | ||
) | ||
).toBeInTheDocument(); | ||
expect(getByTestId('assigned-linodes')).toContainElement( | ||
getByText('test-linode') | ||
); | ||
expect(getByTestId('textfield-input')).toBeDisabled(); | ||
expect(getByRole('button', { name: 'Close' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Cancel' })).toBeInTheDocument(); | ||
expect(getByRole('button', { name: 'Delete' })).toBeDisabled(); | ||
}); | ||
|
||
it("should be enabled when there's no assigned linodes", () => { | ||
queryMocks.usePlacementGroupQuery.mockReturnValue({ | ||
data: placementGroupFactory.build({ | ||
affinity_type: 'anti_affinity', | ||
id: 1, | ||
label: 'PG-to-delete', | ||
linode_ids: [], | ||
}), | ||
}); | ||
const { getByRole, getByTestId, getByText } = renderWithTheme( | ||
<PlacementGroupsDeleteModal {...props} /> | ||
); | ||
|
||
expect(getByText('No Linodes assigned to this Placement Group.')); | ||
|
||
const textField = getByTestId('textfield-input'); | ||
const deleteButton = getByRole('button', { name: 'Delete' }); | ||
|
||
expect(textField).toBeEnabled(); | ||
expect(deleteButton).toBeDisabled(); | ||
|
||
fireEvent.change(textField, { target: { value: 'PG-to-delete' } }); | ||
|
||
expect(deleteButton).toBeEnabled(); | ||
fireEvent.click(deleteButton); | ||
|
||
expect(queryMocks.useDeletePlacementGroup).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
those were never passed therefore when using our
<TypeToConfirmDialog />
component we couldn't access the textfield inputProps