@@ -69,6 +69,7 @@ const renderComponent = (
6969 hardwareProfiles : HardwareProfileKind [ ] ,
7070 currentProject : ProjectKind ,
7171 isKueueEnabled : boolean ,
72+ allowExistingSettings = false ,
7273) => {
7374 useIsAreaAvailableMock . mockReturnValue ( {
7475 status : isKueueEnabled ,
@@ -112,7 +113,7 @@ const renderComponent = (
112113 hardwareProfilesLoaded
113114 hardwareProfilesError = { undefined }
114115 projectScopedHardwareProfiles = { [ [ ] , true , undefined , ( ) => Promise . resolve ( ) ] }
115- allowExistingSettings = { false }
116+ allowExistingSettings = { allowExistingSettings }
116117 hardwareProfileConfig = { hardwareProfileConfig }
117118 isHardwareProfileSupported = { ( ) => true }
118119 onChange = { ( ) => null }
@@ -161,3 +162,32 @@ describe('HardwareProfileSelect filtering', () => {
161162 expect ( screen . getByText ( 'Node Profile 2' ) ) . toBeInTheDocument ( ) ;
162163 } ) ;
163164} ) ;
165+
166+ describe ( 'HardwareProfileSelect - Use existing settings' , ( ) => {
167+ it ( 'should not show "Use existing settings" as the first option when allowExistingSettings is false' , async ( ) => {
168+ const project = mockProjectK8sResource ( { } ) ;
169+ renderComponent ( [ nodeHardwareProfile , nodeHardwareProfile2 ] , project , false , false ) ;
170+
171+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Options menu' } ) ) ;
172+
173+ const options = screen . getAllByRole ( 'option' ) ;
174+ expect ( screen . queryByText ( 'Use existing settings' ) ) . not . toBeInTheDocument ( ) ;
175+ expect ( options [ 0 ] ) . toHaveTextContent ( 'Node Profile' ) ;
176+ expect ( options [ 1 ] ) . toHaveTextContent ( 'Node Profile 2' ) ;
177+ } ) ;
178+
179+ it ( 'should show "Use existing settings" as the first option when allowExistingSettings is true' , async ( ) => {
180+ const project = mockProjectK8sResource ( { } ) ;
181+ project . metadata . labels ??= { } ;
182+ project . metadata . labels [ KnownLabels . KUEUE_MANAGED ] = 'true' ;
183+
184+ renderComponent ( [ nodeHardwareProfile , nodeHardwareProfile2 ] , project , false , true ) ;
185+
186+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Options menu' } ) ) ;
187+
188+ const options = screen . getAllByRole ( 'option' ) ;
189+ expect ( options [ 0 ] ) . toHaveTextContent ( 'Use existing settings' ) ;
190+ expect ( options [ 1 ] ) . toHaveTextContent ( 'Node Profile' ) ;
191+ expect ( options [ 2 ] ) . toHaveTextContent ( 'Node Profile 2' ) ;
192+ } ) ;
193+ } ) ;
0 commit comments