@@ -113,14 +113,8 @@ describe('UserEditor', () => {
113113 expect . anything ( ) ,
114114 expect . objectContaining ( {
115115 body : JSON . stringify ( {
116- slurm_accounts : [ ] ,
117116 project_dir : '/path/to/project/dir' ,
118- slurm_user : 'user' ,
119- ssh_host : null ,
120- ssh_username : null ,
121- ssh_private_key_path : null ,
122- ssh_tasks_dir : null ,
123- ssh_jobs_dir : null
117+ slurm_user : 'user'
124118 } )
125119 } )
126120 ) ;
@@ -182,14 +176,7 @@ describe('UserEditor', () => {
182176 expect . anything ( ) ,
183177 expect . objectContaining ( {
184178 body : JSON . stringify ( {
185- slurm_accounts : [ ] ,
186- project_dir : 'xxx' ,
187- slurm_user : null ,
188- ssh_host : null ,
189- ssh_username : null ,
190- ssh_private_key_path : null ,
191- ssh_tasks_dir : null ,
192- ssh_jobs_dir : null
179+ project_dir : 'xxx'
193180 } )
194181 } )
195182 ) ;
@@ -216,39 +203,66 @@ describe('UserEditor', () => {
216203 ...initialSettings ,
217204 ssh_host : 'localhost' ,
218205 ssh_username : 'username' ,
219- ssh_private_key_path : '/path/to/private/key' ,
220- ssh_tasks_dir : '/path/to/tasks/dir' ,
221- ssh_jobs_dir : '/path/to/jobs/dir'
206+ ssh_private_key_path : '/path/to/private/key'
222207 } )
223208 )
224209 } ) ;
225210
226211 await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH host' } ) , 'localhost' ) ;
227212 await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH username' } ) , 'username' ) ;
228213 await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Private Key Path' } ) , 'xxx' ) ;
229- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Tasks Dir' } ) , 'yyy' ) ;
230- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Jobs Dir' } ) , 'zzz' ) ;
231214 await user . click ( screen . getByRole ( 'button' , { name : 'Save' } ) ) ;
232215 await screen . findByText ( 'User successfully updated' ) ;
233216
234217 expect ( mockRequest ) . toHaveBeenCalledWith (
235218 expect . anything ( ) ,
236219 expect . objectContaining ( {
237220 body : JSON . stringify ( {
238- slurm_accounts : [ ] ,
239- project_dir : null ,
240- slurm_user : null ,
241221 ssh_host : 'localhost' ,
242222 ssh_username : 'username' ,
243- ssh_private_key_path : 'xxx' ,
244- ssh_tasks_dir : 'yyy' ,
245- ssh_jobs_dir : 'zzz'
223+ ssh_private_key_path : 'xxx'
246224 } )
247225 } )
248226 ) ;
249227 } ) ;
250228
251229 it ( 'Update settings with slurm_ssh runner backend - validation error' , async ( ) => {
230+ const mockRequest = /** @type {import('vitest').Mock } */ ( fetch )
231+ . mockResolvedValueOnce ( {
232+ ok : true ,
233+ status : 200 ,
234+ // mock profile
235+ json : ( ) => new Promise ( ( resolve ) => resolve ( { id : 1 , resource_id : 1 } ) )
236+ } )
237+ . mockResolvedValueOnce ( {
238+ ok : true ,
239+ status : 200 ,
240+ // mock resources
241+ json : ( ) => new Promise ( ( resolve ) => resolve ( [ { id : 1 } ] ) )
242+ } )
243+ . mockResolvedValueOnce ( {
244+ ok : true ,
245+ status : 200 ,
246+ // mock profiles
247+ json : ( ) => new Promise ( ( resolve ) => resolve ( [ { id : 1 } ] ) )
248+ } )
249+ . mockResolvedValueOnce ( {
250+ ok : false ,
251+ status : 422 ,
252+ json : ( ) =>
253+ new Promise ( ( resolve ) =>
254+ resolve ( {
255+ detail : [
256+ {
257+ loc : [ 'body' , 'ssh_private_key_path' ] ,
258+ msg : 'mock_error_ssh_private_key_path' ,
259+ type : 'value_error'
260+ }
261+ ]
262+ } )
263+ )
264+ } ) ;
265+
252266 const user = userEvent . setup ( ) ;
253267
254268 render ( UserEditor , {
@@ -260,58 +274,22 @@ describe('UserEditor', () => {
260274 }
261275 } ) ;
262276
263- const mockRequest = /** @type {import('vitest').Mock } */ ( fetch ) . mockResolvedValue ( {
264- ok : false ,
265- status : 422 ,
266- json : ( ) =>
267- new Promise ( ( resolve ) =>
268- resolve ( {
269- detail : [
270- {
271- loc : [ 'body' , 'ssh_private_key_path' ] ,
272- msg : 'mock_error_ssh_private_key_path' ,
273- type : 'value_error'
274- } ,
275- {
276- loc : [ 'body' , 'ssh_tasks_dir' ] ,
277- msg : 'mock_error_ssh_tasks_dir' ,
278- type : 'value_error'
279- } ,
280- {
281- loc : [ 'body' , 'ssh_jobs_dir' ] ,
282- msg : 'mock_error_ssh_jobs_dir' ,
283- type : 'value_error'
284- }
285- ]
286- } )
287- )
288- } ) ;
289-
290277 await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH host' } ) , 'localhost' ) ;
291278 await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH username' } ) , 'username' ) ;
292279 await user . type (
293280 screen . getByRole ( 'textbox' , { name : 'SSH Private Key Path' } ) ,
294281 '/path/to/private/key'
295282 ) ;
296- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Tasks Dir' } ) , '/path/to/tasks/dir' ) ;
297- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Jobs Dir' } ) , '/path/to/jobs/dir' ) ;
298283 await user . click ( screen . getByRole ( 'button' , { name : 'Save' } ) ) ;
299284 await screen . findByText ( 'mock_error_ssh_private_key_path' ) ;
300- await screen . findByText ( 'mock_error_ssh_tasks_dir' ) ;
301- await screen . findByText ( 'mock_error_ssh_jobs_dir' ) ;
302285
303286 expect ( mockRequest ) . toHaveBeenCalledWith (
304287 expect . anything ( ) ,
305288 expect . objectContaining ( {
306289 body : JSON . stringify ( {
307- slurm_accounts : [ ] ,
308- project_dir : null ,
309- slurm_user : null ,
310290 ssh_host : 'localhost' ,
311291 ssh_username : 'username' ,
312- ssh_private_key_path : '/path/to/private/key' ,
313- ssh_tasks_dir : '/path/to/tasks/dir' ,
314- ssh_jobs_dir : '/path/to/jobs/dir'
292+ ssh_private_key_path : '/path/to/private/key'
315293 } )
316294 } )
317295 ) ;
0 commit comments