Skip to content
Snippets Groups Projects
Commit 660307d0 authored by OZGCloud's avatar OZGCloud
Browse files

Merge remote-tracking branch 'origin/master' into OZG-5012-GenerischerResourceService

parents 22d40314 5660e172
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 30 deletions
......@@ -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"
......
......@@ -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,
......
......@@ -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';
}
}
......@@ -39,7 +39,7 @@ describe('VorgangDetailBescheidenResultComponent', () => {
const bescheidStatus: string = getDataTestIdOf('bescheid-status');
const bescheidDocument: string = getDataTestIdOf('bescheid-document');
const bescheidAttachments: string = getDataTestIdOf('bescheid-attachments');
const saveAndSendButton: string = getDataTestIdOf('save-and-send-button');
const saveAndSendButton: string = getDataTestIdOf('confirm-and-save-button');
const sendButton: string = getDataTestIdOf('send-button');
const nachrichtAntragstellerComponent = getDataTestIdOf('bescheid-nachricht-an-antragsteller');
......
......@@ -25,7 +25,7 @@ describe('VorgangDetailBescheidenBescheidVersendenComponent', () => {
let formService: BescheidenFormService;
const sendToAntragstellerButtonTestId: string = getDataTestIdOf('send-to-antragsteller-button');
const saveAndSendButtonTestId: string = getDataTestIdOf('save-and-send-button');
const saveAndSendButtonTestId: string = getDataTestIdOf('save-button');
beforeEach(async () => {
bescheidService = mock(BescheidService);
......
......@@ -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>
<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>
......
......@@ -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(() => {
vorgangWithEingangSubj = new Subject();
vorgangService = {
...mock(VorgangService),
getVorgangWithEingang: () => vorgangWithEingangSubj,
};
beforeEach(async () => {
await TestBed.configureTestingModule({
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();
const subnavigationElement = getDebugElementFromFixtureByCss(fixture, subnavigation);
notExistsAsHtmlElement(fixture, subnavigation);
});
it('should be visible', () => {
vorgangWithEingangSubj.next(createStateResource(vorgangWithEingang));
fixture.detectChanges();
expect(subnavigationElement).toBeNull();
existsAsHtmlElement(fixture, subnavigation);
});
});
describe('action buttons', () => {
it('should be hidden', () => {
vorgangWithEingangSubj.next(createStateResource(null));
fixture.detectChanges();
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();
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);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment