-
Notifications
You must be signed in to change notification settings - Fork 365
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
feat: [M3-8099] - Improve Linode Clone Power Off based on initial data #10508
Merged
mjac0bs
merged 10 commits into
linode:develop
from
mjac0bs:M3-8099-improve-linode-clone-power-off
May 24, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4cdfc3f
Remove duplicate test
mjac0bs 1f4742b
Swap notice list order and bold key words
mjac0bs 8e9ef26
Add analytics event on power off button
mjac0bs cf88d7b
Add status and power off button to linode selection card
mjac0bs 6d2de3d
Prevent power off button from displaying on cards outside clone flow
mjac0bs 22bada9
Add test coverage for SelectLinodeCard
mjac0bs 6a24978
Added changeset: Improvements to Clone flow to encourage powering dowβ¦
mjac0bs 5197953
Merge branch 'develop' into M3-8099-improve-linode-clone-power-off
mjac0bs a1e0053
Address feedback: add missing event in v2 flow
mjac0bs 8dd052f
Address feedback: improve alignment
mjac0bs 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
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": Added | ||
--- | ||
|
||
Improvements to Clone flow to encourage powering down before cloning ([#10508](https://github.com/linode/manager/pull/10508)) |
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
76 changes: 76 additions & 0 deletions
76
...es/manager/src/features/Linodes/LinodesCreate/SelectLinodePanel/SelectLinodeCard.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,76 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { linodeFactory } from 'src/factories'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { SelectLinodeCard } from './SelectLinodeCard'; | ||
|
||
const mockPoweredOnLinode = linodeFactory.build({ status: 'running' }); | ||
const mockPoweredOffLinode = linodeFactory.build({ status: 'offline' }); | ||
|
||
const defaultProps = { | ||
disabled: false, | ||
handlePowerOff: vi.fn(), | ||
handleSelection: vi.fn(), | ||
key: mockPoweredOnLinode.id, | ||
linode: mockPoweredOnLinode, | ||
selected: false, | ||
showPowerActions: false, | ||
}; | ||
|
||
describe('SelectLinodeCard', () => { | ||
it('displays the status of a linode', () => { | ||
const { getByLabelText, getByText, queryByRole } = renderWithTheme( | ||
<SelectLinodeCard {...defaultProps} showPowerActions={true} /> | ||
); | ||
expect(getByLabelText('Linode status running')).toBeInTheDocument(); | ||
expect(getByText('Running')).toBeVisible(); | ||
// Should not display the Power Off button unless the card is selected. | ||
expect(queryByRole('button')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('displays the status and Power Off button of a linode that is selected and running when power actions should be shown', () => { | ||
const { getByLabelText, getByRole, getByText } = renderWithTheme( | ||
<SelectLinodeCard | ||
{...defaultProps} | ||
selected={true} | ||
showPowerActions={true} | ||
/> | ||
); | ||
|
||
expect(getByLabelText('Linode status running')).toBeInTheDocument(); | ||
expect(getByText('Running')).toBeVisible(); | ||
|
||
const powerOffButton = getByRole('button'); | ||
expect(powerOffButton).toHaveTextContent('Power Off'); | ||
fireEvent.click(powerOffButton); | ||
expect(defaultProps.handlePowerOff).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('does not display the Power Off button when it should not be shown', () => { | ||
const { queryByRole } = renderWithTheme( | ||
<SelectLinodeCard | ||
{...defaultProps} | ||
selected={true} | ||
showPowerActions={false} | ||
/> | ||
); | ||
expect(queryByRole('button')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('does not display the Power Off button when a selected linode is powered off', () => { | ||
const { getByLabelText, getByText, queryByRole } = renderWithTheme( | ||
<SelectLinodeCard | ||
{...defaultProps} | ||
linode={mockPoweredOffLinode} | ||
selected={true} | ||
showPowerActions={true} | ||
/> | ||
); | ||
expect(getByLabelText('Linode status offline')).toBeInTheDocument(); | ||
expect(getByText('Offline')).toBeVisible(); | ||
// Should not display the Power Off button unless the linode is running. | ||
expect(queryByRole('button')).not.toBeInTheDocument(); | ||
}); | ||
}); |
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
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
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.
This was a duplicate test the linter notified me of. See L99-L112.