diff --git a/alfa-client/apps/admin/src/app/app.component.html b/alfa-client/apps/admin/src/app/app.component.html index dbf35b4267a3086cc9a3fec2c6ecf4aefbe2b976..1bf3181be49c2b39c5f0273266c0f5a07cf75d57 100644 --- a/alfa-client/apps/admin/src/app/app.component.html +++ b/alfa-client/apps/admin/src/app/app.component.html @@ -40,22 +40,32 @@ </header> <div class="flex h-screen w-full justify-center overflow-y-auto"> <ods-navbar data-test-id="navigation"> - <ng-container *ngIf="apiRoot | hasLink: ApiRootLinkRel.CONFIGURATION"> - <ods-nav-item caption="Benutzer & Rollen" path="/benutzer_und_rollen"> - <ods-users-icon class="stroke-text" icon /> - </ods-nav-item> - <hr /> - <ods-nav-item caption="Postfach" path="/postfach"> - <ods-mailbox-icon icon /> - </ods-nav-item> - <ods-nav-item caption="Organisationseinheiten" path="/organisationseinheiten"> - <ods-orga-unit-icon icon /> - </ods-nav-item> + <ng-container *ngIf="apiRoot | hasLink: apiRootLinkRel.CONFIGURATION"> + <ng-container *ngIf="environment.features.benutzerRollen"> + <ods-nav-item data-test-id="users-roles-navigation" caption="Benutzer & Rollen" path="/benutzer_und_rollen"> + <ods-users-icon class="stroke-text" icon /> + </ods-nav-item> + <hr /> + </ng-container> + <ng-container *ngIf="environment.features.postfach"> + <ods-nav-item data-test-id="postfach-navigation" caption="Postfach" path="/postfach"> + <ods-mailbox-icon icon /> + </ods-nav-item> + </ng-container> + <ng-container *ngIf="apiRoot | hasLink: apiRootLinkRel.ORGANISATIONS_EINHEIT"> + <ods-nav-item + data-test-id="organisations-einheiten-navigation" + caption="Organisationseinheiten" + path="/organisationseinheiten" + > + <ods-orga-unit-icon icon /> + </ods-nav-item> + </ng-container> </ng-container> </ods-navbar> <main class="flex-1 overflow-y-auto bg-white px-6 py-4"> <router-outlet - *ngIf="apiRoot | hasLink: ApiRootLinkRel.CONFIGURATION; else configurationResourceLinkNotAvailable" + *ngIf="apiRoot | hasLink: apiRootLinkRel.CONFIGURATION; else configurationResourceLinkNotAvailable" data-test-id="router-outlet" ></router-outlet> <ng-template #configurationResourceLinkNotAvailable> diff --git a/alfa-client/apps/admin/src/app/app.component.spec.ts b/alfa-client/apps/admin/src/app/app.component.spec.ts index e873c4c8a7069f6b52b612bca299a8a8e7d51329..47e52ca32268a84cd26ea728858fad6b0265e96a 100644 --- a/alfa-client/apps/admin/src/app/app.component.spec.ts +++ b/alfa-client/apps/admin/src/app/app.component.spec.ts @@ -23,6 +23,7 @@ */ import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { BuildInfoComponent } from '@alfa-client/common'; +import { getEnvironmentFactory } from '@alfa-client/environment-shared'; import { HasLinkPipe, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; import { Mock, @@ -44,6 +45,7 @@ import { } from '@ods/system'; import { AuthenticationService } from 'authentication'; import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; +import { createEnvironment } from 'libs/environment-shared/test/environment'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent, MockDirective } from 'ng-mocks'; import { of } from 'rxjs'; @@ -51,6 +53,8 @@ import { UserProfileButtonContainerComponent } from '../common/user-profile-butt import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component'; import { AppComponent } from './app.component'; +jest.mock('@alfa-client/environment-shared'); + describe('AppComponent', () => { let component: AppComponent; let fixture: ComponentFixture<AppComponent>; @@ -59,9 +63,15 @@ describe('AppComponent', () => { const buildInfoSelector: string = getDataTestIdOf('build-info'); const userProfileButtonSelector: string = getDataTestIdOf('user-profile-button'); const navigationSelector: string = getDataTestIdOf('navigation'); + const usersRolesNavigationSelector: string = getDataTestIdOf('users-roles-navigation'); + const postfachNavigationSelector: string = getDataTestIdOf('postfach-navigation'); + const organisationsEinheitenNavigationSelector: string = getDataTestIdOf('organisations-einheiten-navigation'); const logoLink: string = getDataTestIdOf('logo-link'); const routerOutletSelector: string = getDataTestIdOf('router-outlet'); + const environment = createEnvironment(); + (getEnvironmentFactory as jest.Mock).mockReturnValue(environment); + const authenticationService: Mock<AuthenticationService> = { ...mock(AuthenticationService), login: jest.fn().mockResolvedValue(Promise.resolve()), @@ -208,8 +218,11 @@ describe('AppComponent', () => { }); describe('navigation', () => { - it('should show links if configuration link exists', () => { + beforeEach(() => { component.apiRootStateResource$ = of(createStateResource(createApiRootResource([ApiRootLinkRel.CONFIGURATION]))); + }); + + it('should show links if configuration link exists', () => { fixture.detectChanges(); const navbarElement: HTMLElement = getElementFromFixture(fixture, navigationSelector); @@ -225,6 +238,49 @@ describe('AppComponent', () => { expect(navbarElement.children.length).toBe(0); }); + + it('should show postfach link if postfach feature toggle is true', () => { + component.environment.features.postfach = true; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, postfachNavigationSelector); + }); + + it('should not show postfach link if postfach feature toggle is false', () => { + component.environment.features.postfach = false; + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, postfachNavigationSelector); + }); + + it('should show benutzer & rollen if benutzerRollen feature toggle is true', () => { + component.environment.features.benutzerRollen = true; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, usersRolesNavigationSelector); + }); + + it('should not show benutzer & rollen if benutzerRollen feature toggle is false', () => { + component.environment.features.benutzerRollen = false; + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, usersRolesNavigationSelector); + }); + + it('should show organisationsEinheiten if link in apiRoot exists', () => { + component.apiRootStateResource$ = of( + createStateResource(createApiRootResource([ApiRootLinkRel.ORGANISATIONS_EINHEIT, ApiRootLinkRel.CONFIGURATION])), + ); + fixture.detectChanges(); + + existsAsHtmlElement(fixture, organisationsEinheitenNavigationSelector); + }); + + it('should not show organisationsEinheiten if link in apiRoot does not exist', () => { + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, organisationsEinheitenNavigationSelector); + }); }); describe('build version', () => { diff --git a/alfa-client/apps/admin/src/app/app.component.ts b/alfa-client/apps/admin/src/app/app.component.ts index d130469cdafedfe1d8086b0780db40a58fa2ca0d..6dc6936abb0e6e2d7fef0c644a631c53cc87fa8a 100644 --- a/alfa-client/apps/admin/src/app/app.component.ts +++ b/alfa-client/apps/admin/src/app/app.component.ts @@ -22,6 +22,7 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; +import { Environment, getEnvironmentFactory } from '@alfa-client/environment-shared'; import { StateResource } from '@alfa-client/tech-shared'; import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; @@ -37,6 +38,9 @@ export class AppComponent implements OnInit { readonly title = 'admin'; public apiRootStateResource$: Observable<StateResource<ApiRootResource>>; + public readonly environment: Environment = getEnvironmentFactory(); + + public readonly apiRootLinkRel = ApiRootLinkRel; constructor( public authenticationService: AuthenticationService, @@ -63,6 +67,4 @@ export class AppComponent implements OnInit { const { iss, state, session_state, code, ...queryParams } = this.route.snapshot.queryParams; return queryParams; } - - protected readonly ApiRootLinkRel = ApiRootLinkRel; } diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.html b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.html index 9848aa4ee1a9324d610396a2ab220f27ee59825c..fca49823df0221f08cab813339b1d78c30e2e05c 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.html +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.html @@ -23,4 +23,8 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<admin-organisationseinheit-form-container/> \ No newline at end of file +<ng-container *ngIf="(apiRootStateResource$ | async)?.resource as apiRoot"> + @if (apiRoot | hasLink: apiRootLinkRel.ORGANISATIONS_EINHEIT) { + <admin-organisationseinheit-form-container data-test-id="organisations-einheit-form" /> + } +</ng-container> 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 8e2b1c2555223a4b58466c93698d10661b96483e..e0d2d21f172de4baa71a6fcb48adadc57e2d4e6a 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 @@ -22,17 +22,32 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { OrganisationsEinheitFormContainerComponent } from '@admin-client/admin-settings'; +import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; +import { createStateResource, StateResource, TechSharedModule } from '@alfa-client/tech-shared'; +import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { singleColdCompleted } from 'libs/tech-shared/test/marbles'; import { MockComponent } from 'ng-mocks'; +import { Observable, of } from 'rxjs'; import { OrganisationsEinheitFormPageComponent } from './organisationseinheit-form-page.component'; describe('OrganisationsEinheitFormPageComponent', () => { let component: OrganisationsEinheitFormPageComponent; let fixture: ComponentFixture<OrganisationsEinheitFormPageComponent>; + const organisationsEinheitFormSelector: string = getDataTestIdOf('organisations-einheit-form'); + + let apiRootService: Mock<ApiRootService>; + beforeEach(async () => { + apiRootService = mock(ApiRootService); + await TestBed.configureTestingModule({ + imports: [TechSharedModule], declarations: [OrganisationsEinheitFormPageComponent, MockComponent(OrganisationsEinheitFormContainerComponent)], + providers: [{ provide: ApiRootService, useValue: apiRootService }], }).compileComponents(); }); @@ -46,4 +61,45 @@ describe('OrganisationsEinheitFormPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('component', () => { + describe('ngOnInit', () => { + const apiRootStateResource: StateResource<ApiRootResource> = createStateResource(createApiRootResource()); + const apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(apiRootStateResource); + + beforeEach(() => { + apiRootService.getApiRoot.mockReturnValue(apiRootStateResource$); + }); + + it('should call apiRootService getApiRoot', () => { + component.ngOnInit(); + + expect(apiRootService.getApiRoot).toHaveBeenCalled(); + }); + + it('should get apiRootStateResource$', () => { + component.ngOnInit(); + + expect(component.apiRootStateResource$).toBeObservable(singleColdCompleted(apiRootStateResource)); + }); + }); + }); + + describe('template', () => { + 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, organisationsEinheitFormSelector); + }); + + it('should not be rendered if apiRootState has no link', () => { + component.apiRootStateResource$ = of(createStateResource(createApiRootResource())); + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, organisationsEinheitFormSelector); + }); + }); + }); }); diff --git a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.ts b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.ts index 2d7a1479fea9a39358fe326b3e5f751e90cfe42f..3a62a7cfbb243c6432d189fc3e9d02f91084be4f 100644 --- a/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.ts +++ b/alfa-client/apps/admin/src/pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component.ts @@ -21,10 +21,23 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -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, OnInit } from '@angular/core'; +import { Observable, of } from 'rxjs'; @Component({ selector: 'organisationseinheit-form-page', templateUrl: './organisationseinheit-form-page.component.html', }) -export class OrganisationsEinheitFormPageComponent {} +export class OrganisationsEinheitFormPageComponent implements OnInit { + private apiRootService = inject(ApiRootService); + + public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>()); + + public readonly apiRootLinkRel = ApiRootLinkRel; + + ngOnInit(): void { + this.apiRootStateResource$ = this.apiRootService.getApiRoot(); + } +} 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 798bbb222bab649759a3a1945618189ac39b2255..c6b911fd2bd0dbec75e9fd4a62eb0ac2813c428e 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 @@ -23,4 +23,8 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<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> 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 adee98f70cf2dc490f20f93e064011785c4b6a40..fccde3c44eadce5a59c51bc5a5548597ff0f0a43 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 @@ -22,17 +22,32 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { OrganisationsEinheitContainerComponent } from '@admin-client/admin-settings'; +import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; +import { createStateResource, StateResource, TechSharedModule } from '@alfa-client/tech-shared'; +import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; +import { singleColdCompleted } from 'libs/tech-shared/test/marbles'; import { MockComponent } from 'ng-mocks'; +import { Observable, of } from 'rxjs'; import { OrganisationsEinheitPageComponent } from './organisationseinheit-page.component'; describe('OrganisationsEinheitPageComponent', () => { let component: OrganisationsEinheitPageComponent; let fixture: ComponentFixture<OrganisationsEinheitPageComponent>; + const organisationsEinheitContainerSelector: string = getDataTestIdOf('organisations-einheit-container'); + + let apiRootService: Mock<ApiRootService>; + beforeEach(async () => { + apiRootService = mock(ApiRootService); + await TestBed.configureTestingModule({ + imports: [TechSharedModule], declarations: [OrganisationsEinheitPageComponent, MockComponent(OrganisationsEinheitContainerComponent)], + providers: [{ provide: ApiRootService, useValue: apiRootService }], }).compileComponents(); }); @@ -46,4 +61,45 @@ describe('OrganisationsEinheitPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('component', () => { + describe('ngOnInit', () => { + const apiRootStateResource: StateResource<ApiRootResource> = createStateResource(createApiRootResource()); + const apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(apiRootStateResource); + + beforeEach(() => { + apiRootService.getApiRoot.mockReturnValue(apiRootStateResource$); + }); + + it('should call apiRootService getApiRoot', () => { + component.ngOnInit(); + + expect(apiRootService.getApiRoot).toHaveBeenCalled(); + }); + + it('should get apiRootStateResource$', () => { + component.ngOnInit(); + + expect(component.apiRootStateResource$).toBeObservable(singleColdCompleted(apiRootStateResource)); + }); + }); + }); + + 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 abede46a36bbdeadd51a596224f0e4b569bbfbc7..e24994ae5e1fcafdf6e7cc153da2b40f0db2f218 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 @@ -21,10 +21,23 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -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, OnInit } from '@angular/core'; +import { Observable, of } from 'rxjs'; @Component({ selector: 'organisationseinheit-page', templateUrl: './organisationseinheit-page.component.html', }) -export class OrganisationsEinheitPageComponent {} +export class OrganisationsEinheitPageComponent implements OnInit { + private apiRootService = inject(ApiRootService); + + public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>()); + + public readonly apiRootLinkRel = ApiRootLinkRel; + + ngOnInit(): void { + this.apiRootStateResource$ = this.apiRootService.getApiRoot(); + } +} 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 5e8a60c93c273b96363115f317ea711ee484f502..323961ecd53f966827744fef12654efaa6444c92 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 @@ -23,4 +23,6 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<admin-postfach-container></admin-postfach-container> +@if (environment.features.postfach) { + <admin-postfach-container data-test-id="postfach-container" /> +} 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 75e5b7e35f48288cb3a8078503825d7ca3e2e3c2..5d000e0a2b734afc40086b414b0d5e8776bf4e85 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 @@ -22,14 +22,25 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { PostfachContainerComponent } from '@admin-client/admin-settings'; +import { getEnvironmentFactory } from '@alfa-client/environment-shared'; +import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createEnvironment } from 'libs/environment-shared/test/environment'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { PostfachPageComponent } from './postfach-page.component'; +jest.mock('@alfa-client/environment-shared'); + describe('PostfachPageComponent', () => { let component: PostfachPageComponent; let fixture: ComponentFixture<PostfachPageComponent>; + const postfachContainerSelector: string = getDataTestIdOf('postfach-container'); + + const environment = createEnvironment(); + (getEnvironmentFactory as jest.Mock).mockReturnValue(environment); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [PostfachPageComponent, MockComponent(PostfachContainerComponent)], @@ -39,11 +50,28 @@ describe('PostfachPageComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(PostfachPageComponent); component = fixture.componentInstance; - 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 7c20736f71530c2283c03b59fd2c75c7df5a1ba5..888d44c066acb8c54b8d3c8f3f662bd0c783f404 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 @@ -21,10 +21,13 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +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 readonly environment: Environment = getEnvironmentFactory(); +} diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.html b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.html index e66706ba8d9fddff3b5aa4aeada99c9618471732..51a20e77113f69a4974e2886c91ea147f47fc9de 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.html +++ b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.html @@ -23,4 +23,6 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<admin-user-add-form /> +@if (environment.features.benutzerRollen) { + <admin-user-add-form data-test-id="user-add-form" /> +} 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 fd3a0127718e1307bcd2257b208630848ca6e999..13478e0f8f00dd03b6ef09b17b618c3d9e094388 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 @@ -22,14 +22,25 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { UserAddFormComponent } from '@admin-client/admin-settings'; +import { getEnvironmentFactory } from '@alfa-client/environment-shared'; +import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createEnvironment } from 'libs/environment-shared/test/environment'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { UserAddPageComponent } from './user-add-page.component'; +jest.mock('@alfa-client/environment-shared'); + describe('UserAddPageComponent', () => { let component: UserAddPageComponent; let fixture: ComponentFixture<UserAddPageComponent>; + const userAddFormSelector: string = getDataTestIdOf('user-add-form'); + + const environment = createEnvironment(); + (getEnvironmentFactory as jest.Mock).mockReturnValue(environment); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [UserAddPageComponent, MockComponent(UserAddFormComponent)], @@ -43,4 +54,22 @@ describe('UserAddPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('template', () => { + 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); + }); + + it('should not be rendered if feature toggle for benutzerRollen is false', () => { + environment.features.benutzerRollen = false; + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, userAddFormSelector); + }); + }); + }); }); diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.ts b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.ts index b6901fb17d9d95a06a6321342b81ed17cfc83697..9b4ccbdfdc5cb58bf2afcbef09d2700aacdcca88 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.ts +++ b/alfa-client/apps/admin/src/pages/users-roles/user-add-page/user-add-page.component.ts @@ -21,10 +21,13 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { Environment, getEnvironmentFactory } from '@alfa-client/environment-shared'; import { Component } from '@angular/core'; @Component({ selector: 'user-add-page', templateUrl: './user-add-page.component.html', }) -export class UserAddPageComponent {} +export class UserAddPageComponent { + public readonly environment: Environment = getEnvironmentFactory(); +} diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.html b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.html index 000c3e5a2182dbbc5ea2bc67c4ac2e140f4a10bb..35bbbc0007a18979bf7904595c5910d09316cb3b 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.html +++ b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.html @@ -23,4 +23,6 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<admin-users-roles /> \ No newline at end of file +@if (environment.features.benutzerRollen) { + <admin-users-roles data-test-id="users-roles" /> +} 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 72526ae5d76c5f21580a38d0662f1df55b4c9127..d6e0ed998c333bdcdbde92edbed4abdff395f984 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 @@ -22,14 +22,25 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { UsersRolesComponent } from '@admin-client/admin-settings'; +import { getEnvironmentFactory } from '@alfa-client/environment-shared'; +import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { createEnvironment } from 'libs/environment-shared/test/environment'; +import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { UserRolesPageComponent } from './user-roles-page.component'; +jest.mock('@alfa-client/environment-shared'); + describe('UserRolesPageComponent', () => { let component: UserRolesPageComponent; let fixture: ComponentFixture<UserRolesPageComponent>; + const usersRolesSelector: string = getDataTestIdOf('users-roles'); + + const environment = createEnvironment(); + (getEnvironmentFactory as jest.Mock).mockReturnValue(environment); + beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [UserRolesPageComponent], @@ -44,4 +55,22 @@ describe('UserRolesPageComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + describe('template', () => { + describe('admin-users-roles', () => { + it('should be rendered if feature toggle benutzerRollen is true', () => { + environment.features.benutzerRollen = true; + fixture.detectChanges(); + + existsAsHtmlElement(fixture, usersRolesSelector); + }); + + it('should not be rendered component if feature toggle benutzerRollen is false', () => { + environment.features.benutzerRollen = false; + fixture.detectChanges(); + + notExistsAsHtmlElement(fixture, usersRolesSelector); + }); + }); + }); }); diff --git a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.ts b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.ts index 6078ea313fc4ea0e46c87c3b01e177fe1c3fffcc..8c059c1eb09245e2492f737233c3baa7c19e5a82 100644 --- a/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.ts +++ b/alfa-client/apps/admin/src/pages/users-roles/user-roles-page/user-roles-page.component.ts @@ -21,10 +21,13 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { Environment, getEnvironmentFactory } from '@alfa-client/environment-shared'; import { Component } from '@angular/core'; @Component({ selector: 'app-user-roles-page', templateUrl: './user-roles-page.component.html', }) -export class UserRolesPageComponent {} +export class UserRolesPageComponent { + public readonly environment: Environment = getEnvironmentFactory(); +} diff --git a/alfa-client/libs/environment-shared/src/lib/environment.model.ts b/alfa-client/libs/environment-shared/src/lib/environment.model.ts index 83e2674c9e48c189746d57f5751496a00d655f5f..751085929a4e9756a07fd3b7615197b75dd77553 100644 --- a/alfa-client/libs/environment-shared/src/lib/environment.model.ts +++ b/alfa-client/libs/environment-shared/src/lib/environment.model.ts @@ -30,4 +30,8 @@ export interface Environment { realm: string; clientId: string; processorNames: string[]; + features: { + postfach: boolean; + benutzerRollen: boolean; + }; } diff --git a/alfa-client/libs/environment-shared/test/environment.ts b/alfa-client/libs/environment-shared/test/environment.ts index ef29099703a89b5bb9d0fc989a1de91a13070bc4..a0b3bf79e50da3351ab61283e7903d4747956942 100644 --- a/alfa-client/libs/environment-shared/test/environment.ts +++ b/alfa-client/libs/environment-shared/test/environment.ts @@ -32,6 +32,10 @@ const environment: Environment = { realm: faker.word.sample(), clientId: faker.string.uuid(), processorNames: [faker.person.fullName()], + features: { + postfach: true, + benutzerRollen: true, + }, }; export function createEnvironment(): Environment { diff --git a/alfa-client/tsconfig.base.json b/alfa-client/tsconfig.base.json index c5305dcc83a25e9d9243459743806ce905bdbaa8..31d83c1b32d909a18934ccd5695464f05b160782 100644 --- a/alfa-client/tsconfig.base.json +++ b/alfa-client/tsconfig.base.json @@ -66,7 +66,7 @@ "@alfa-client/zustaendige-stelle-shared": ["libs/zustaendige-stelle-shared/src/index.ts"], "@ods/component": ["libs/design-component/src/index.ts"], "@ods/system": ["libs/design-system/src/index.ts"], - "authentication": ["libs/authentication/src/index.ts"], + "authentication": ["libs/authentication/src/index.ts"] } }, "exclude": ["node_modules", "tmp"]