Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into release-2211.32.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rmch91 committed Nov 29, 2024
2 parents d4c916f + 6e16fc3 commit 5335110
Show file tree
Hide file tree
Showing 22 changed files with 253 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ describe('OrderGuestRegisterFormComponent', () => {
cxMinOneDigit: true,
cxMinOneUpperCaseCharacter: true,
cxMinOneSpecialCharacter: true,
cxMinSixCharactersLength: true,
cxMinEightCharactersLength: true,
cxMaxCharactersLength: true,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { Component, Input, OnDestroy, inject } from '@angular/core';
import { Component, inject, Input, OnDestroy } from '@angular/core';
import {
UntypedFormBuilder,
UntypedFormGroup,
Expand All @@ -31,20 +31,24 @@ export class OrderGuestRegisterFormComponent implements OnDestroy {
protected passwordValidators = this.featureConfigService?.isEnabled(
'formErrorsDescriptiveMessages'
)
? this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
? this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidators
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
: [
this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidator
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
];

@Input() guid: string;
Expand Down
3 changes: 2 additions & 1 deletion feature-libs/user/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = function (config) {
global: {
statements: 90,
lines: 90,
branches: 75,
//TODO CXSPA-8984 change branches to 75 after fix
branches: 70,
functions: 80,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,10 @@ describe('RegisterComponent', () => {
expect(validators).toEqual({
required: true,
cxMinOneDigit: true,
cxMinOneUpperCaseCharacter: true,
cxMinOneSpecialCharacter: true,
cxMinSixCharactersLength: true,
cxMinOneUpperCaseCharacter: true,
cxMinEightCharactersLength: true,
cxMaxCharactersLength: true,
});
});

Expand Down
30 changes: 17 additions & 13 deletions feature-libs/user/profile/components/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,24 @@ export class RegisterComponent implements OnInit, OnDestroy {
protected passwordValidators = this.featureConfigService?.isEnabled(
'formErrorsDescriptiveMessages'
)
? this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
? this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidators
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
: [
this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidator
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
];

titles$: Observable<Title[]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ describe('ResetPasswordComponentService', () => {
describe('reset', () => {
describe('success', () => {
beforeEach(() => {
password.setValue('Qwe123!');
passwordConfirm.setValue('Qwe123!');
password.setValue('QwePas123!');
passwordConfirm.setValue('QwePas123!');
});

it('should reset password', () => {
spyOn(userPasswordService, 'reset').and.callThrough();
service.resetPassword(resetToken);
expect(userPasswordService.reset).toHaveBeenCalledWith(
resetToken,
'Qwe123!'
'QwePas123!'
);
});

Expand All @@ -177,8 +177,8 @@ describe('ResetPasswordComponentService', () => {
describe('error', () => {
describe('valid form', () => {
beforeEach(() => {
password.setValue('Qwe123!');
passwordConfirm.setValue('Qwe123!');
password.setValue('QwePas123!');
passwordConfirm.setValue('QwePas123!');
});

it('should show error message', () => {
Expand Down Expand Up @@ -239,7 +239,8 @@ describe('ResetPasswordComponentService', () => {
cxMinOneDigit: true,
cxMinOneUpperCaseCharacter: true,
cxMinOneSpecialCharacter: true,
cxMinSixCharactersLength: true,
cxMinEightCharactersLength: true,
cxMaxCharactersLength: true,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,24 @@ export class ResetPasswordComponentService {
protected passwordValidators = this.featureConfigService?.isEnabled(
'formErrorsDescriptiveMessages'
)
? this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
? this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidators
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
: [
this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidator
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
];

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ describe('UpdatePasswordComponentService', () => {
describe('updatePassword', () => {
describe('success', () => {
beforeEach(() => {
oldPassword.setValue('Old123!');
newPassword.setValue('New123!');
newPasswordConfirm.setValue('New123!');
oldPassword.setValue('OldPas123!');
newPassword.setValue('NewPas123!');
newPasswordConfirm.setValue('NewPas123!');
});

it('should update password', () => {
service.updatePassword();
expect(userPasswordFacade.update).toHaveBeenCalledWith(
'Old123!',
'New123!'
'OldPas123!',
'NewPas123!'
);
});

Expand Down Expand Up @@ -201,7 +201,8 @@ describe('UpdatePasswordComponentService', () => {
cxMinOneDigit: true,
cxMinOneUpperCaseCharacter: true,
cxMinOneSpecialCharacter: true,
cxMinSixCharactersLength: true,
cxMinEightCharactersLength: true,
cxMaxCharactersLength: true,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@ export class UpdatePasswordComponentService {
protected passwordValidators = this.featureConfigService?.isEnabled(
'formErrorsDescriptiveMessages'
)
? this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
? this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidators
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? [
...CustomFormValidators.passwordValidators,
CustomFormValidators.noConsecutiveCharacters,
]
: CustomFormValidators.passwordValidators
: [
this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
this.featureConfigService.isEnabled('enableSecurePasswordValidation')
? CustomFormValidators.securePasswordValidator
: this.featureConfigService.isEnabled(
'enableConsecutiveCharactersPasswordRequirement'
)
? CustomFormValidators.strongPasswordValidator
: CustomFormValidators.passwordValidator,
];

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ describe('OpfResourceLoaderService', () => {
}
);

opfResourceLoaderService.loadResources([mockScriptResource]);
opfResourceLoaderService
.loadResources([mockScriptResource])
.then(() => {})
.catch(() => {});

expect(opfResourceLoaderService['loadStyles']).not.toHaveBeenCalled();
expect(opfResourceLoaderService['loadScript']).toHaveBeenCalled();
Expand Down Expand Up @@ -207,7 +210,10 @@ describe('OpfResourceLoaderService', () => {
}
);

opfResourceLoaderService.loadResources([], [mockStylesResources]);
opfResourceLoaderService
.loadResources([], [mockStylesResources])
.then(() => {})
.catch(() => {});

expect(opfResourceLoaderService['loadScript']).not.toHaveBeenCalled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ export class OpfResourceLoaderService {
}
);

return Promise.all(resourcesPromises)
.then(() => {})
.catch(() => {});
return Promise.all(resourcesPromises).then(() => {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export class OpfCheckoutPaymentWrapperService {
if (html) {
this.executeScriptFromHtml(html);
}
})
.catch(() => {
this.handleGeneralPaymentError().pipe(take(1)).subscribe();
});
return;
}
Expand Down
2 changes: 2 additions & 0 deletions projects/assets/src/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@
"cxMinOneDigit": "Password must contain at least one digit",
"cxMinOneSpecialCharacter": "Password must contain at least one special character",
"cxMinSixCharactersLength": "Password must contain at least 6 characters",
"cxMinEightCharactersLength": "Password must contain at least 8 characters",
"cxMaxCharactersLength": "Password cannot have more than 128 characters",
"cxContainsSpecialCharacters": "Password cannot contain special characters",
"cxNoConsecutiveCharacters": "Password cannot contain consecutive identical characters",
"date": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ export interface FeatureTogglesInterface {
* Moves components to be children of this section element.
*/
a11yWrapReviewOrderInSection?: boolean;

enableSecurePasswordValidation?: boolean;
}

export const defaultFeatureToggles: Required<FeatureTogglesInterface> = {
Expand Down Expand Up @@ -963,4 +965,5 @@ export const defaultFeatureToggles: Required<FeatureTogglesInterface> = {
sciEnabled: false,
useExtendedMediaComponentConfiguration: false,
showRealTimeStockInPDP: false,
enableSecurePasswordValidation: false,
};
7 changes: 7 additions & 0 deletions projects/core/src/util/regex-pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ export const MIN_ONE_SPECIAL_CHARACTER_PATTERN =

export const MIN_SIX_CHARACTERS_PATTERN = /^.{6,}$/;

export const MIN_EIGHT_CHARACTERS_PATTERN = /^.{8,}$/;

export const MAX_CHARACTERS_PATTERN = /^.{0,128}$/;

export const CONSECUTIVE_CHARACTERS = /(.)\1+/;

export const STRONG_PASSWORD_PATTERN =
/^(?!.*(.)\1)(?=.*?[A-Z])(?=.*?\d)(?=.*?[!@#$%^*()_\-+{};:.,]).{6,}$/;

export const SECURE_PASSWORD_PATTERN =
/^(?!.*(.)\1)(?=.*?[A-Z])(?=.*?\d)(?=.*?[!@#$%^*()_\-+{};:.,]).{8,128}$/;
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ if (environment.cpq) {
useExtendedMediaComponentConfiguration: true,
showRealTimeStockInPDP: false,
a11yWrapReviewOrderInSection: true,
enableSecurePasswordValidation: true,
};
return appFeatureToggles;
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {
import { Facet, FacetValue, FeatureConfigService } from '@spartacus/core';
import { Observable } from 'rxjs';
import { ICON_TYPE } from '../../../../../cms-components/misc/icon/icon.model';
import { FocusDirective } from '../../../../../layout/a11y/keyboard-focus/focus.directive';
import {
FocusDirective,
disableTabbingForTick,
} from '../../../../../layout/a11y';
import { FacetCollapseState } from '../facet.model';
import { FacetService } from '../services/facet.service';

Expand Down Expand Up @@ -153,7 +156,21 @@ export class FacetComponent implements AfterViewInit {
case 'ArrowUp':
this.onArrowUp(event, targetIndex);
break;
case 'Tab':
this.onTabNavigation();
break;
}
}

/**
* If a11yTabComponent is enabled, we temporarily disable tabbing for the facet values.
* This is to use proper keyboard navigation keys(ArrowUp/ArrowDown) for navigating through the facet values.
*/
protected onTabNavigation(): void {
if (!this.featureConfigService?.isEnabled('a11yTabComponent')) {
return;
}
disableTabbingForTick(this.values.map((el) => el.nativeElement));
}

/**
Expand Down
1 change: 1 addition & 0 deletions projects/storefrontlib/layout/a11y/keyboard-focus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { FocusConfig, TrapFocus, TrapFocusType } from './keyboard-focus.model';
export * from './keyboard-focus.module';
export * from './focus-testing.module';
export * from './services/index';
export * from './keyboard-focus.utils';

// export * from './autofocus/index';
// export * from './base/index';
Expand Down
Loading

0 comments on commit 5335110

Please sign in to comment.