From 43eaa1b47b70b512e4a7f0cac35fc8e325ee056b Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Fri, 20 Sep 2024 10:31:21 +0200 Subject: [PATCH] OZG-6376 OZG-6800 Fix status bug --- .../vorgang-status-text.component.html | 2 +- .../vorgang-status-text.component.spec.ts | 11 ++++++++--- .../vorgang-status-text.component.ts | 4 +++- .../vorgang-list-item.component.html | 2 +- .../vorgang-list-item.component.spec.ts | 8 -------- .../vorgang-list-item/vorgang-list-item.component.ts | 4 +--- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.html b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.html index f6a1ebd55e..696169f347 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.html +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.html @@ -24,5 +24,5 @@ --> <div class="status-name text-sm" data-test-id="vorgang-status-text"> - {{ status }} + {{ status | enumToLabel: vorgangStatusLabel }} </div> diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.spec.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.spec.ts index 15774e62da..31b6f8e0de 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.spec.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.spec.ts @@ -21,19 +21,23 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { EnumToLabelPipe } from '@alfa-client/tech-shared'; +import { VorgangResource, VorgangStatusLabel } from '@alfa-client/vorgang-shared'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { createVorgangResource } from 'libs/vorgang-shared/test/vorgang'; import { VorgangStatusTextComponent } from './vorgang-status-text.component'; describe('VorgangStatusTextComponent', () => { let component: VorgangStatusTextComponent; let fixture: ComponentFixture<VorgangStatusTextComponent>; + const vorgang: VorgangResource = createVorgangResource(); const statusTextTestId: string = getDataTestIdOf('vorgang-status-text'); beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [VorgangStatusTextComponent], + declarations: [EnumToLabelPipe, VorgangStatusTextComponent], }).compileComponents(); }); @@ -48,11 +52,12 @@ describe('VorgangStatusTextComponent', () => { }); it('should show status text', () => { - component.status = 'Neu'; + component.status = vorgang.status; + const statusText: string = VorgangStatusLabel[vorgang.status]; fixture.detectChanges(); const statusTextElement: HTMLElement = fixture.nativeElement.querySelector(statusTextTestId); - expect(statusTextElement.innerHTML).toContain('Neu'); + expect(statusTextElement.innerHTML).toContain(statusText); }); }); diff --git a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.ts b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.ts index de4e772d0b..a1c90fd8af 100644 --- a/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.ts +++ b/alfa-client/libs/vorgang-shared-ui/src/lib/vorgang-status-text/vorgang-status-text.component.ts @@ -21,6 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { VorgangStatus, VorgangStatusLabel } from '@alfa-client/vorgang-shared'; import { Component, Input } from '@angular/core'; @Component({ @@ -29,5 +30,6 @@ import { Component, Input } from '@angular/core'; styleUrls: ['./vorgang-status-text.component.scss'], }) export class VorgangStatusTextComponent { - @Input() status: string; + @Input() status: VorgangStatus; + readonly vorgangStatusLabel = VorgangStatusLabel; } diff --git a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.html b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.html index d7faafb103..228c9808d4 100644 --- a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.html +++ b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.html @@ -38,7 +38,7 @@ data-test-class="status-dot" ></alfa-vorgang-status-dot> <alfa-vorgang-status-text - [status]="status" + [status]="vorgang.status" data-test-class="status-text" class="status-text" ></alfa-vorgang-status-text> diff --git a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.spec.ts b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.spec.ts index 0c9700bd02..892fe541f8 100644 --- a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.spec.ts +++ b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.spec.ts @@ -114,14 +114,6 @@ describe('VorgangListItemComponent', () => { }); describe('ngOnInit', () => { - it('should set status', () => { - component.getStatus = jest.fn().mockReturnValue('Test'); - - component.ngOnInit(); - - expect(component.status).toBe('Test'); - }); - it('should build aria label', () => { component.buildAriaLabel = jest.fn(); diff --git a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.ts b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.ts index b695b0b374..a86e83410e 100644 --- a/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.ts +++ b/alfa-client/libs/vorgang/src/lib/vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component.ts @@ -56,7 +56,6 @@ export class VorgangListItemComponent implements OnInit { userProfile: StateResource<UserProfileResource> = createEmptyStateResource<UserProfileResource>(); public ariaLabel: string = ''; - public status: string = ''; constructor(public userProfileService: UserProfileService) {} @@ -69,7 +68,6 @@ export class VorgangListItemComponent implements OnInit { this.userProfile = userProfileStateResource; }); } - this.status = this.getStatus(); this.buildAriaLabel(); } @@ -80,7 +78,7 @@ export class VorgangListItemComponent implements OnInit { const approvalStatus: string = this.getApprovalText(); const createdAt: string = formatFullDateWithTimeWithoutSeconds(this.vorgang.createdAt); - this.ariaLabel = `Vorgang: ${name}, Aktenzeichen: ${aktenzeichen}, Nummer: ${nummer} Status: ${this.status} ${approvalStatus}, Eingang: ${createdAt}, Aktuell zugewiesener Nutzer: ${getUserName(this.userProfile.resource)}`; + this.ariaLabel = `Vorgang: ${name}, Aktenzeichen: ${aktenzeichen}, Nummer: ${nummer} Status: ${this.getStatus()} ${approvalStatus}, Eingang: ${createdAt}, Aktuell zugewiesener Nutzer: ${getUserName(this.userProfile.resource)}`; if ( hasLink(this.vorgang, VorgangHeaderLinkRel.WIEDERVORLAGEN) && -- GitLab