Skip to content

Commit ed55c0c

Browse files
inverse http code with string "error" in en
1 parent 234dd20 commit ed55c0c

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

src/app/shared/error-handler/error-handler.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ <h1 class="error-view__title">
33
{{ 'PAGES.ERROR.NOT_FOUND.TITLE' | translate }}
44
</h1>
55

6-
<h3 class="error-view__code">
7-
{{ 'PAGES.ERROR.NOT_FOUND.LABEL' | translate }}
6+
<h3
7+
class="error-view__code"
8+
[class.is-english]="translate.getCurrentLang() === 'en'">
9+
<span class="error-view__label">{{ 'PAGES.ERROR.NOT_FOUND.LABEL' | translate }}</span>
810
<span class="error-view__code-value">{{ code() }}</span>
911
</h3>
1012

src/app/shared/error-handler/error-handler.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@
1919
}
2020

2121
&__code {
22+
display: flex;
23+
justify-content: center;
24+
align-items: center;
25+
gap: 0.5rem;
2226
color: var(--text-black-color);
2327
font-size: var(--font-size-h3);
2428
margin-bottom: 2rem;
29+
2530
&-value {
2631
color: var(--text-primary-color);
2732
font-weight: var(--font-weight-bold);
2833
}
34+
35+
&.is-english {
36+
flex-direction: row-reverse;
37+
}
2938
}
3039

3140
&__content {

src/app/shared/error-handler/error-handler.component.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@ describe('ErrorHandlerComponent', () => {
276276
// --- ASSERT ---
277277
expect(component.code()).toBe('500');
278278
});
279+
280+
it('should set code to empty string if URL does not match any known error pattern', () => {
281+
// --- ARRANGE ---
282+
Object.defineProperty(router, 'url', { value: '/error/unknown-path', configurable: true });
283+
queryParams$.next({});
284+
285+
// --- ACT ---
286+
fixture.detectChanges();
287+
288+
// --- ASSERT ---
289+
expect(component.code()).toBe('');
290+
});
279291
});
280292

281293
describe('UI & Navigation Actions', () => {
@@ -395,5 +407,27 @@ describe('ErrorHandlerComponent', () => {
395407
expect(buttonComponent.label()).toBe('Login');
396408
expect(buttonComponent.ariaLabel()).toBe('Button to open the login form');
397409
});
410+
411+
it('should apply "is-english" class to the code container when language is English', () => {
412+
// --- ACT ---
413+
translate.use('en');
414+
fixture.detectChanges();
415+
416+
const codeContainer = fixture.debugElement.query(By.css('.error-view__code'));
417+
418+
// --- ASSERT ---
419+
expect(codeContainer.nativeElement.classList.contains('is-english')).toBe(true);
420+
});
421+
422+
it('should NOT apply "is-english" class when language is French', () => {
423+
// --- ACT ---
424+
translate.use('fr');
425+
fixture.detectChanges();
426+
427+
const codeContainer = fixture.debugElement.query(By.css('.error-view__code'));
428+
429+
// --- ASSERT ---
430+
expect(codeContainer.nativeElement.classList.contains('is-english')).toBe(false);
431+
});
398432
});
399433
});

src/app/shared/error-handler/error-handler.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ChangeDetectionStrategy, Component, OnInit, inject, signal, DestroyRef, ChangeDetectorRef } from '@angular/core';
22
import { ActivatedRoute, Router, RouterOutlet } from '@angular/router';
33
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4-
import { TranslateModule } from '@ngx-translate/core';
4+
import { TranslateModule, TranslateService } from '@ngx-translate/core';
55

6-
import { MainButtonComponent } from '../shared';
6+
import { MainButtonComponent } from '@shared';
77

88
@Component({
99
selector: 'error-handler',
@@ -25,6 +25,7 @@ export class ErrorHandlerComponent implements OnInit {
2525
private readonly router = inject(Router);
2626

2727
public readonly code = signal<string>('');
28+
public readonly translate = inject(TranslateService);
2829

2930
ngOnInit(): void {
3031
this.route.queryParams.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((params) => {

0 commit comments

Comments
 (0)