Fix password keyup on togglevisible button empties password
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
|||||||
NgbActiveModal,
|
NgbActiveModal,
|
||||||
NgbModal,
|
NgbModal,
|
||||||
NgbModalModule,
|
NgbModalModule,
|
||||||
NgbModalRef,
|
|
||||||
} from '@ng-bootstrap/ng-bootstrap'
|
} from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { HttpClientModule } from '@angular/common/http'
|
import { HttpClientModule } from '@angular/common/http'
|
||||||
import { TextComponent } from '../input/text/text.component'
|
import { TextComponent } from '../input/text/text.component'
|
||||||
@@ -36,7 +35,6 @@ describe('ProfileEditDialogComponent', () => {
|
|||||||
let profileService: ProfileService
|
let profileService: ProfileService
|
||||||
let toastService: ToastService
|
let toastService: ToastService
|
||||||
let clipboard: Clipboard
|
let clipboard: Clipboard
|
||||||
let modalService: NgbModal
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -57,7 +55,6 @@ describe('ProfileEditDialogComponent', () => {
|
|||||||
profileService = TestBed.inject(ProfileService)
|
profileService = TestBed.inject(ProfileService)
|
||||||
toastService = TestBed.inject(ToastService)
|
toastService = TestBed.inject(ToastService)
|
||||||
clipboard = TestBed.inject(Clipboard)
|
clipboard = TestBed.inject(Clipboard)
|
||||||
modalService = TestBed.inject(NgbModal)
|
|
||||||
fixture = TestBed.createComponent(ProfileEditDialogComponent)
|
fixture = TestBed.createComponent(ProfileEditDialogComponent)
|
||||||
component = fixture.componentInstance
|
component = fixture.componentInstance
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
@@ -138,7 +135,10 @@ describe('ProfileEditDialogComponent', () => {
|
|||||||
getSpy.mockReturnValue(of(profile))
|
getSpy.mockReturnValue(of(profile))
|
||||||
component.ngOnInit()
|
component.ngOnInit()
|
||||||
component.form.get('password').patchValue('new*pass')
|
component.form.get('password').patchValue('new*pass')
|
||||||
component.onPasswordKeyUp({ target: { value: 'new*pass' } } as any)
|
component.onPasswordKeyUp({
|
||||||
|
target: { value: 'new*pass', tagName: 'input' },
|
||||||
|
} as any)
|
||||||
|
component.onPasswordKeyUp({ target: { tagName: 'button' } } as any) // coverage
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(component.form.get('password_confirm').enabled).toBeTruthy()
|
expect(component.form.get('password_confirm').enabled).toBeTruthy()
|
||||||
expect(fixture.debugElement.nativeElement.textContent).toContain(
|
expect(fixture.debugElement.nativeElement.textContent).toContain(
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export class ProfileEditDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onPasswordKeyUp(event: KeyboardEvent): void {
|
onPasswordKeyUp(event: KeyboardEvent): void {
|
||||||
|
if ((event.target as HTMLElement).tagName !== 'input') return // toggle button can trigger this handler
|
||||||
this.newPassword = (event.target as HTMLInputElement)?.value
|
this.newPassword = (event.target as HTMLInputElement)?.value
|
||||||
this.onPasswordChange()
|
this.onPasswordChange()
|
||||||
}
|
}
|
||||||
@@ -162,7 +163,6 @@ export class ProfileEditDialogComponent implements OnInit, OnDestroy {
|
|||||||
generateAuthToken(): void {
|
generateAuthToken(): void {
|
||||||
this.profileService.generateAuthToken().subscribe({
|
this.profileService.generateAuthToken().subscribe({
|
||||||
next: (token: string) => {
|
next: (token: string) => {
|
||||||
console.log(token)
|
|
||||||
this.form.patchValue({ auth_token: token })
|
this.form.patchValue({ auth_token: token })
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user