diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts index e27ea055d18d984cfb5edc24df6f93fe3a01a212..eb70d9123241996827a8440b6205cb4b25d35d8a 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.spec.ts @@ -13,7 +13,7 @@ describe('OrganisationsEinheitFormPageComponent', () => { let component: OrganisationsEinheitFormPageComponent; let fixture: ComponentFixture<OrganisationsEinheitFormPageComponent>; - const organisationsEinheiteFormSelector: string = getDataTestIdOf('organisations-einheit-form'); + const organisationsEinheitFormSelector: string = getDataTestIdOf('organisations-einheit-form'); const apiRootStateResource$ = of(createStateResource(createApiRootResource())); const apiRootService: Mock<ApiRootService> = { @@ -51,18 +51,19 @@ describe('OrganisationsEinheitFormPageComponent', () => { }); describe('template', () => { - // todo: fix me describe('admin-organisationseinheit-form-container', () => { it('should be rendered if apiRootState has link', () => { component.apiRootStateResource$ = of(createStateResource(createApiRootResource([ApiRootLinkRel.ORGANISATIONS_EINHEIT]))); + fixture.detectChanges(); - existsAsHtmlElement(fixture, organisationsEinheiteFormSelector); + existsAsHtmlElement(fixture, organisationsEinheitFormSelector); }); it('should not be rendered if apiRootState has no link', () => { component.apiRootStateResource$ = of(createStateResource(createApiRootResource())); + fixture.detectChanges(); - notExistsAsHtmlElement(fixture, organisationsEinheiteFormSelector); + notExistsAsHtmlElement(fixture, organisationsEinheitFormSelector); }); }); }); diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.html b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.html index 792930158756ab6bea2bf0e8fbd5c164c5037c0a..d57d0eb794c0a9499b29f94856f7bd95903bb891 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.html +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.html @@ -1 +1,5 @@ -<admin-organisationseinheit-container/> +<ng-container *ngIf="(apiRootStateResource$ | async)?.resource as apiRoot"> + @if(apiRoot | hasLink: ApiRootLinkRel.ORGANISATIONS_EINHEIT){ + <admin-organisationseinheit-container data-test-id="organisations-einheit-container"/> + } +</ng-container> \ No newline at end of file diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts index 59ddda81ab9c26fbac8f8bd976298596c9283b5a..17a5736eae9427dd9e1b620ef21807111e59deec 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.spec.ts @@ -1,15 +1,31 @@ import { OrganisationsEinheitContainerComponent } from '@admin-client/admin-settings'; +import { ApiRootLinkRel, ApiRootService } from '@alfa-client/api-root-shared'; +import { createStateResource, TechSharedModule } from '@alfa-client/tech-shared'; +import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; +import { of } from 'rxjs'; +import { createApiRootResource } from '../../../../../../libs/api-root-shared/test/api-root'; +import { getDataTestIdOf } from '../../../../../../libs/tech-shared/test/data-test'; import { OrganisationsEinheitPageComponent } from './organisationseinheit-page.component'; describe('OrganisationsEinheitPageComponent', () => { let component: OrganisationsEinheitPageComponent; let fixture: ComponentFixture<OrganisationsEinheitPageComponent>; + const organisationsEinheitContainerSelector: string = getDataTestIdOf('organisations-einheit-container'); + + const apiRootStateResource$ = of(createStateResource(createApiRootResource())); + const apiRootService: Mock<ApiRootService> = { + ...mock(ApiRootService), + getApiRoot: jest.fn().mockReturnValue(apiRootStateResource$), + }; + beforeEach(async () => { await TestBed.configureTestingModule({ + imports: [TechSharedModule], declarations: [OrganisationsEinheitPageComponent, MockComponent(OrganisationsEinheitContainerComponent)], + providers: [{ provide: ApiRootService, useValue: apiRootService }], }).compileComponents(); }); @@ -23,4 +39,22 @@ describe('OrganisationsEinheitPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('template', () => { + describe('admin-organisationseinheit-container', () => { + it('should be rendered if apiRootState has link', () => { + component.apiRootStateResource$ = of(createStateResource(createApiRootResource([ApiRootLinkRel.ORGANISATIONS_EINHEIT]))); + fixture.detectChanges(); + + existsAsHtmlElement(fixture, organisationsEinheitContainerSelector); + }); + + it('should not be rendered if apiRootState has no link', () => { + component.apiRootStateResource$ = of(createStateResource(createApiRootResource())); + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, organisationsEinheitContainerSelector); + }); + }); + }); }); diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.ts index 4d653b6ed7b3701a4f74ce763f313cc93ca29dc6..08fdbd714dc2f421a2b2614f18b47d743c494011 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component.ts @@ -1,7 +1,19 @@ -import { Component } from '@angular/core'; +import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; +import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; +import { Component, inject } from '@angular/core'; +import { Observable, of } from 'rxjs'; @Component({ selector: 'organisationseinheit-page', templateUrl: './organisationseinheit-page.component.html', }) -export class OrganisationsEinheitPageComponent {} +export class OrganisationsEinheitPageComponent { + private apiRootService = inject(ApiRootService); + + public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>()); + + ngOnInit(): void { + this.apiRootStateResource$ = this.apiRootService.getApiRoot(); + } + protected readonly ApiRootLinkRel = ApiRootLinkRel; +} diff --git a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.html b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.html index 35312d3a6fcbc752440bf2d9a0395bb55b2678da..6d30a459ec00c868f26e62c48e52d0028c3b03ab 100644 --- a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.html +++ b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.html @@ -1 +1,3 @@ -<admin-postfach-container></admin-postfach-container> +@if(environment.features.postfach){ + <admin-postfach-container data-test-id="postfach-container"/> +} \ No newline at end of file diff --git a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.spec.ts b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.spec.ts index 5ebec9f21a5002eea14557838b3af6aa0f724196..49c04dc617d7202d1edf3328df2fb76ab5514d97 100644 --- a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.spec.ts @@ -1,12 +1,18 @@ import { PostfachContainerComponent } from '@admin-client/admin-settings'; +import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; +import { createEnvironment } from '../../../../../../libs/environment-shared/test/environment'; +import { getDataTestIdOf } from '../../../../../../libs/tech-shared/test/data-test'; import { PostfachPageComponent } from './postfach-page.component'; describe('PostfachPageComponent', () => { let component: PostfachPageComponent; let fixture: ComponentFixture<PostfachPageComponent>; + const postfachContainerSelector: string = getDataTestIdOf('postfach-container'); + const environment = createEnvironment(); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [PostfachPageComponent, MockComponent(PostfachContainerComponent)], @@ -16,11 +22,29 @@ describe('PostfachPageComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(PostfachPageComponent); component = fixture.componentInstance; - + component.environment = environment; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + describe('template', () => { + describe('admin-postfach-container', () => { + it('should be rendered if feature toggle postfach is true', () => { + environment.features.postfach = true; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, postfachContainerSelector); + }); + + it('should not be rendered if feature toggle postfach is false', () => { + environment.features.postfach = false; + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, postfachContainerSelector); + }); + }); + }); }); diff --git a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.ts b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.ts index 1d9a54ceddbd6e663477e382dbbff95d9ab13c66..e517dd361f662c17b3c69994a76f1ee131f8bcd8 100644 --- a/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.ts +++ b/alfa-client/apps/admin/src/pages/postfach/postfach-page/postfach-page.component.ts @@ -1,7 +1,10 @@ +import { Environment, getEnvironmentFactory } from '@alfa-client/environment-shared'; import { Component } from '@angular/core'; @Component({ selector: 'postfach-page', templateUrl: './postfach-page.component.html', }) -export class PostfachPageComponent {} +export class PostfachPageComponent { + public environment: Environment = getEnvironmentFactory(); +} diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.spec.ts b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.spec.ts index 49c6e7a84d7daadaaaac737598acbcddf744ce0c..4a3016f2eb4ff2a8fdcbde9ada61b2cf2989f28d 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.spec.ts @@ -29,18 +29,20 @@ describe('UserAddPageComponent', () => { }); describe('template', () => { - it('should render the users roles component if feature toggle is true', () => { - environment.features.benutzerRollen = true; - fixture.detectChanges(); + describe('admin-user-add-form', () => { + it('should be rendered if feature toggle for benutzerRollen is true', () => { + environment.features.benutzerRollen = true; + fixture.detectChanges(); - existsAsHtmlElement(fixture, userAddFormSelector); - }); + existsAsHtmlElement(fixture, userAddFormSelector); + }); - it('should not render the users roles component if feature toggle is false', () => { - environment.features.benutzerRollen = false; - fixture.detectChanges(); + it('should not be rendered if feature toggle for benutzerRollen is false', () => { + environment.features.benutzerRollen = false; + fixture.detectChanges(); - notExistsAsHtmlElement(fixture, userAddFormSelector); + notExistsAsHtmlElement(fixture, userAddFormSelector); + }); }); }); }); diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.spec.ts b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.spec.ts index a25520507ff6a3cf0c41caa26bffe2ca64f35062..0819e2bec035d19f66a785198869252ca1bbfa7c 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.spec.ts +++ b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.spec.ts @@ -30,18 +30,20 @@ describe('UserRolesPageComponent', () => { }); describe('template', () => { - it('should render the users roles component if feature toggle is true', () => { - environment.features.benutzerRollen = true; - fixture.detectChanges(); + describe('admin-users-roles', () => { + it('should be rendered if feature toggle benutzerRollen is true', () => { + environment.features.benutzerRollen = true; + fixture.detectChanges(); - existsAsHtmlElement(fixture, usersRolesSelector); - }); + existsAsHtmlElement(fixture, usersRolesSelector); + }); - it('should not render the users roles component if feature toggle is false', () => { - environment.features.benutzerRollen = false; - fixture.detectChanges(); + it('should not be rendered component if feature toggle benutzerRollen is false', () => { + environment.features.benutzerRollen = false; + fixture.detectChanges(); - notExistsAsHtmlElement(fixture, usersRolesSelector); + notExistsAsHtmlElement(fixture, usersRolesSelector); + }); }); }); });