@@ -8,6 +8,8 @@ import { shallowMount } from '@vue/test-utils'
88import type { VueWrapper } from '@vue/test-utils'
99import CreateAccount from '../../views/CreateAccount.vue'
1010import md5 from 'blueimp-md5'
11+ import axios from '@nextcloud/axios'
12+ import { generateOcsUrl } from '@nextcloud/router'
1113
1214type ValidationField = {
1315 $model : string
@@ -82,8 +84,12 @@ describe('CreateAccount.vue - Business Logic', () => {
8284 }
8385
8486 let wrapper ! : CreateAccountWrapper
87+ const axiosPostMock = vi . mocked ( axios . post )
88+ const generateOcsUrlMock = vi . mocked ( generateOcsUrl )
8589
8690 beforeEach ( ( ) => {
91+ axiosPostMock . mockReset ( )
92+ generateOcsUrlMock . mockClear ( )
8793 wrapper = shallowMount ( CreateAccount , {
8894 global : {
8995 mocks : {
@@ -486,5 +492,35 @@ describe('CreateAccount.vue - Business Logic', () => {
486492
487493 expect ( wrapper . vm . canSave ) . toBe ( false )
488494 } )
495+
496+ it ( 'posts create-account request with interpolated sign request uuid' , async ( ) => {
497+ axiosPostMock . mockRejectedValue ( {
498+ response : {
499+ data : {
500+ ocs : {
501+ data : {
502+ message : 'Invalid UUID' ,
503+ } ,
504+ } ,
505+ } ,
506+ } ,
507+ } )
508+
509+ await wrapper . setData ( {
510+ email : 'test@example.com' ,
511+ password : 'validPassword123' ,
512+ passwordConfirm : 'validPassword123' ,
513+ } )
514+
515+ await wrapper . vm . createAccount ( )
516+
517+ expect ( generateOcsUrlMock ) . toHaveBeenCalledWith ( '/apps/libresign/api/v1/account/create/{uuid}' , {
518+ uuid : 'test-uuid' ,
519+ } )
520+ expect ( axiosPostMock ) . toHaveBeenCalledWith ( '/apps/libresign/api/v1/account/create/{uuid}' , {
521+ email : 'test@example.com' ,
522+ password : 'validPassword123' ,
523+ } )
524+ } )
489525 } )
490526} )
0 commit comments