diff --git a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.html b/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.html deleted file mode 100644 index 3257ab5bdb..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.html +++ /dev/null @@ -1,22 +0,0 @@ -
- - - -
diff --git a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.scss b/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.scss deleted file mode 100644 index a5173469e5..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.scss +++ /dev/null @@ -1,66 +0,0 @@ -@import '../../../../theme/colors'; -.tooltip-container { - position: absolute; - z-index: 1000; - border-radius: 8px; - background: $white; - box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25); - color: $blue-black; - - .tooltip { - display: inline-flex; - padding: 16px; - flex-direction: column; - align-items: flex-start; - gap: 8px; - border-radius: 8px; - background: $white; - - &::before { - position: absolute; - bottom: 100%; - left: 50%; - transform: translateX(-50%); - border-width: 8px; - border-style: solid; - border-color: transparent transparent $white transparent; - filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.1)); - } - - &__text { - font-size: 12px; - font-style: normal; - font-weight: 500; - line-height: 1.25; - } - - &__list { - list-style: none; - padding: 0; - margin: 0; - font-size: 12px; - line-height: 1.25; - - &__check { - display: flex; - align-items: center; - align-content: center; - gap: 4px; - flex-wrap: wrap; - - &__icon { - width: 12px; - height: 12px; - } - - &__valid { - fill: $green; - } - - &__invalid { - fill: $grey-light; - } - } - } - } -} diff --git a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.spec.ts b/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.spec.ts deleted file mode 100644 index bbd2e56fd7..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.spec.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { IonicModule } from '@ionic/angular'; - -import { PasswordCheckTooltipComponent } from './password-check-tooltip.component'; -import { By } from '@angular/platform-browser'; - -describe('PasswordCheckTooltipComponent', () => { - let component: PasswordCheckTooltipComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [PasswordCheckTooltipComponent], - imports: [IonicModule.forRoot()], - }).compileComponents(); - - fixture = TestBed.createComponent(PasswordCheckTooltipComponent); - component = fixture.componentInstance; - component.passwordCriteria = [ - { - isValid: false, - message: '12 to 32 characters', - }, - { - isValid: false, - message: '1 uppercase character', - }, - { - isValid: false, - message: '1 lowercase character', - }, - { - isValid: false, - message: '1 number', - }, - { - isValid: false, - message: '1 special character', - }, - ]; - fixture.detectChanges(); - })); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('ngOnChanges(): should call validatePassword when ngOnChanges is triggered', () => { - spyOn(component, 'validatePassword'); - component.password = 'ValidPass123!'; - component.ngOnChanges(); - expect(component.validatePassword).toHaveBeenCalledTimes(1); - }); - - describe('validatePassword(): ', () => { - beforeEach(() => { - component.previousValidityState = true; - }); - - it('should fail when password length is less than 12 characters', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'Short1!'; - fixture.detectChanges(); - component.validatePassword(); - expect(component.passwordChecks.lengthValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should fail when password length is more than 32 characters', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'A'.repeat(33) + '1!'; - component.validatePassword(); - expect(component.passwordChecks.lengthValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should fail when password is missing an uppercase character', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'lowercase1!'; - component.validatePassword(); - expect(component.passwordChecks.uppercaseValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should fail when password is missing a lowercase character', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'UPPERCASE1!'; - component.validatePassword(); - expect(component.passwordChecks.lowercaseValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should fail when password is missing a numeric character', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'OnlyAlphabets!'; - component.validatePassword(); - expect(component.passwordChecks.numberValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should fail when password is missing a special character', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'NoSpecials1'; - component.validatePassword(); - expect(component.passwordChecks.specialCharValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - - it('should pass when password meets all criteria', () => { - component.previousValidityState = false; - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = 'ValidPass123!'; - component.validatePassword(); - expect(component.passwordChecks.lengthValid).toBeTrue(); - expect(component.passwordChecks.uppercaseValid).toBeTrue(); - expect(component.passwordChecks.lowercaseValid).toBeTrue(); - expect(component.passwordChecks.numberValid).toBeTrue(); - expect(component.passwordChecks.specialCharValid).toBeTrue(); - expect(emitSpy).toHaveBeenCalledWith(true); - }); - - it('should fail when password is empty', () => { - const emitSpy = spyOn(component.isPasswordValid, 'emit'); - component.password = ''; - component.validatePassword(); - expect(component.passwordChecks.lengthValid).toBeFalse(); - expect(component.passwordChecks.uppercaseValid).toBeFalse(); - expect(component.passwordChecks.lowercaseValid).toBeFalse(); - expect(component.passwordChecks.numberValid).toBeFalse(); - expect(component.passwordChecks.specialCharValid).toBeFalse(); - expect(emitSpy).toHaveBeenCalledWith(false); - }); - }); - - describe('template', () => { - it('should render the tooltip text and all checks when all validations are false', () => { - component.passwordChecks = { - lengthValid: false, - uppercaseValid: false, - lowercaseValid: false, - numberValid: false, - specialCharValid: false, - }; - fixture.detectChanges(); - - const tooltipText = fixture.debugElement.query(By.css('.tooltip__text')).nativeElement; - const listItems = fixture.debugElement.queryAll(By.css('.tooltip__list__check')); - expect(tooltipText.textContent).toContain('Password should contain:'); - expect(listItems.length).toBe(5); - }); - - it('should display valid icons for valid password checks', () => { - component.password = 'Somepass1'; - component.ngOnChanges(); - fixture.detectChanges(); - - const validIcons = fixture.debugElement.queryAll(By.css('.tooltip__list__check__valid')); - expect(validIcons.length).toBe(3); - const invalidIcons = fixture.debugElement.queryAll(By.css('.tooltip__list__check__invalid')); - expect(invalidIcons.length).toBe(2); - }); - }); -}); diff --git a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.ts b/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.ts deleted file mode 100644 index d86071ed2f..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-check-tooltip.component.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Component, Input, Output, EventEmitter, OnChanges } from '@angular/core'; -import { PasswordChecks } from './password-checks.model'; -import { PasswordCriteria } from './password-criteria.model'; - -@Component({ - selector: 'app-password-check-tooltip', - templateUrl: './password-check-tooltip.component.html', - styleUrls: ['./password-check-tooltip.component.scss'], -}) -export class PasswordCheckTooltipComponent implements OnChanges { - @Input() password: string; - - @Output() isPasswordValid = new EventEmitter(); - - previousValidityState = false; - - passwordChecks: PasswordChecks = { - lengthValid: false, - uppercaseValid: false, - lowercaseValid: false, - numberValid: false, - specialCharValid: false, - }; - - passwordCriteria: PasswordCriteria[]; - - updatePasswordCriteria(): void { - this.passwordCriteria = [ - { - isValid: this.passwordChecks.lengthValid, - message: '12 to 32 characters', - }, - { - isValid: this.passwordChecks.uppercaseValid, - message: '1 uppercase character', - }, - { - isValid: this.passwordChecks.lowercaseValid, - message: '1 lowercase character', - }, - { - isValid: this.passwordChecks.numberValid, - message: '1 number', - }, - { - isValid: this.passwordChecks.specialCharValid, - message: '1 special character', - }, - ]; - } - - ngOnChanges(): void { - this.validatePassword(); - } - - validatePassword(): void { - if (!this.password) { - Object.keys(this.passwordChecks).forEach((key) => { - this.passwordChecks[key as keyof PasswordChecks] = false; - }); - this.isPasswordValid.emit(false); - return; - } - - const specialCharRegex = /[!@#$%^&*()+\-:;<=>{}|~?]/; - - this.passwordChecks.lengthValid = this.password.length >= 12 && this.password.length <= 32; - this.passwordChecks.uppercaseValid = /[A-Z]/.test(this.password); - this.passwordChecks.lowercaseValid = /[a-z]/.test(this.password); - this.passwordChecks.numberValid = /[0-9]/.test(this.password); - this.passwordChecks.specialCharValid = specialCharRegex.test(this.password); - - this.updatePasswordCriteria(); - // Using Boolean() with every() ensures strict boolean comparison for all password criteria - const allValid = Object.values(this.passwordChecks).every(Boolean); - if (allValid !== this.previousValidityState) { - this.isPasswordValid.emit(allValid); - } - this.previousValidityState = allValid; - } -} diff --git a/src/app/shared/components/password-check-tooltip/password-checks.model.ts b/src/app/shared/components/password-check-tooltip/password-checks.model.ts deleted file mode 100644 index 95f81f5589..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-checks.model.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface PasswordChecks { - lengthValid: boolean; - uppercaseValid: boolean; - lowercaseValid: boolean; - numberValid: boolean; - specialCharValid: boolean; -} diff --git a/src/app/shared/components/password-check-tooltip/password-criteria.model.ts b/src/app/shared/components/password-check-tooltip/password-criteria.model.ts deleted file mode 100644 index da2c4693ee..0000000000 --- a/src/app/shared/components/password-check-tooltip/password-criteria.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface PasswordCriteria { - isValid: boolean; - message: string; -}