-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [M3-8016] - Add TagSelect to edit images drawer (#10466)
* Add tags to images type * Add tag select to ImagesDrawer * Added changeset: TagSelect in Edit Image drawer * Added changeset: `tags` field in `Image` type * Further removal of unused logic * Add unit tests for ImagesDrawer * Fix unit tests * Fix action menu items * Add `tags` to `updateImageSchema` * feedback @abailly-akamai
- Loading branch information
1 parent
32f836a
commit 819356b
Showing
14 changed files
with
194 additions
and
248 deletions.
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/api-v4": Added | ||
--- | ||
|
||
`tags` field in `Image` type ([#10466](https://github.com/linode/manager/pull/10466)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
TagSelect in Edit Image drawer ([#10466](https://github.com/linode/manager/pull/10466)) |
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
97 changes: 97 additions & 0 deletions
97
packages/manager/src/features/Images/ImagesDrawer.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,97 @@ | ||
import { fireEvent } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import { linodeFactory } from 'src/factories'; | ||
import { makeResourcePage } from 'src/mocks/serverHandlers'; | ||
import { HttpResponse, http, server } from 'src/mocks/testServer'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { ImagesDrawer, Props } from './ImagesDrawer'; | ||
|
||
const props: Props = { | ||
changeDescription: vi.fn(), | ||
changeDisk: vi.fn(), | ||
changeLabel: vi.fn(), | ||
changeLinode: vi.fn(), | ||
changeTags: vi.fn(), | ||
mode: 'edit', | ||
onClose: vi.fn(), | ||
open: true, | ||
selectedLinode: null, | ||
}; | ||
|
||
describe('ImagesDrawer edit mode', () => { | ||
it('should render', async () => { | ||
const { getByText } = renderWithTheme( | ||
<ImagesDrawer {...props} mode="edit" /> | ||
); | ||
|
||
// Verify title renders | ||
getByText('Edit Image'); | ||
}); | ||
|
||
it('should allow editing image details', async () => { | ||
const { getByLabelText, getByText } = renderWithTheme( | ||
<ImagesDrawer {...props} mode="edit" /> | ||
); | ||
|
||
fireEvent.change(getByLabelText('Label'), { | ||
target: { value: 'test-image-label' }, | ||
}); | ||
|
||
fireEvent.change(getByLabelText('Description'), { | ||
target: { value: 'test description' }, | ||
}); | ||
|
||
fireEvent.change(getByLabelText('Tags'), { | ||
target: { value: 'new-tag' }, | ||
}); | ||
fireEvent.click(getByText('Create "new-tag"')); | ||
|
||
fireEvent.click(getByText('Save Changes')); | ||
|
||
expect(props.changeLabel).toBeCalledWith( | ||
expect.objectContaining({ | ||
target: expect.objectContaining({ value: 'test-image-label' }), | ||
}) | ||
); | ||
|
||
expect(props.changeDescription).toBeCalledWith( | ||
expect.objectContaining({ | ||
target: expect.objectContaining({ value: 'test description' }), | ||
}) | ||
); | ||
|
||
expect(props.changeTags).toBeCalledWith(['new-tag']); | ||
}); | ||
}); | ||
|
||
describe('ImagesDrawer restore mode', () => { | ||
it('should render', async () => { | ||
const { getByText } = renderWithTheme( | ||
<ImagesDrawer {...props} mode="restore" /> | ||
); | ||
|
||
// Verify title renders | ||
getByText('Restore from Image'); | ||
}); | ||
|
||
it('should allow editing image details', async () => { | ||
const { findByText, getByRole, getByText } = renderWithTheme( | ||
<ImagesDrawer {...props} mode="restore" /> | ||
); | ||
|
||
server.use( | ||
http.get('*/linode/instances', () => { | ||
return HttpResponse.json(makeResourcePage(linodeFactory.buildList(5))); | ||
}) | ||
); | ||
|
||
await userEvent.click(getByRole('combobox')); | ||
await userEvent.click(await findByText('linode-1')); | ||
await userEvent.click(getByText('Restore Image')); | ||
|
||
expect(props.changeLinode).toBeCalledWith(1); | ||
}); | ||
}); |
Oops, something went wrong.