33// Redux State → mapRequestFromState() → API Request. They could be replaced by unit
44// tests for the request mapper functions (mapRequestToState/mapRequestFromState) which
55// would be faster and more focused than full integration tests.
6- import { EDIT_BLUEPRINT } from '../../../../../constants' ;
6+ import { screen , within } from '@testing-library/react' ;
7+
8+ import { CreateBlueprintRequest } from '@/store/api/backend' ;
9+ import { clickWithWait , createUser } from '@/test/testUtils' ;
10+
11+ import {
12+ CREATE_BLUEPRINT ,
13+ EDIT_BLUEPRINT ,
14+ RHEL_10 ,
15+ } from '../../../../../constants' ;
716import { mockBlueprintIds } from '../../../../fixtures/blueprints' ;
817import {
918 aarch64CreateBlueprintRequest ,
@@ -13,8 +22,14 @@ import {
1322 x86_64CreateBlueprintRequest ,
1423} from '../../../../fixtures/editMode' ;
1524import {
25+ blueprintRequest ,
26+ enterBlueprintName ,
27+ goToReview ,
28+ interceptBlueprintRequest ,
1629 interceptEditBlueprintRequest ,
30+ renderCreateMode ,
1731 renderEditMode ,
32+ selectGuestImageTarget ,
1833} from '../../wizardTestUtils' ;
1934
2035describe ( 'Image output edit mode' , ( ) => {
@@ -82,3 +97,103 @@ describe('Image output edit mode', () => {
8297 expect ( receivedRequest ) . toEqual ( expectedRequest ) ;
8398 } ) ;
8499} ) ;
100+
101+ const selectNetworkInstaller = async ( ) => {
102+ const user = createUser ( ) ;
103+ const checkbox = await screen . findByRole ( 'checkbox' , {
104+ name : / N e t w o r k i n s t a l l e r c h e c k b o x / i,
105+ } ) ;
106+ await clickWithWait ( user , checkbox ) ;
107+ return checkbox ;
108+ } ;
109+
110+ describe ( 'Network installer target' , ( ) => {
111+ beforeEach ( ( ) => {
112+ vi . clearAllMocks ( ) ;
113+ } ) ;
114+
115+ test ( 'selecting network-installer shows alert and disables other checkboxes' , async ( ) => {
116+ await renderCreateMode ( ) ;
117+ const networkInstallerCheckbox = await selectNetworkInstaller ( ) ;
118+
119+ await screen . findByText (
120+ / T h i s i m a g e t y p e r e q u i r e s s p e c i f i c , m i n i m a l c o n f i g u r a t i o n f o r r e m o t e i n s t a l l a t i o n / i,
121+ ) ;
122+ const guestImageCheckbox = await screen . findByRole ( 'checkbox' , {
123+ name : / V i r t u a l i z a t i o n g u e s t i m a g e / i,
124+ } ) ;
125+ expect ( guestImageCheckbox ) . toBeDisabled ( ) ;
126+
127+ const bareMetalCheckbox = await screen . findByRole ( 'checkbox' , {
128+ name : / B a r e m e t a l i n s t a l l e r / i,
129+ } ) ;
130+ expect ( bareMetalCheckbox ) . toBeDisabled ( ) ;
131+
132+ expect ( networkInstallerCheckbox ) . toBeChecked ( ) ;
133+ expect ( networkInstallerCheckbox ) . toBeEnabled ( ) ;
134+ } ) ;
135+
136+ test ( 'selecting another target first disables network-installer' , async ( ) => {
137+ await renderCreateMode ( ) ;
138+ await selectGuestImageTarget ( ) ;
139+
140+ const networkInstallerCheckbox = await screen . findByRole ( 'checkbox' , {
141+ name : / N e t w o r k i n s t a l l e r c h e c k b o x / i,
142+ } ) ;
143+ expect ( networkInstallerCheckbox ) . toBeDisabled ( ) ;
144+ } ) ;
145+
146+ test ( 'selecting network-installer only shows base settings, advanced settings, and review steps' , async ( ) => {
147+ await renderCreateMode ( ) ;
148+ await selectNetworkInstaller ( ) ;
149+
150+ const navigation = await screen . findByRole ( 'navigation' , {
151+ name : / w i z a r d s t e p s / i,
152+ } ) ;
153+
154+ const stepButtons = within ( navigation ) . getAllByRole ( 'button' ) ;
155+ expect ( stepButtons ) . toHaveLength ( 3 ) ;
156+
157+ expect (
158+ within ( navigation ) . getByRole ( 'button' , { name : / b a s e s e t t i n g s / i } ) ,
159+ ) . toBeInTheDocument ( ) ;
160+ expect (
161+ within ( navigation ) . getByRole ( 'button' , { name : / a d v a n c e d s e t t i n g s / i } ) ,
162+ ) . toBeInTheDocument ( ) ;
163+ expect (
164+ within ( navigation ) . getByRole ( 'button' , { name : / r e v i e w / i } ) ,
165+ ) . toBeInTheDocument ( ) ;
166+ } ) ;
167+
168+ test ( 'can create a blueprint with network-installer' , async ( ) => {
169+ await renderCreateMode ( ) ;
170+ await selectNetworkInstaller ( ) ;
171+ await enterBlueprintName ( 'Red Velvet' ) ;
172+
173+ await goToReview ( ) ;
174+
175+ const receivedRequest = await interceptBlueprintRequest ( CREATE_BLUEPRINT ) ;
176+
177+ const expectedRequest : CreateBlueprintRequest = {
178+ ...blueprintRequest ,
179+ distribution : RHEL_10 ,
180+ customizations : {
181+ locale : {
182+ languages : [ 'C.UTF-8' ] ,
183+ } ,
184+ } ,
185+ image_requests : [
186+ {
187+ architecture : 'x86_64' ,
188+ image_type : 'network-installer' ,
189+ upload_request : {
190+ options : { } ,
191+ type : 'aws.s3' ,
192+ } ,
193+ } ,
194+ ] ,
195+ } ;
196+
197+ expect ( receivedRequest ) . toEqual ( expectedRequest ) ;
198+ } ) ;
199+ } ) ;
0 commit comments