Skip to content
Snippets Groups Projects
Commit 9246ea48 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6700 feature toggle in pages

parent f3f3c760
No related branches found
No related tags found
No related merge requests found
Showing
with 112 additions and 28 deletions
......@@ -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);
});
});
});
......
<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
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);
});
});
});
});
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;
}
<admin-postfach-container></admin-postfach-container>
@if(environment.features.postfach){
<admin-postfach-container data-test-id="postfach-container"/>
}
\ No newline at end of file
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);
});
});
});
});
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();
}
......@@ -29,14 +29,15 @@ describe('UserAddPageComponent', () => {
});
describe('template', () => {
it('should render the users roles component if feature toggle is true', () => {
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 render the users roles component if feature toggle is false', () => {
it('should not be rendered if feature toggle for benutzerRollen is false', () => {
environment.features.benutzerRollen = false;
fixture.detectChanges();
......@@ -44,3 +45,4 @@ describe('UserAddPageComponent', () => {
});
});
});
});
......@@ -30,14 +30,15 @@ describe('UserRolesPageComponent', () => {
});
describe('template', () => {
it('should render the users roles component if feature toggle is true', () => {
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 render the users roles component if feature toggle is false', () => {
it('should not be rendered component if feature toggle benutzerRollen is false', () => {
environment.features.benutzerRollen = false;
fixture.detectChanges();
......@@ -45,3 +46,4 @@ describe('UserRolesPageComponent', () => {
});
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment