Compare commits
2 Commits
feature/al
...
homologaci
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a952af784 | |||
| b1d4c4d13d |
@@ -115,6 +115,6 @@ describe('App', () => {
|
||||
expect(fixture.nativeElement.textContent).toContain('No encontramos una tienda para este dominio');
|
||||
expect(document.title).toBe('ShopitFront');
|
||||
expect(document.head.querySelector<HTMLLinkElement>('link[rel~="icon"]')?.getAttribute('href'))
|
||||
.toBe('favicon.ico');
|
||||
.toBe("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,8 @@ import { GlobalLoadingComponent } from './shared/components/global-loading/globa
|
||||
import { ModalHostComponent } from './shared/components/modal-host/modal-host.component';
|
||||
import { ToastContainerComponent } from './shared/components/toast-container/toast-container.component';
|
||||
|
||||
const EMPTY_FAVICON = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E";
|
||||
|
||||
function hexToRgb(hex: string): string {
|
||||
const cleanHex = hex.replace('#', '').trim();
|
||||
let r = 0, g = 0, b = 0;
|
||||
@@ -66,7 +68,7 @@ export class App {
|
||||
effect(() => {
|
||||
const tenant = this.tenantService.tenant();
|
||||
const siteTitle = tenant?.site_title?.trim() || 'ShopitFront';
|
||||
const faviconHref = tenant?.favicon || 'favicon.ico';
|
||||
const faviconHref = tenant?.favicon || EMPTY_FAVICON;
|
||||
|
||||
this.title.setTitle(siteTitle);
|
||||
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
<label class="visually-hidden" for="reset-password-new">Nueva Contraseña</label>
|
||||
<app-input
|
||||
id="reset-password-new"
|
||||
type="password"
|
||||
type="password-toggle"
|
||||
placeholder="Nueva Contraseña"
|
||||
[value]="form.controls.password.value"
|
||||
[invalid]="showControlError('password')"
|
||||
[visible]="passwordVisible()"
|
||||
(valueChange)="updatePassword('password', $event)"
|
||||
(visibleChange)="setPasswordVisibility($event)"
|
||||
/>
|
||||
@if (getControlError('password'); as errorMessage) {
|
||||
<small class="text-danger">{{ errorMessage }}</small>
|
||||
@@ -30,11 +32,13 @@
|
||||
</label>
|
||||
<app-input
|
||||
id="reset-password-confirmation"
|
||||
type="password"
|
||||
type="password-toggle"
|
||||
placeholder="Repetir Nueva Contraseña"
|
||||
[value]="form.controls.password_confirmation.value"
|
||||
[invalid]="showControlError('password_confirmation')"
|
||||
[visible]="passwordVisible()"
|
||||
(valueChange)="updatePassword('password_confirmation', $event)"
|
||||
(visibleChange)="setPasswordVisibility($event)"
|
||||
/>
|
||||
@if (getControlError('password_confirmation'); as errorMessage) {
|
||||
<small class="text-danger">{{ errorMessage }}</small>
|
||||
|
||||
@@ -50,6 +50,43 @@ describe('ResetPasswordPageComponent', () => {
|
||||
];
|
||||
}
|
||||
|
||||
it('shows and hides both password fields with either visibility control', async () => {
|
||||
const modalService = {
|
||||
openSimple: vi.fn(),
|
||||
};
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ResetPasswordPageComponent],
|
||||
providers: resetProviders(modalService),
|
||||
}).compileComponents();
|
||||
|
||||
const fixture = TestBed.createComponent(ResetPasswordPageComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const getPasswordInputs = () =>
|
||||
Array.from(fixture.nativeElement.querySelectorAll('input')) as HTMLInputElement[];
|
||||
const getVisibilityButtons = () =>
|
||||
Array.from(
|
||||
fixture.nativeElement.querySelectorAll('button[aria-label]'),
|
||||
) as HTMLButtonElement[];
|
||||
|
||||
expect(getPasswordInputs().map((input) => input.type)).toEqual(['password', 'password']);
|
||||
|
||||
getVisibilityButtons()[0].click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getPasswordInputs().map((input) => input.type)).toEqual(['text', 'text']);
|
||||
expect(getVisibilityButtons().map((button) => button.getAttribute('aria-label'))).toEqual([
|
||||
'Ocultar contraseña',
|
||||
'Ocultar contraseña',
|
||||
]);
|
||||
|
||||
getVisibilityButtons()[1].click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getPasswordInputs().map((input) => input.type)).toEqual(['password', 'password']);
|
||||
});
|
||||
|
||||
it('rejects passwords that do not match', async () => {
|
||||
const modalService = {
|
||||
openSimple: vi.fn(),
|
||||
|
||||
@@ -49,6 +49,7 @@ export class ResetPasswordPageComponent {
|
||||
private readonly submittedState = signal(false);
|
||||
private readonly isSubmittingState = signal(false);
|
||||
private readonly serverErrorState = signal<string | null>(null);
|
||||
private readonly passwordVisibleState = signal(false);
|
||||
|
||||
private readonly email = this.route.snapshot.queryParamMap.get('email') ?? '';
|
||||
private readonly code = this.route.snapshot.queryParamMap.get('code') ?? '';
|
||||
@@ -72,6 +73,11 @@ export class ResetPasswordPageComponent {
|
||||
protected readonly submitted = this.submittedState.asReadonly();
|
||||
protected readonly isSubmitting = this.isSubmittingState.asReadonly();
|
||||
protected readonly serverError = this.serverErrorState.asReadonly();
|
||||
protected readonly passwordVisible = this.passwordVisibleState.asReadonly();
|
||||
|
||||
protected setPasswordVisibility(visible: boolean): void {
|
||||
this.passwordVisibleState.set(visible);
|
||||
}
|
||||
|
||||
protected updatePassword(controlName: PasswordControlName, value: string | number): void {
|
||||
this.form.controls[controlName].setValue(String(value));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<title>ShopitFront</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
|
||||
Reference in New Issue
Block a user