diff --git a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.html b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.html index be0c599a5b7e04df8b03cbe0c51568aed474e709..897a93130bf9e8d21b120f86de04796e564b7300 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.html +++ b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.html @@ -23,7 +23,7 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<ng-container *ngIf="vorgang | hasLink: linkRel.ABSCHLIESSEN"> +<ng-container *ngIf="!isVorgangInBearbeitung && vorgang | hasLink: linkRel.ABSCHLIESSEN"> <ozgcloud-stroked-button-with-spinner *ngIf="!showAsIconButton" data-test-id="abschliessen-button" diff --git a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.spec.ts index 2a96a3b53a7329a7ef6536c2e184cf5d1be096a9..ff72e924921e24b4de0a81d651dc2854ec06e266 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.spec.ts @@ -33,7 +33,11 @@ import { IconButtonWithSpinnerComponent, OzgcloudStrokedButtonWithSpinnerComponent, } from '@alfa-client/ui'; -import { VorgangCommandService, VorgangWithEingangLinkRel } from '@alfa-client/vorgang-shared'; +import { + VorgangCommandService, + VorgangStatus, + VorgangWithEingangLinkRel, +} from '@alfa-client/vorgang-shared'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { createCommandResource } from 'libs/command-shared/test/command'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; @@ -74,6 +78,7 @@ describe('AbschliessenButtonComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(AbschliessenButtonComponent); component = fixture.componentInstance; + component.vorgang = createVorgangWithEingangResource(); fixture.detectChanges(); }); @@ -129,6 +134,18 @@ describe('AbschliessenButtonComponent', () => { expect(buttonElement).not.toBeInstanceOf(HTMLElement); }); + it('should be hidden if in bearbeitung', () => { + component.vorgang = { + ...createVorgangWithEingangResource([VorgangWithEingangLinkRel.ABSCHLIESSEN]), + status: VorgangStatus.IN_BEARBEITUNG, + }; + + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(abschliessenButton); + + expect(buttonElement).not.toBeInstanceOf(HTMLElement); + }); + it('should be visible', () => { component.vorgang = createVorgangWithEingangResource([ VorgangWithEingangLinkRel.ABSCHLIESSEN, @@ -156,6 +173,18 @@ describe('AbschliessenButtonComponent', () => { expect(buttonElement).not.toBeInstanceOf(HTMLElement); }); + it('should be hidden if in bearbeitung', () => { + component.vorgang = { + ...createVorgangWithEingangResource([VorgangWithEingangLinkRel.ABSCHLIESSEN]), + status: VorgangStatus.IN_BEARBEITUNG, + }; + + fixture.detectChanges(); + const buttonElement = fixture.nativeElement.querySelector(abschliessenIconButton); + + expect(buttonElement).not.toBeInstanceOf(HTMLElement); + }); + it('should be visible', () => { component.vorgang = createVorgangWithEingangResource([ VorgangWithEingangLinkRel.ABSCHLIESSEN, diff --git a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.ts b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.ts index 15df48ad2b497eed92ec4dfd36278e18fd3e506f..c8475e5aae551b7cfedeeea0d9a15e36c58219e6 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/buttons/abschliessen-button/abschliessen-button.component.ts @@ -55,4 +55,8 @@ export class AbschliessenButtonComponent implements OnInit { public abschliessen(): void { this.commandStateResource$ = this.vorgangCommandService.abschliessen(this.vorgang); } + + get isVorgangInBearbeitung(): boolean { + return this.vorgang.status === 'IN_BEARBEITUNG'; + } } diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.html b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.html index 1e513746896629e14bbfaca4d97b8dc0d4e3834f..b985566e1869ee4b1de3b2588dd7188845a72768 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.html +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.html @@ -24,19 +24,25 @@ --> <ng-container *ngIf="vorgangStateResource$ | async as vorgangStateResource"> - <ozgcloud-subnavigation class="mat-typography mat-app-background"> + <ozgcloud-subnavigation class="mat-typography mat-app-background" data-test-id="subnavigation"> <alfa-vorgang-detail-back-button-container></alfa-vorgang-detail-back-button-container> - <alfa-vorgang-detail-action-buttons - [vorgangWithEingang]="vorgangStateResource.resource" - ></alfa-vorgang-detail-action-buttons> - <alfa-vorgang-detail-more-menu - [vorgangWithEingang]="vorgangStateResource.resource" - ></alfa-vorgang-detail-more-menu> + <ng-container *ngIf="vorgangStateResource.resource"> + <alfa-vorgang-detail-action-buttons + [vorgangWithEingang]="vorgangStateResource.resource" + data-test-id="action-buttons" + ></alfa-vorgang-detail-action-buttons> + <alfa-vorgang-detail-more-menu + [vorgangWithEingang]="vorgangStateResource.resource" + data-test-id="more-menu" + ></alfa-vorgang-detail-more-menu> + </ng-container> </ozgcloud-subnavigation> <div class="l-scroll-area--full"> <alfa-vorgang-detail-area + *ngIf="vorgangStateResource" [vorgangStateResource]="vorgangStateResource" + data-test-id="detail-area" ></alfa-vorgang-detail-area> </div> </ng-container> diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.spec.ts index c22913961fe75585bd7180358e4f78ae886c4c85..7466616259f69afe3069e61596a3af74acb2b891 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-page.component.spec.ts @@ -21,11 +21,9 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MatIcon } from '@angular/material/icon'; import { LoeschAnforderungService } from '@alfa-client/loesch-anforderung-shared'; import { StateResource, createStateResource } from '@alfa-client/tech-shared'; -import { getDebugElementFromFixtureByCss, mock } from '@alfa-client/test-utils'; +import { Mock, existsAsHtmlElement, mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { SpinnerComponent, SpinnerTransparencyComponent } from '@alfa-client/ui'; import { VorgangCommandService, @@ -33,6 +31,9 @@ import { VorgangWithEingang, VorgangWithEingangResource, } from '@alfa-client/vorgang-shared'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatIcon } from '@angular/material/icon'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { ProgressBarComponent } from 'libs/ui/src/lib/ui/progress-bar/progress-bar.component'; import { SubnavigationComponent } from 'libs/ui/src/lib/ui/subnavigation/subnavigation.component'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; @@ -42,26 +43,37 @@ import { VorgangDetailActionButtonsComponent } from './vorgang-detail-area/vorga import { VorgangDetailAreaComponent } from './vorgang-detail-area/vorgang-detail-area.component'; import { VorgangDetailFormularButtonsComponent } from './vorgang-detail-area/vorgang-detail-formular-buttons/vorgang-detail-formular-buttons.component'; import { VorgangDetailBackButtonContainerComponent } from './vorgang-detail-back-button-container/vorgang-detail-back-button-container.component'; +import { VorgangDetailMoreMenuComponent } from './vorgang-detail-more-menu/vorgang-detail-more-menu.component'; import { VorgangDetailPageComponent } from './vorgang-detail-page.component'; +type withGetVorgang = { + getVorgangWithEingang: () => Subject<StateResource<VorgangWithEingang>>; +}; + describe('VorgangDetailPageComponent', () => { let component: VorgangDetailPageComponent; let fixture: ComponentFixture<VorgangDetailPageComponent>; - const getVorgangWithEingangSubj: Subject<StateResource<VorgangWithEingang>> = new Subject(); - const vorgangService = { - ...mock(VorgangService), - getVorgangWithEingang: () => getVorgangWithEingangSubj, - }; + let vorgangWithEingangSubj: Subject<StateResource<VorgangWithEingang>>; + let vorgangService: Mock<VorgangService> | withGetVorgang; const vorgangCommandService = mock(VorgangCommandService); const loeschAnforderungService = mock(LoeschAnforderungService); const vorgangWithEingang: VorgangWithEingangResource = createVorgangWithEingangResource(); - const subnavigation: string = 'ozgcloud-subnavigation'; + const subnavigation: string = getDataTestIdOf('subnavigation'); + const actionButtons: string = getDataTestIdOf('action-buttons'); + const moreMenu: string = getDataTestIdOf('more-menu'); + const detailArea: string = getDataTestIdOf('detail-area'); - beforeEach(async () => { - await TestBed.configureTestingModule({ + beforeEach(() => { + vorgangWithEingangSubj = new Subject(); + vorgangService = { + ...mock(VorgangService), + getVorgangWithEingang: () => vorgangWithEingangSubj, + }; + + TestBed.configureTestingModule({ declarations: [ VorgangDetailPageComponent, MatIcon, @@ -71,6 +83,7 @@ describe('VorgangDetailPageComponent', () => { MockComponent(VorgangDetailActionButtonsComponent), MockComponent(VorgangDetailFormularButtonsComponent), MockComponent(VorgangDetailBackButtonContainerComponent), + MockComponent(VorgangDetailMoreMenuComponent), MockComponent(SpinnerComponent), MockComponent(SpinnerTransparencyComponent), ], @@ -89,9 +102,7 @@ describe('VorgangDetailPageComponent', () => { }, ], }); - }); - beforeEach(() => { fixture = TestBed.createComponent(VorgangDetailPageComponent); component = fixture.componentInstance; fixture.detectChanges(); @@ -125,21 +136,65 @@ describe('VorgangDetailPageComponent', () => { describe('subnavigation', () => { it('should be hidden', () => { - getVorgangWithEingangSubj.next(null); + vorgangWithEingangSubj.next(null); + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, subnavigation); + }); + + it('should be visible', () => { + vorgangWithEingangSubj.next(createStateResource(vorgangWithEingang)); + fixture.detectChanges(); + + existsAsHtmlElement(fixture, subnavigation); + }); + }); + + describe('action buttons', () => { + it('should be hidden', () => { + vorgangWithEingangSubj.next(createStateResource(null)); fixture.detectChanges(); - const subnavigationElement = getDebugElementFromFixtureByCss(fixture, subnavigation); + notExistsAsHtmlElement(fixture, actionButtons); + }); + + it('should be visible', () => { + vorgangWithEingangSubj.next(createStateResource(vorgangWithEingang)); + fixture.detectChanges(); + + existsAsHtmlElement(fixture, actionButtons); + }); + }); + + describe('more menu', () => { + it('should be hidden', () => { + vorgangWithEingangSubj.next(createStateResource(null)); + fixture.detectChanges(); - expect(subnavigationElement).toBeNull(); + notExistsAsHtmlElement(fixture, moreMenu); }); it('should be visible', () => { - getVorgangWithEingangSubj.next(createStateResource(vorgangWithEingang)); + vorgangWithEingangSubj.next(createStateResource(vorgangWithEingang)); fixture.detectChanges(); - const subnavigationElement = getDebugElementFromFixtureByCss(fixture, subnavigation); + existsAsHtmlElement(fixture, moreMenu); + }); + }); + + describe('detail area', () => { + it('should be hidden', () => { + vorgangWithEingangSubj.next(null); + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, detailArea); + }); + + it('should be visible', () => { + vorgangWithEingangSubj.next(createStateResource(vorgangWithEingang)); + fixture.detectChanges(); - expect(subnavigationElement).toBeDefined(); + existsAsHtmlElement(fixture, detailArea); }); }); });