Skip to content
Snippets Groups Projects
Commit 1f450870 authored by Albert Bruns's avatar Albert Bruns
Browse files

OZG-6989-7502 guard

parent ee77d1e1
No related branches found
No related tags found
1 merge request!20OZG-6989-7502-statisitk-link-pruefung
Showing
with 15 additions and 239 deletions
...@@ -23,8 +23,4 @@ ...@@ -23,8 +23,4 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
<ng-container *ngIf="(apiRootStateResource$ | async)?.resource as apiRoot">
@if (apiRoot | hasLink: apiRootLinkRel.ORGANISATIONS_EINHEIT) {
<admin-organisations-einheit-form-container data-test-id="organisations-einheit-form" /> <admin-organisations-einheit-form-container data-test-id="organisations-einheit-form" />
\ No newline at end of file
}
</ng-container>
\ No newline at end of file
...@@ -22,33 +22,18 @@ ...@@ -22,33 +22,18 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { OrganisationsEinheitFormContainerComponent } from '@admin-client/organisations-einheit'; import { OrganisationsEinheitFormContainerComponent } from '@admin-client/organisations-einheit';
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 { CommonModule } from '@angular/common';
import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { MockComponent } from 'ng-mocks';
import { Observable, of } from 'rxjs';
import { OrganisationsEinheitFormPageComponent } from './organisationseinheit-form-page.component'; import { OrganisationsEinheitFormPageComponent } from './organisationseinheit-form-page.component';
describe('OrganisationsEinheitFormPageComponent', () => { describe('OrganisationsEinheitFormPageComponent', () => {
let component: OrganisationsEinheitFormPageComponent; let component: OrganisationsEinheitFormPageComponent;
let fixture: ComponentFixture<OrganisationsEinheitFormPageComponent>; let fixture: ComponentFixture<OrganisationsEinheitFormPageComponent>;
const organisationsEinheitFormSelector: string = getDataTestIdOf('organisations-einheit-form');
let apiRootService: Mock<ApiRootService>;
beforeEach(async () => { beforeEach(async () => {
apiRootService = mock(ApiRootService);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [CommonModule, TechSharedModule], imports: [],
declarations: [OrganisationsEinheitFormPageComponent, MockComponent(OrganisationsEinheitFormContainerComponent)], declarations: [OrganisationsEinheitFormPageComponent, MockComponent(OrganisationsEinheitFormContainerComponent)],
providers: [{ provide: ApiRootService, useValue: apiRootService }],
}).compileComponents(); }).compileComponents();
}); });
...@@ -62,45 +47,4 @@ describe('OrganisationsEinheitFormPageComponent', () => { ...@@ -62,45 +47,4 @@ describe('OrganisationsEinheitFormPageComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); 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);
});
});
});
}); });
...@@ -22,27 +22,12 @@ ...@@ -22,27 +22,12 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { OrganisationsEinheitFormContainerComponent } from '@admin-client/organisations-einheit'; import { OrganisationsEinheitFormContainerComponent } from '@admin-client/organisations-einheit';
import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { Component } from '@angular/core';
import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared';
import { UiModule } from '@alfa-client/ui';
import { CommonModule } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
@Component({ @Component({
selector: 'organisationseinheit-form-page', selector: 'organisationseinheit-form-page',
templateUrl: './organisationseinheit-form-page.component.html', templateUrl: './organisationseinheit-form-page.component.html',
standalone: true, standalone: true,
imports: [CommonModule, UiModule, OrganisationsEinheitFormContainerComponent], imports: [OrganisationsEinheitFormContainerComponent],
}) })
export class OrganisationsEinheitFormPageComponent implements OnInit { export class OrganisationsEinheitFormPageComponent {}
private apiRootService = inject(ApiRootService);
public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>());
public readonly apiRootLinkRel = ApiRootLinkRel;
ngOnInit(): void {
this.apiRootStateResource$ = this.apiRootService.getApiRoot();
}
}
...@@ -23,8 +23,4 @@ ...@@ -23,8 +23,4 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
<ng-container *ngIf="(apiRootStateResource$ | async)?.resource as apiRoot">
@if (apiRoot | hasLink: apiRootLinkRel.ORGANISATIONS_EINHEIT) {
<admin-organisations-einheit-container data-test-id="organisations-einheit-container" /> <admin-organisations-einheit-container data-test-id="organisations-einheit-container" />
}
</ng-container>
...@@ -22,33 +22,18 @@ ...@@ -22,33 +22,18 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { OrganisationsEinheitContainerComponent } from '@admin-client/organisations-einheit'; import { OrganisationsEinheitContainerComponent } from '@admin-client/organisations-einheit';
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 { CommonModule } from '@angular/common';
import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { MockComponent } from 'ng-mocks';
import { Observable, of } from 'rxjs';
import { OrganisationsEinheitPageComponent } from './organisationseinheit-page.component'; import { OrganisationsEinheitPageComponent } from './organisationseinheit-page.component';
describe('OrganisationsEinheitPageComponent', () => { describe('OrganisationsEinheitPageComponent', () => {
let component: OrganisationsEinheitPageComponent; let component: OrganisationsEinheitPageComponent;
let fixture: ComponentFixture<OrganisationsEinheitPageComponent>; let fixture: ComponentFixture<OrganisationsEinheitPageComponent>;
const organisationsEinheitContainerSelector: string = getDataTestIdOf('organisations-einheit-container');
let apiRootService: Mock<ApiRootService>;
beforeEach(async () => { beforeEach(async () => {
apiRootService = mock(ApiRootService);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [CommonModule, TechSharedModule], imports: [],
declarations: [OrganisationsEinheitPageComponent, MockComponent(OrganisationsEinheitContainerComponent)], declarations: [OrganisationsEinheitPageComponent, MockComponent(OrganisationsEinheitContainerComponent)],
providers: [{ provide: ApiRootService, useValue: apiRootService }],
}).compileComponents(); }).compileComponents();
}); });
...@@ -62,45 +47,4 @@ describe('OrganisationsEinheitPageComponent', () => { ...@@ -62,45 +47,4 @@ describe('OrganisationsEinheitPageComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); 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);
});
});
});
}); });
...@@ -22,27 +22,12 @@ ...@@ -22,27 +22,12 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { OrganisationsEinheitContainerComponent } from '@admin-client/organisations-einheit'; import { OrganisationsEinheitContainerComponent } from '@admin-client/organisations-einheit';
import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { Component } from '@angular/core';
import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared';
import { UiModule } from '@alfa-client/ui';
import { CommonModule } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
@Component({ @Component({
selector: 'organisationseinheit-page', selector: 'organisationseinheit-page',
templateUrl: './organisationseinheit-page.component.html', templateUrl: './organisationseinheit-page.component.html',
standalone: true, standalone: true,
imports: [CommonModule, OrganisationsEinheitContainerComponent, UiModule], imports: [OrganisationsEinheitContainerComponent],
}) })
export class OrganisationsEinheitPageComponent implements OnInit { export class OrganisationsEinheitPageComponent {}
private apiRootService = inject(ApiRootService);
public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>());
public readonly apiRootLinkRel = ApiRootLinkRel;
ngOnInit(): void {
this.apiRootStateResource$ = this.apiRootService.getApiRoot();
}
}
...@@ -23,8 +23,4 @@ ...@@ -23,8 +23,4 @@
unter der Lizenz sind dem Lizenztext zu entnehmen. unter der Lizenz sind dem Lizenztext zu entnehmen.
--> -->
<ng-container *ngIf="(apiRootStateResource$ | async)?.resource as apiRoot">
@if (apiRoot | hasLink: apiRootLinkRel.AGGREGATION_MAPPING) {
<admin-statistik-container data-test-id="statistik-container" /> <admin-statistik-container data-test-id="statistik-container" />
}
</ng-container>
...@@ -22,33 +22,18 @@ ...@@ -22,33 +22,18 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { StatistikContainerComponent } from '@admin-client/statistik'; import { StatistikContainerComponent } from '@admin-client/statistik';
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 { CommonModule } from '@angular/common';
import { ComponentFixture, TestBed } from '@angular/core/testing'; 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 { MockComponent } from 'ng-mocks';
import { Observable, of } from 'rxjs';
import { StatistikPageComponent } from './statistik-page.component'; import { StatistikPageComponent } from './statistik-page.component';
describe('StatistikPageComponent', () => { describe('StatistikPageComponent', () => {
let component: StatistikPageComponent; let component: StatistikPageComponent;
let fixture: ComponentFixture<StatistikPageComponent>; let fixture: ComponentFixture<StatistikPageComponent>;
const statistikContainerSelector: string = getDataTestIdOf('statistik-container');
let apiRootService: Mock<ApiRootService>;
beforeEach(async () => { beforeEach(async () => {
apiRootService = mock(ApiRootService);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [CommonModule, TechSharedModule], imports: [],
declarations: [StatistikPageComponent, MockComponent(StatistikContainerComponent)], declarations: [StatistikPageComponent, MockComponent(StatistikContainerComponent)],
providers: [{ provide: ApiRootService, useValue: apiRootService }],
}).compileComponents(); }).compileComponents();
}); });
...@@ -62,45 +47,4 @@ describe('StatistikPageComponent', () => { ...@@ -62,45 +47,4 @@ describe('StatistikPageComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); 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('statistik-organisationseinheit-container', () => {
it('should be rendered if apiRootState has link', () => {
component.apiRootStateResource$ = of(createStateResource(createApiRootResource([ApiRootLinkRel.AGGREGATION_MAPPING])));
fixture.detectChanges();
existsAsHtmlElement(fixture, statistikContainerSelector);
});
it('should not be rendered if apiRootState has no link', () => {
component.apiRootStateResource$ = of(createStateResource(createApiRootResource()));
fixture.detectChanges();
notExistsAsHtmlElement(fixture, statistikContainerSelector);
});
});
});
}); });
...@@ -22,26 +22,12 @@ ...@@ -22,26 +22,12 @@
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { StatistikContainerComponent } from '@admin-client/statistik'; import { StatistikContainerComponent } from '@admin-client/statistik';
import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { Component } from '@angular/core';
import { createEmptyStateResource, StateResource, TechSharedModule } from '@alfa-client/tech-shared';
import { CommonModule } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Observable, of } from 'rxjs';
@Component({ @Component({
selector: 'app-statistik-page', selector: 'app-statistik-page',
standalone: true, standalone: true,
imports: [CommonModule, StatistikContainerComponent, TechSharedModule], imports: [StatistikContainerComponent],
templateUrl: './statistik-page.component.html', templateUrl: './statistik-page.component.html',
}) })
export class StatistikPageComponent implements OnInit { export class StatistikPageComponent {}
private readonly apiRootService = inject(ApiRootService);
public apiRootStateResource$: Observable<StateResource<ApiRootResource>> = of(createEmptyStateResource<ApiRootResource>());
public readonly apiRootLinkRel = ApiRootLinkRel;
ngOnInit(): void {
this.apiRootStateResource$ = this.apiRootService.getApiRoot();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment