forked from linode/manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'linode:develop' into develop
- Loading branch information
Showing
43 changed files
with
457 additions
and
523 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10903-upcoming-features-1725857694589.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 | ||
--- | ||
|
||
Update CSS for widget level filters and widget heading title for ACLP ([#10903](https://github.com/linode/manager/pull/10903)) |
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": Tests | ||
--- | ||
|
||
Add unit tests for Dialog and DeletionDialog components ([#10917](https://github.com/linode/manager/pull/10917)) |
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10930-removed-1726159393499.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": Removed | ||
--- | ||
|
||
Support for Gravatar as user profile avatars ([#10930](https://github.com/linode/manager/pull/10930)) |
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": Fixed | ||
--- | ||
|
||
Textarea tooltip icon focus area ([#10938](https://github.com/linode/manager/pull/10938)) |
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": Fixed | ||
--- | ||
|
||
Flickering on the user profile page when updating the currently signed in user's username ([#10947](https://github.com/linode/manager/pull/10947)) |
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
148 changes: 148 additions & 0 deletions
148
packages/manager/src/components/DeletionDialog/DeletionDialog.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,148 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { DeletionDialog } from './DeletionDialog'; | ||
|
||
import type { DeletionDialogProps } from './DeletionDialog'; | ||
|
||
describe('DeletionDialog', () => { | ||
const defaultArgs: DeletionDialogProps = { | ||
entity: 'Linode', | ||
label: 'my-linode-0', | ||
loading: false, | ||
onClose: vi.fn(), | ||
onDelete: vi.fn(), | ||
open: false, | ||
}; | ||
|
||
it.each([ | ||
['not render', false], | ||
['render', true], | ||
])( | ||
'should %s a DeletionDialog with the correct title, close button, and action buttons when open is %s', | ||
(_, isOpen) => { | ||
const { queryByRole, queryByTestId, queryByText } = renderWithTheme( | ||
<DeletionDialog {...defaultArgs} open={isOpen} /> | ||
); | ||
const title = queryByText( | ||
`Delete ${defaultArgs.entity} ${defaultArgs.label}?` | ||
); | ||
const dialog = queryByTestId('drawer'); | ||
const closeButton = queryByRole('button', { name: 'Close' }); | ||
const cancelButton = queryByTestId('cancel'); | ||
const deleteButton = queryByTestId('confirm'); | ||
|
||
if (isOpen) { | ||
expect(title).toBeInTheDocument(); | ||
expect(dialog).toBeInTheDocument(); | ||
expect(closeButton).toBeInTheDocument(); | ||
expect(cancelButton).toBeInTheDocument(); | ||
expect(deleteButton).toBeInTheDocument(); | ||
expect(deleteButton).toHaveTextContent(`Delete ${defaultArgs.entity}`); | ||
} else { | ||
expect(title).not.toBeInTheDocument(); | ||
expect(dialog).not.toBeInTheDocument(); | ||
expect(closeButton).not.toBeInTheDocument(); | ||
expect(cancelButton).not.toBeInTheDocument(); | ||
expect(deleteButton).not.toBeInTheDocument(); | ||
} | ||
} | ||
); | ||
|
||
it('should call onClose when the DeletionDialog close button or Action cancel button is clicked', () => { | ||
const { getByRole, getByTestId } = renderWithTheme( | ||
<DeletionDialog {...defaultArgs} open={true} /> | ||
); | ||
|
||
// For close icon button | ||
const closeButton = getByRole('button', { name: 'Close' }); | ||
expect(closeButton).not.toBeDisabled(); | ||
fireEvent.click(closeButton); | ||
|
||
expect(defaultArgs.onClose).toHaveBeenCalled(); | ||
|
||
// For action cancel button | ||
const cancelButton = getByTestId('cancel'); | ||
expect(cancelButton).not.toBeDisabled(); | ||
fireEvent.click(cancelButton); | ||
|
||
expect(defaultArgs.onClose).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call onDelete when the DeletionDialog delete button is clicked', () => { | ||
const { getByTestId } = renderWithTheme( | ||
<DeletionDialog {...defaultArgs} open={true} /> | ||
); | ||
|
||
const deleteButton = getByTestId('confirm'); | ||
expect(deleteButton).not.toBeDisabled(); | ||
fireEvent.click(deleteButton); | ||
|
||
expect(defaultArgs.onDelete).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render a DeletionDialog with an error message if provided', () => { | ||
const { getByText } = renderWithTheme( | ||
<DeletionDialog | ||
{...defaultArgs} | ||
error="Error that will be shown in the dialog." | ||
open={true} | ||
/> | ||
); | ||
|
||
expect(getByText('Error that will be shown in the dialog.')).toBeVisible(); | ||
}); | ||
|
||
it('should disable delete button and show loading icon if loading is true', () => { | ||
const { getByTestId } = renderWithTheme( | ||
<DeletionDialog {...defaultArgs} loading={true} open={true} /> | ||
); | ||
|
||
const deleteButton = getByTestId('confirm'); | ||
expect(deleteButton).toBeInTheDocument(); | ||
expect(deleteButton).toBeDisabled(); | ||
|
||
const loadingSvgIcon = deleteButton.querySelector( | ||
'[data-test-id="ReloadIcon"]' | ||
); | ||
|
||
expect(loadingSvgIcon).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display the correct warning text in the DeletionDialog', () => { | ||
const { getByTestId } = renderWithTheme( | ||
<DeletionDialog {...defaultArgs} open={true} /> | ||
); | ||
|
||
const dialog = getByTestId('drawer'); | ||
const warningText = `Warning: Deleting this ${defaultArgs.entity} is permanent and can\u2019t be undone.`; | ||
|
||
expect(dialog).toHaveTextContent(warningText); | ||
}); | ||
|
||
it.each([ | ||
['not render', false], | ||
['render', true], | ||
])( | ||
'should %s input field with label when typeToConfirm is %s', | ||
(_, typeToConfirm) => { | ||
const { queryByTestId } = renderWithTheme( | ||
<DeletionDialog | ||
{...defaultArgs} | ||
open={true} | ||
typeToConfirm={typeToConfirm} | ||
/> | ||
); | ||
|
||
if (typeToConfirm) { | ||
expect(queryByTestId('inputLabelWrapper')).toBeInTheDocument(); | ||
expect(queryByTestId('textfield-input')).toBeInTheDocument(); | ||
} else { | ||
expect(queryByTestId('inputLabelWrapper')).not.toBeInTheDocument(); | ||
expect(queryByTestId('textfield-input')).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { Dialog } from './Dialog'; | ||
|
||
import type { DialogProps } from './Dialog'; | ||
|
||
describe('Dialog', () => { | ||
const defaultArgs: DialogProps = { | ||
onClose: vi.fn(), | ||
open: false, | ||
title: 'This is a Dialog', | ||
}; | ||
|
||
it.each([ | ||
['not render', false], | ||
['render', true], | ||
])('should %s a Dialog with title when open is %s', (_, isOpen) => { | ||
const { queryByTestId, queryByText } = renderWithTheme( | ||
<Dialog {...defaultArgs} open={isOpen} /> | ||
); | ||
|
||
const title = queryByText('This is a Dialog'); | ||
const dialog = queryByTestId('drawer'); | ||
|
||
if (isOpen) { | ||
expect(title).toBeInTheDocument(); | ||
expect(dialog).toBeInTheDocument(); | ||
} else { | ||
expect(title).not.toBeInTheDocument(); | ||
expect(dialog).not.toBeInTheDocument(); | ||
} | ||
}); | ||
|
||
it('should render a Dialog with children if provided', () => { | ||
const { getByText } = renderWithTheme( | ||
<Dialog {...defaultArgs} open={true}> | ||
<p>Child items can go here!</p> | ||
</Dialog> | ||
); | ||
|
||
expect(getByText('Child items can go here!')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onClose when the Dialog close button is clicked', () => { | ||
const { getByRole } = renderWithTheme( | ||
<Dialog {...defaultArgs} open={true} /> | ||
); | ||
|
||
const closeButton = getByRole('button', { name: 'Close' }); | ||
fireEvent.click(closeButton); | ||
|
||
expect(defaultArgs.onClose).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should render a Dialog with an error message if provided', () => { | ||
const { getByText } = renderWithTheme( | ||
<Dialog | ||
{...defaultArgs} | ||
error="Error that will be shown in the dialog." | ||
open={true} | ||
/> | ||
); | ||
|
||
expect(getByText('Error that will be shown in the dialog.')).toBeVisible(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.