@@ -46,21 +46,15 @@ describe('UserEditor', () => {
4646 /** @type {import('fractal-components/types/api').UserSettings } */
4747 const initialSettings = {
4848 slurm_accounts : [ ] ,
49- project_dir : null ,
50- slurm_user : null ,
51- ssh_host : null ,
52- ssh_username : null ,
53- ssh_private_key_path : null ,
54- ssh_tasks_dir : null ,
55- ssh_jobs_dir : null
49+ project_dir : null
5650 } ;
5751
5852 /**
5953 * @type {() => Promise<Response> }
6054 */
6155 const mockSaveUser = vi . fn ( ) ;
6256
63- it ( 'Update settings with slurm_sudo runner backend - success' , async ( ) => {
57+ it ( 'Update settings - success' , async ( ) => {
6458 const mockRequest = /** @type {import('vitest').Mock } */ ( fetch )
6559 . mockResolvedValueOnce ( {
6660 ok : true ,
@@ -105,22 +99,21 @@ describe('UserEditor', () => {
10599 } ) ;
106100
107101 await user . type ( screen . getByRole ( 'textbox' , { name : 'Project dir' } ) , '/path/to/project/dir' ) ;
108- await user . type ( screen . getByRole ( 'textbox' , { name : 'SLURM user' } ) , 'user' ) ;
109102 await user . click ( screen . getByRole ( 'button' , { name : 'Save' } ) ) ;
110103 await screen . findByText ( 'User successfully updated' ) ;
111104
112105 expect ( mockRequest ) . toHaveBeenCalledWith (
113106 expect . anything ( ) ,
114107 expect . objectContaining ( {
115108 body : JSON . stringify ( {
116- project_dir : '/path/to/project/dir' ,
117- slurm_user : 'user '
109+ slurm_accounts : [ ] ,
110+ project_dir : '/path/to/project/dir '
118111 } )
119112 } )
120113 ) ;
121114 } ) ;
122115
123- it ( 'Update settings with slurm_sudo runner backend - validation error' , async ( ) => {
116+ it ( 'Update settings - validation error' , async ( ) => {
124117 const mockRequest = /** @type {import('vitest').Mock } */ ( fetch )
125118 . mockResolvedValueOnce ( {
126119 ok : true ,
@@ -176,122 +169,10 @@ describe('UserEditor', () => {
176169 expect . anything ( ) ,
177170 expect . objectContaining ( {
178171 body : JSON . stringify ( {
172+ slurm_accounts : [ ] ,
179173 project_dir : 'xxx'
180174 } )
181175 } )
182176 ) ;
183177 } ) ;
184-
185- it ( 'Update settings with slurm_ssh runner backend - success' , async ( ) => {
186- const user = userEvent . setup ( ) ;
187-
188- render ( UserEditor , {
189- props : {
190- runnerBackend : 'slurm_ssh' ,
191- user : selectedUser ,
192- settings : { ...initialSettings } ,
193- saveUser : mockSaveUser
194- }
195- } ) ;
196-
197- const mockRequest = /** @type {import('vitest').Mock } */ ( fetch ) . mockResolvedValue ( {
198- ok : true ,
199- status : 200 ,
200- json : ( ) =>
201- new Promise ( ( resolve ) =>
202- resolve ( {
203- ...initialSettings ,
204- ssh_host : 'localhost' ,
205- ssh_username : 'username' ,
206- ssh_private_key_path : '/path/to/private/key'
207- } )
208- )
209- } ) ;
210-
211- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH host' } ) , 'localhost' ) ;
212- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH username' } ) , 'username' ) ;
213- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH Private Key Path' } ) , 'xxx' ) ;
214- await user . click ( screen . getByRole ( 'button' , { name : 'Save' } ) ) ;
215- await screen . findByText ( 'User successfully updated' ) ;
216-
217- expect ( mockRequest ) . toHaveBeenCalledWith (
218- expect . anything ( ) ,
219- expect . objectContaining ( {
220- body : JSON . stringify ( {
221- ssh_host : 'localhost' ,
222- ssh_username : 'username' ,
223- ssh_private_key_path : 'xxx'
224- } )
225- } )
226- ) ;
227- } ) ;
228-
229- 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-
266- const user = userEvent . setup ( ) ;
267-
268- render ( UserEditor , {
269- props : {
270- runnerBackend : 'slurm_ssh' ,
271- user : selectedUser ,
272- settings : { ...initialSettings } ,
273- saveUser : mockSaveUser
274- }
275- } ) ;
276-
277- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH host' } ) , 'localhost' ) ;
278- await user . type ( screen . getByRole ( 'textbox' , { name : 'SSH username' } ) , 'username' ) ;
279- await user . type (
280- screen . getByRole ( 'textbox' , { name : 'SSH Private Key Path' } ) ,
281- '/path/to/private/key'
282- ) ;
283- await user . click ( screen . getByRole ( 'button' , { name : 'Save' } ) ) ;
284- await screen . findByText ( 'mock_error_ssh_private_key_path' ) ;
285-
286- expect ( mockRequest ) . toHaveBeenCalledWith (
287- expect . anything ( ) ,
288- expect . objectContaining ( {
289- body : JSON . stringify ( {
290- ssh_host : 'localhost' ,
291- ssh_username : 'username' ,
292- ssh_private_key_path : '/path/to/private/key'
293- } )
294- } )
295- ) ;
296- } ) ;
297178} ) ;
0 commit comments