File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
contentcuration/contentcuration/frontend Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,10 @@ describe('resetPassword', () => {
3939 } ) ;
4040 it ( 'should call setPassword on submit if password data is valid' , ( ) => {
4141 wrapper . setData ( { new_password1 : 'pass' , new_password2 : 'pass' } ) ;
42- wrapper . find ( { ref : 'form' } ) . trigger ( 'submit' ) ;
43- expect ( setPassword ) . toHaveBeenCalled ( ) ;
42+ wrapper . vm . $nextTick ( ( ) => {
43+ wrapper . find ( { ref : 'form' } ) . trigger ( 'submit' ) ;
44+ expect ( setPassword ) . toHaveBeenCalled ( ) ;
45+ } ) ;
4446 } ) ;
4547 it ( 'should retain data from query params so reset credentials are preserved' , ( ) => {
4648 router . replace ( {
@@ -50,7 +52,9 @@ describe('resetPassword', () => {
5052 } ,
5153 } ) ;
5254 wrapper . setData ( { new_password1 : 'pass' , new_password2 : 'pass' } ) ;
53- wrapper . find ( { ref : 'form' } ) . trigger ( 'submit' ) ;
54- expect ( setPassword . mock . calls [ 0 ] [ 0 ] . test ) . toBe ( 'testing' ) ;
55+ wrapper . vm . $nextTick ( ( ) => {
56+ wrapper . find ( { ref : 'form' } ) . trigger ( 'submit' ) ;
57+ expect ( setPassword . mock . calls [ 0 ] [ 0 ] . test ) . toBe ( 'testing' ) ;
58+ } ) ;
5559 } ) ;
5660} ) ;
Original file line number Diff line number Diff line change 99 <PasswordField
1010 v-model =" new_password1"
1111 :label =" $tr('passwordLabel')"
12+ :additionalRules =" passwordValidationRules"
1213 autofocus
1314 />
1415 <PasswordField
5253 passwordConfirmRules () {
5354 return [value => (this .new_password1 === value ? true : this .$tr (' passwordMatchMessage' ))];
5455 },
56+ passwordValidationRules () {
57+ return [value => (value .length >= 8 ? true : this .$tr (' passwordValidationMessage' ))];
58+ },
5559 },
5660 methods: {
5761 ... mapActions (' account' , [' setPassword' ]),
8084 resetPasswordPrompt: ' Enter and confirm your new password' ,
8185 passwordLabel: ' New password' ,
8286 passwordConfirmLabel: ' Confirm password' ,
87+ passwordValidationMessage: ' Password should be at least 8 characters long' ,
8388 passwordMatchMessage: " Passwords don't match" ,
8489 submitButton: ' Submit' ,
8590 resetPasswordFailed: ' Failed to reset password. Please try again.' ,
Original file line number Diff line number Diff line change 88 @submit =" submitPassword"
99 @cancel =" dialog = false"
1010 >
11- <VForm ref =" form" >
11+ <!-- inline style here avoids scrollbar on validations -->
12+ <VForm ref =" form" style =" height : 196px " >
1213 <PasswordField
1314 v-model =" password"
15+ :additionalRules =" passwordValidationRules"
1416 :label =" $tr('newPasswordLabel')"
1517 />
1618 <PasswordField
5254 this .$emit (' input' , value);
5355 },
5456 },
57+ passwordValidationRules () {
58+ return [value => (value .length >= 8 ? true : this .$tr (' passwordValidationMessage' ))];
59+ },
5560 passwordConfirmRules () {
5661 return [value => (this .password === value ? true : this .$tr (' formInvalidText' ))];
5762 },
8691 newPasswordLabel: ' New password' ,
8792 confirmNewPasswordLabel: ' Confirm new password' ,
8893 formInvalidText: " Passwords don't match" ,
94+ passwordValidationMessage: ' Password should be at least 8 characters long' ,
8995 cancelAction: ' Cancel' ,
9096 saveChangesAction: ' Save changes' ,
9197 paswordChangeSuccess: ' Password updated' ,
You can’t perform that action at this time.
0 commit comments