-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(images): Implement change source design MAASENG-4361 (#5612)
- Loading branch information
1 parent
7f2c51e
commit 2fa7b05
Showing
78 changed files
with
687 additions
and
4,453 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
100 changes: 56 additions & 44 deletions
100
src/app/images/components/ImagesForms/ImagesForms.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 |
---|---|---|
@@ -1,55 +1,67 @@ | ||
import configureStore from "redux-mock-store"; | ||
|
||
import ImagesForms from "./ImagesForms"; | ||
|
||
import { ImageSidePanelViews } from "@/app/images/constants"; | ||
import type { ImageSidePanelContent } from "@/app/images/types"; | ||
import { ConfigNames } from "@/app/store/config/types"; | ||
import type { RootState } from "@/app/store/root/types"; | ||
import * as factory from "@/testing/factories"; | ||
import { renderWithBrowserRouter, screen } from "@/testing/utils"; | ||
import { | ||
getByTextContent, | ||
renderWithBrowserRouter, | ||
screen, | ||
} from "@/testing/utils"; | ||
|
||
const mockStore = configureStore<RootState>(); | ||
let state: RootState; | ||
describe("ImagesForms", () => { | ||
it("renders DeleteImage form", () => { | ||
const sidePanelContent: ImageSidePanelContent = { | ||
view: ImageSidePanelViews.DELETE_IMAGE, | ||
extras: { bootResource: factory.bootResource() }, | ||
}; | ||
renderWithBrowserRouter( | ||
<ImagesForms | ||
setSidePanelContent={vi.fn()} | ||
sidePanelContent={sidePanelContent} | ||
/> | ||
); | ||
|
||
beforeEach(() => { | ||
state = factory.rootState({ | ||
bootresource: factory.bootResourceState({ | ||
resources: [ | ||
factory.bootResource({ | ||
arch: "amd64", | ||
complete: true, | ||
name: "ubuntu/focal", | ||
title: "20.04 LTS", | ||
}), | ||
], | ||
}), | ||
config: factory.configState({ | ||
items: [ | ||
factory.config({ | ||
name: ConfigNames.COMMISSIONING_DISTRO_SERIES, | ||
value: "focal", | ||
}), | ||
], | ||
}), | ||
expect( | ||
screen.getByRole("form", { name: "Confirm image deletion" }) | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it("renders a form when appropriate sidepanel view is provided", () => { | ||
const store = mockStore(state); | ||
const sidePanelContent: ImageSidePanelContent = { | ||
view: ImageSidePanelViews.CHANGE_SOURCE, | ||
extras: { hasSources: false }, | ||
}; | ||
renderWithBrowserRouter( | ||
<ImagesForms | ||
setSidePanelContent={vi.fn()} | ||
sidePanelContent={sidePanelContent} | ||
/>, | ||
{ store } | ||
); | ||
it("renders DeleteMultipleImages form", () => { | ||
const sidePanelContent: ImageSidePanelContent = { | ||
view: ImageSidePanelViews.DELETE_MULTIPLE_IMAGES, | ||
extras: { | ||
rowSelection: { 1: true }, | ||
setRowSelection: vi.fn, | ||
}, | ||
}; | ||
renderWithBrowserRouter( | ||
<ImagesForms | ||
setSidePanelContent={vi.fn()} | ||
sidePanelContent={sidePanelContent} | ||
/> | ||
); | ||
|
||
expect( | ||
screen.getByRole("form", { name: "Confirm image deletion" }) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders DownloadImages form", () => { | ||
const sidePanelContent: ImageSidePanelContent = { | ||
view: ImageSidePanelViews.DOWNLOAD_IMAGE, | ||
}; | ||
renderWithBrowserRouter( | ||
<ImagesForms | ||
setSidePanelContent={vi.fn()} | ||
sidePanelContent={sidePanelContent} | ||
/> | ||
); | ||
|
||
expect( | ||
screen.getByRole("form", { name: "Choose source" }) | ||
).toBeInTheDocument(); | ||
expect( | ||
getByTextContent( | ||
"Select images to be imported and kept in sync daily. Images will be available for deploying to machines managed by MAAS." | ||
) | ||
).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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.