-
Notifications
You must be signed in to change notification settings - Fork 361
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
change: [M3-6843] - Move manual snapshot error message to snapshot confirmation dialog #10791
Changes from all commits
4000650
8e6bddc
bd3f848
60c1447
f8be75d
317b92d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Changed | ||
--- | ||
|
||
Move manual snapshot error message from Linode Backups page to snapshot confirmation dialog ([#10791](https://github.com/linode/manager/pull/10791)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { CaptureSnapshotConfirmationDialog } from './CaptureSnapshotConfirmationDialog'; | ||
|
||
const props = { | ||
error: undefined, | ||
loading: false, | ||
onClose: vi.fn(), | ||
onExited: vi.fn(), | ||
onSnapshot: vi.fn(), | ||
open: true, | ||
}; | ||
|
||
describe('CaptureSnapshotConfirmationDialog', () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it('should render the dialog', () => { | ||
const { getByTestId, getByText } = renderWithTheme( | ||
<CaptureSnapshotConfirmationDialog {...props} /> | ||
); | ||
|
||
const takeSnapshotButton = getByTestId('confirm'); | ||
const cancelButton = getByText('Cancel'); | ||
const title = getByText('Take a snapshot?'); | ||
const body = getByText( | ||
'Taking a snapshot will back up your Linode in its current state, overriding your previous snapshot. Are you sure?' | ||
); | ||
|
||
expect(takeSnapshotButton).toBeVisible(); | ||
expect(cancelButton).toBeVisible(); | ||
expect(title).toBeVisible(); | ||
expect(body).toBeVisible(); | ||
}); | ||
coliu-akamai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('should send a request to create a snapshot if loading is false', () => { | ||
const { getByTestId } = renderWithTheme( | ||
<CaptureSnapshotConfirmationDialog {...props} /> | ||
); | ||
|
||
const takeSnapshotButton = getByTestId('confirm'); | ||
expect(takeSnapshotButton).toBeVisible(); | ||
fireEvent.click(takeSnapshotButton); | ||
expect(props.onSnapshot).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not send a request to create a snapshot if loading is true', () => { | ||
const { getByTestId } = renderWithTheme( | ||
<CaptureSnapshotConfirmationDialog {...props} loading={true} /> | ||
); | ||
|
||
const takeSnapshotButton = getByTestId('confirm'); | ||
expect(takeSnapshotButton).toBeVisible(); | ||
fireEvent.click(takeSnapshotButton); | ||
expect(props.onSnapshot).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should close the dialog when the "Cancel" button is clicked', () => { | ||
const { getByText } = renderWithTheme( | ||
<CaptureSnapshotConfirmationDialog {...props} /> | ||
); | ||
|
||
const cancelButton = getByText('Cancel'); | ||
expect(cancelButton).toBeVisible(); | ||
fireEvent.click(cancelButton); | ||
expect(props.onClose).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render the dialog with an error message', () => { | ||
const { getByText } = renderWithTheme( | ||
<CaptureSnapshotConfirmationDialog | ||
{...props} | ||
error={'mock error message'} | ||
/> | ||
); | ||
|
||
const errorMessage = getByText('mock error message'); | ||
expect(errorMessage).toBeVisible(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,16 @@ import { ConfirmationDialog } from 'src/components/ConfirmationDialog/Confirmati | |
import { Typography } from 'src/components/Typography'; | ||
|
||
interface Props { | ||
error?: string; | ||
error: string | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's no change in type/functionality of this prop, just made it non optional bc the one place we use this component now passes in an error |
||
loading: boolean; | ||
onClose: () => void; | ||
onExited: () => void; | ||
onSnapshot: () => void; | ||
open: boolean; | ||
} | ||
|
||
export const CaptureSnapshotConfirmationDialog = (props: Props) => { | ||
const { error, loading, onClose, onSnapshot, open } = props; | ||
const { error, loading, onClose, onExited, onSnapshot, open } = props; | ||
|
||
const actions = ( | ||
<ActionsPanel | ||
|
@@ -37,6 +38,7 @@ export const CaptureSnapshotConfirmationDialog = (props: Props) => { | |
actions={actions} | ||
error={error} | ||
onClose={onClose} | ||
onExited={onExited} | ||
open={open} | ||
title="Take a snapshot?" | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { LinodeBackup, PriceObject } from '@linode/api-v4/lib/linodes'; | ||
import { Box, Stack } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
import * as React from 'react'; | ||
|
@@ -23,13 +22,15 @@ import { useRegionsQuery } from 'src/queries/regions/regions'; | |
import { useTypeQuery } from 'src/queries/types'; | ||
import { getMonthlyBackupsPrice } from 'src/utilities/pricing/backups'; | ||
|
||
import { BackupTableRow } from './BackupTableRow'; | ||
import { BackupsPlaceholder } from './BackupsPlaceholder'; | ||
import { BackupTableRow } from './BackupTableRow'; | ||
import { CancelBackupsDialog } from './CancelBackupsDialog'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are just eslint changes (same with line 75 of CaptureSnapshot.tsx) |
||
import { CaptureSnapshot } from './CaptureSnapshot'; | ||
import { RestoreToLinodeDrawer } from './RestoreToLinodeDrawer'; | ||
import { ScheduleSettings } from './ScheduleSettings'; | ||
|
||
import type { LinodeBackup, PriceObject } from '@linode/api-v4/lib/linodes'; | ||
|
||
export const LinodeBackups = () => { | ||
const { linodeId } = useParams<{ linodeId: string }>(); | ||
const id = Number(linodeId); | ||
|
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.
Thanks for adding this test!!!