diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..5575fa3501a7e60a75709c48b78881480d10024b --- /dev/null +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts @@ -0,0 +1,36 @@ +import { CollaborationService } from './collaboration.service'; + +describe('CollaborationService', () => { + let service: CollaborationService; + + beforeEach(() => { + service = new CollaborationService(); + }); + + describe('is anfrage formular visible', () => { + it.skip('FIX TestSetup | should return value', () => { + // const isVisible: Observable<boolean> = service.isAnfrageFormularVisible(); + // expect(isVisible).toBeObservable(isVisible); + }); + }); + + describe('show anfrage formular', () => { + it('should set "showAnfrageFormular" to true', () => { + service.showAnfrageFormular$.next(false); + + service.showAnfrageFormular(); + + expect(service.showAnfrageFormular$.value).toBeTruthy(); + }); + }); + + describe('hide anfrage formular', () => { + it('should set "showAnfrageFormular" to false', () => { + service.showAnfrageFormular$.next(true); + + service.hideAnfrageFormular(); + + expect(service.showAnfrageFormular$.value).toBeFalsy(); + }); + }); +}); diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cedabfe78f77bc2ac3de1b45ca8d69cbab904c6 --- /dev/null +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; + +@Injectable() +export class CollaborationService { + showAnfrageFormular$: BehaviorSubject<boolean> = new BehaviorSubject(false); + + public isAnfrageFormularVisible(): Observable<boolean> { + //FIX TEST + return this.showAnfrageFormular$.asObservable(); + // + } + + public showAnfrageFormular(): void { + this.showAnfrageFormular$.next(true); + } + + public hideAnfrageFormular(): void { + this.showAnfrageFormular$.next(false); + } +} diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html index 1b3f1789b2628eb40f769cecdd17698bbe708e6d..03d11d5c710f87ba333b3f0205b4e6a110b036d0 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.html @@ -1,5 +1,17 @@ -<ods-button variant="outline" text="Anfrage erstellen" dataTestId="anfrage-erstellen-button"> - <ods-save-icon icon class="fill-text"></ods-save-icon> -</ods-button> +<ng-template #anfrageErstellenButton> + <ods-button + variant="outline" + text="Anfrage erstellen" + data-test-id="anfrage-erstellen-button" + (clickEmitter)="showAnfrageFormular()" + > + <ods-save-icon icon class="fill-text"></ods-save-icon> + </ods-button> +</ng-template> -dsadwad +<ng-container *ngIf="isAnfrageFormularVisible$ | async; else anfrageErstellenButton"> + <alfa-zustaendige-stelle-container + data-test-id="zustaendige-stelle-container" + (hideFormular)="hideFormular()" + ></alfa-zustaendige-stelle-container> +</ng-container> diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.scss b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts index a2bc518a760d64e36e481958c7085004eaafd42b..14d69899dad43bc7bfcf1255116eaeb613f2c70c 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts @@ -1,15 +1,44 @@ +import { + Mock, + dispatchEventFromFixture, + existsAsHtmlElement, + mock, + notExistsAsHtmlElement, +} from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ButtonComponent, SaveIconComponent } from '@ods/system'; +import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { MockComponent } from 'ng-mocks'; +import { of } from 'rxjs'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container.component'; +import { ZustaendigeStelleContainerComponent } from './zustaendige-stelle-container/zustaendige-stelle-container.component'; describe('CollaborationInVorgangContainerComponent', () => { let component: CollaborationInVorgangContainerComponent; let fixture: ComponentFixture<CollaborationInVorgangContainerComponent>; + const anfrageErstellenButton: string = getDataTestIdOf('anfrage-erstellen-button'); + const zustaendigeStelleContainer: string = getDataTestIdOf('zustaendige-stelle-container'); + + const service: Mock<CollaborationService> = { + ...mock(CollaborationService), + isAnfrageFormularVisible: jest.fn().mockReturnValue(of(false)), + }; + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ButtonComponent, SaveIconComponent], - declarations: [CollaborationInVorgangContainerComponent], + declarations: [ + CollaborationInVorgangContainerComponent, + MockComponent(ZustaendigeStelleContainerComponent), + ], + providers: [ + { + provide: CollaborationService, + useValue: service, + }, + ], }).compileComponents(); fixture = TestBed.createComponent(CollaborationInVorgangContainerComponent); @@ -20,4 +49,71 @@ describe('CollaborationInVorgangContainerComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('ngOnInit', () => { + it('should call service', () => { + component.ngOnInit(); + + expect(service.isAnfrageFormularVisible).toHaveBeenCalled(); + }); + }); + + describe('anfrage erstellen button', () => { + describe('on anfrage formular visibility false', () => { + beforeEach(() => { + component.isAnfrageFormularVisible$ = of(false); + }); + + it('should be shown', () => { + fixture.detectChanges(); + + existsAsHtmlElement(fixture, anfrageErstellenButton); + }); + + it('should call service on click', () => { + fixture.detectChanges(); + + dispatchEventFromFixture(fixture, anfrageErstellenButton, 'clickEmitter'); + + expect(service.showAnfrageFormular).toHaveBeenCalled(); + }); + }); + + it('should be hidden if formular visibility is true', () => { + component.isAnfrageFormularVisible$ = of(true); + + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, anfrageErstellenButton); + }); + }); + + describe('zustaendige stelle', () => { + describe('on anfrage formular visibility true', () => { + beforeEach(() => { + component.isAnfrageFormularVisible$ = of(true); + }); + it('should be shown', () => { + fixture.detectChanges(); + + existsAsHtmlElement(fixture, zustaendigeStelleContainer); + }); + + it('should call service on hideFormular output', () => { + fixture.detectChanges(); + + dispatchEventFromFixture(fixture, zustaendigeStelleContainer, 'hideFormular'); + + expect(service.hideAnfrageFormular).toHaveBeenCalled(); + }); + }); + + it('should be hidden if formular visibility is false', () => { + component.isAnfrageFormularVisible$ = of(false); + + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, zustaendigeStelleContainer); + }); + }); }); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts index 91db940d90a0195ced38a6aefe1966f06cb3dddc..c3c14cebfca8473ac116bc1a76f548c4c2748132 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts @@ -1,8 +1,25 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; +import { Observable } from 'rxjs'; @Component({ selector: 'alfa-collaboration-in-vorgang-container', templateUrl: './collaboration-in-vorgang-container.component.html', - styleUrls: ['./collaboration-in-vorgang-container.component.scss'], }) -export class CollaborationInVorgangContainerComponent {} +export class CollaborationInVorgangContainerComponent implements OnInit { + public isAnfrageFormularVisible$: Observable<boolean>; + + constructor(private service: CollaborationService) {} + + ngOnInit(): void { + this.isAnfrageFormularVisible$ = this.service.isAnfrageFormularVisible(); + } + + public showAnfrageFormular(): void { + this.service.showAnfrageFormular(); + } + + public hideFormular(): void { + this.service.hideAnfrageFormular(); + } +} diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.html new file mode 100644 index 0000000000000000000000000000000000000000..6e905e5ef08a3ffc8043d3083fc528018fdeb1d5 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.html @@ -0,0 +1,17 @@ +ICON_PLATZHALTER +<ods-button + variant="outline" + text="Zuständige Stelle auswählen" + dataTestId="zustaendige-stelle-search-button" +> + <ods-save-icon icon class="fill-text"></ods-save-icon> +</ods-button> + +<ods-button + variant="outline" + text="Abbrechen" + data-test-id="zustaendige-stelle-abbrechen-button" + (clickEmitter)="hideFormular.emit()" +> + <ods-close-icon icon class="fill-text"></ods-close-icon> +</ods-button> diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..44b14427ee5bf2bb5ec1ad38c90fe6426fa90b86 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.spec.ts @@ -0,0 +1,42 @@ +import { dispatchEventFromFixture } from '@alfa-client/test-utils'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ButtonComponent, CloseIconComponent, SaveIconComponent } from '@ods/system'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { MockComponent } from 'ng-mocks'; +import { ZustaendigeStelleContainerComponent } from './zustaendige-stelle-container.component'; + +describe('ZustaendigeStelleContainerComponent', () => { + let component: ZustaendigeStelleContainerComponent; + let fixture: ComponentFixture<ZustaendigeStelleContainerComponent>; + + const abbrechenButton: string = getDataTestIdOf('zustaendige-stelle-abbrechen-button'); + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ButtonComponent], + declarations: [ + ZustaendigeStelleContainerComponent, + MockComponent(SaveIconComponent), + MockComponent(CloseIconComponent), + ], + }).compileComponents(); + + fixture = TestBed.createComponent(ZustaendigeStelleContainerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + describe('abbrechen button', () => { + it('should emit hideFormular', () => { + const emitSpy = (component.hideFormular.emit = jest.fn()); + + dispatchEventFromFixture(fixture, abbrechenButton, 'clickEmitter'); + + expect(emitSpy).toHaveBeenCalled(); + }); + }); +}); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..316fc5d3e42870c274efee7e24df34cd7233cc22 --- /dev/null +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component.ts @@ -0,0 +1,9 @@ +import { Component, EventEmitter, Output } from '@angular/core'; + +@Component({ + selector: 'alfa-zustaendige-stelle-container', + templateUrl: './zustaendige-stelle-container.component.html', +}) +export class ZustaendigeStelleContainerComponent { + @Output() public hideFormular: EventEmitter<void> = new EventEmitter<void>(); +} diff --git a/alfa-client/libs/collaboration/src/lib/collaboration.module.ts b/alfa-client/libs/collaboration/src/lib/collaboration.module.ts index 49305c63a2962b28ee5fa74bcf377272d1b680fe..2847a5dd26eba7521f52d011549fb7b361caa550 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration.module.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration.module.ts @@ -1,11 +1,19 @@ +import { CollaborationSharedModule } from '@alfa-client/collaboration-shared'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { ButtonComponent, SaveIconComponent } from '@ods/system'; +import { ButtonComponent, CloseIconComponent, SaveIconComponent } from '@ods/system'; import { CollaborationInVorgangContainerComponent } from './collaboration-in-vorgang-container/collaboration-in-vorgang-container.component'; +import { ZustaendigeStelleContainerComponent } from './collaboration-in-vorgang-container/zustaendige-stelle-container/zustaendige-stelle-container.component'; @NgModule({ - imports: [CommonModule, ButtonComponent, SaveIconComponent], - declarations: [CollaborationInVorgangContainerComponent], + imports: [ + CommonModule, + ButtonComponent, + SaveIconComponent, + CloseIconComponent, + CollaborationSharedModule, + ], + declarations: [CollaborationInVorgangContainerComponent, ZustaendigeStelleContainerComponent], exports: [CollaborationInVorgangContainerComponent], }) export class CollaborationModule {} diff --git a/alfa-client/tsconfig.base.json b/alfa-client/tsconfig.base.json index dcd7a091e2e4c3e485af22ec4b92386bfee0394d..15284c9f0e8bc51994ae4e9b965a16c8b17d0bb6 100644 --- a/alfa-client/tsconfig.base.json +++ b/alfa-client/tsconfig.base.json @@ -24,6 +24,7 @@ "@alfa-client/binary-file": ["libs/binary-file/src/index.ts"], "@alfa-client/binary-file-shared": ["libs/binary-file-shared/src/index.ts"], "@alfa-client/collaboration": ["libs/collaboration/src/index.ts"], + "@alfa-client/collaboration-shared": ["libs/collaboration-shared/src/index.ts"], "@alfa-client/command-shared": ["libs/command-shared/src/index.ts"], "@alfa-client/environment-shared": ["libs/environment-shared/src/index.ts"], "@alfa-client/forwarding": ["libs/forwarding/src/index.ts"],