Skip to content
Snippets Groups Projects
Commit 6ededafb authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-4993-Organisationseinheit-Input-Validation

parents 4f658d1b 152d9adf
No related branches found
No related tags found
No related merge requests found
...@@ -10,11 +10,23 @@ ...@@ -10,11 +10,23 @@
<div class="flex w-full flex-auto justify-center overflow-y-auto"> <div class="flex w-full flex-auto justify-center overflow-y-auto">
<div class="w-72 bg-slate-100 p-6"> <div class="w-72 bg-slate-100 p-6">
<nav> <nav>
<admin-navigation data-test-id="navigation"></admin-navigation> <admin-navigation
*ngIf="apiRoot | hasLink: ApiRootLinkRel.CONFIGURATION"
data-test-id="navigation"
></admin-navigation>
</nav> </nav>
</div> </div>
<main class="flex-auto overflow-y-auto bg-slate-200 p-6"> <main class="flex-auto overflow-y-auto bg-slate-200 p-6">
<router-outlet></router-outlet> <router-outlet
*ngIf="
apiRoot | hasLink: ApiRootLinkRel.CONFIGURATION;
else configurationResourceLinkNotAvailable
"
data-test-id="router-outlet"
></router-outlet>
<ng-template #configurationResourceLinkNotAvailable>
<unavailable-page></unavailable-page>
</ng-template>
</main> </main>
</div> </div>
<span data-test-id="build-version">Version: {{ apiRoot.version }}</span> <span data-test-id="build-version">Version: {{ apiRoot.version }}</span>
......
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import {
import { ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; existsAsHtmlElement,
getElementFromFixture,
mock,
Mock,
notExistsAsHtmlElement,
} from '@alfa-client/test-utils';
import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; import {
createEmptyStateResource,
createStateResource,
HasLinkPipe,
} from '@alfa-client/tech-shared';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { createApiRootResource } from 'libs/api-root-shared/test/api-root'; import { createApiRootResource } from 'libs/api-root-shared/test/api-root';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
...@@ -12,15 +22,17 @@ import { Router } from '@angular/router'; ...@@ -12,15 +22,17 @@ import { Router } from '@angular/router';
import { NavigationComponent } from 'libs/admin-settings/src/lib/navigation/navigation.component'; import { NavigationComponent } from 'libs/admin-settings/src/lib/navigation/navigation.component';
import { AuthenticationService } from 'authentication'; import { AuthenticationService } from 'authentication';
import { UserProfileButtonContainerComponent } from '../common/user-profile-button-container/user-profile.button-container.component'; import { UserProfileButtonContainerComponent } from '../common/user-profile-button-container/user-profile.button-container.component';
import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component';
describe('AppComponent', () => { describe('AppComponent', () => {
let component: AppComponent; let component: AppComponent;
let fixture: ComponentFixture<AppComponent>; let fixture: ComponentFixture<AppComponent>;
const adminHeader: string = getDataTestIdOf('admin-header'); const adminHeaderSelector: string = getDataTestIdOf('admin-header');
const buildVersion: string = getDataTestIdOf('build-version'); const buildVersionSelector: string = getDataTestIdOf('build-version');
const userProfileButton: string = getDataTestIdOf('user-profile-button'); const userProfileButtonSelector: string = getDataTestIdOf('user-profile-button');
const navigation: string = getDataTestIdOf('navigation'); const navigationSelector: string = getDataTestIdOf('navigation');
const routerOutletSelector: string = getDataTestIdOf('router-outlet');
const authenticationService: Mock<AuthenticationService> = { const authenticationService: Mock<AuthenticationService> = {
...mock(AuthenticationService), ...mock(AuthenticationService),
...@@ -36,6 +48,8 @@ describe('AppComponent', () => { ...@@ -36,6 +48,8 @@ describe('AppComponent', () => {
AppComponent, AppComponent,
MockComponent(NavigationComponent), MockComponent(NavigationComponent),
MockComponent(UserProfileButtonContainerComponent), MockComponent(UserProfileButtonContainerComponent),
MockComponent(UnavailablePageComponent),
HasLinkPipe,
], ],
imports: [RouterTestingModule], imports: [RouterTestingModule],
providers: [ providers: [
...@@ -58,7 +72,6 @@ describe('AppComponent', () => { ...@@ -58,7 +72,6 @@ describe('AppComponent', () => {
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges();
}); });
it(`should have as title 'admin'`, () => { it(`should have as title 'admin'`, () => {
...@@ -101,7 +114,7 @@ describe('AppComponent', () => { ...@@ -101,7 +114,7 @@ describe('AppComponent', () => {
it('show not show header if apiRoot is not loaded', () => { it('show not show header if apiRoot is not loaded', () => {
component.apiRootStateResource$ = of(createEmptyStateResource<ApiRootResource>()); component.apiRootStateResource$ = of(createEmptyStateResource<ApiRootResource>());
notExistsAsHtmlElement(fixture, adminHeader); notExistsAsHtmlElement(fixture, adminHeaderSelector);
}); });
describe('user profile button', () => { describe('user profile button', () => {
...@@ -112,30 +125,63 @@ describe('AppComponent', () => { ...@@ -112,30 +125,63 @@ describe('AppComponent', () => {
it('should show if apiRoot exists', () => { it('should show if apiRoot exists', () => {
fixture.detectChanges(); fixture.detectChanges();
existsAsHtmlElement(fixture, userProfileButton); existsAsHtmlElement(fixture, userProfileButtonSelector);
}); });
}); });
describe('navigation', () => { describe('navigation', () => {
beforeEach(() => { beforeEach(() => {});
component.apiRootStateResource$ = of(createStateResource(createApiRootResource())); it('should exist if configuration link exists', () => {
component.apiRootStateResource$ = of(
createStateResource(createApiRootResource([ApiRootLinkRel.CONFIGURATION])),
);
fixture.detectChanges();
existsAsHtmlElement(fixture, navigationSelector);
}); });
it('should exists', () => {
it('should not exist if configuration resource not available', () => {
fixture.detectChanges(); fixture.detectChanges();
existsAsHtmlElement(fixture, navigation); notExistsAsHtmlElement(fixture, navigationSelector);
}); });
}); });
describe('build version', () => { describe('build version', () => {
const apiResource: ApiRootResource = createApiRootResource();
beforeEach(() => { beforeEach(() => {
component.apiRootStateResource$ = of(createStateResource(createApiRootResource())); component.apiRootStateResource$ = of(createStateResource(apiResource));
}); });
it('should show after apiRoot loaded', () => { it('should show after apiRoot loaded', () => {
fixture.detectChanges(); fixture.detectChanges();
existsAsHtmlElement(fixture, buildVersion); const buildVersionElement = getElementFromFixture(fixture, buildVersionSelector);
expect(buildVersionElement.textContent.trim()).toEqual(`Version: ${apiResource.version}`);
});
});
describe('router outlet', () => {
beforeEach(() => {});
it('should exist if configuration resource available', () => {
component.apiRootStateResource$ = of(
createStateResource(createApiRootResource([ApiRootLinkRel.CONFIGURATION])),
);
fixture.detectChanges();
existsAsHtmlElement(fixture, routerOutletSelector);
});
it('should not exist if configuration resource not available', () => {
component.apiRootStateResource$ = of(createStateResource(createApiRootResource()));
fixture.detectChanges();
notExistsAsHtmlElement(fixture, routerOutletSelector);
}); });
}); });
}); });
import { ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared'; import { ApiRootLinkRel, ApiRootResource, ApiRootService } from '@alfa-client/api-root-shared';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
...@@ -29,4 +29,6 @@ export class AppComponent implements OnInit { ...@@ -29,4 +29,6 @@ export class AppComponent implements OnInit {
this.apiRootStateResource$ = this.apiRootService.getApiRoot(); this.apiRootStateResource$ = this.apiRootService.getApiRoot();
this.router.navigate(['/']); this.router.navigate(['/']);
} }
protected readonly ApiRootLinkRel = ApiRootLinkRel;
} }
...@@ -21,6 +21,8 @@ import { AdminSettingsModule } from '@admin-client/admin-settings'; ...@@ -21,6 +21,8 @@ import { AdminSettingsModule } from '@admin-client/admin-settings';
import { OAuthModule } from 'angular-oauth2-oidc'; import { OAuthModule } from 'angular-oauth2-oidc';
import { HttpUnauthorizedInterceptor } from 'libs/authentication/src/lib/http-unauthorized.interceptor'; import { HttpUnauthorizedInterceptor } from 'libs/authentication/src/lib/http-unauthorized.interceptor';
import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component'; import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component';
import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component';
import { TechSharedModule } from '@alfa-client/tech-shared';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -28,6 +30,7 @@ import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit ...@@ -28,6 +30,7 @@ import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit
PostfachPageComponent, PostfachPageComponent,
OrganisationseinheitPageComponent, OrganisationseinheitPageComponent,
UserProfileButtonContainerComponent, UserProfileButtonContainerComponent,
UnavailablePageComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,
...@@ -50,6 +53,7 @@ import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit ...@@ -50,6 +53,7 @@ import { OrganisationseinheitPageComponent } from '../pages/organisationseinheit
sendAccessToken: true, sendAccessToken: true,
}, },
}), }),
TechSharedModule,
], ],
providers: [ providers: [
{ {
......
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PostfachPageComponent } from './postfach-page.component'; import { PostfachPageComponent } from './postfach-page.component';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { ReactiveFormsModule } from '@angular/forms';
import { PostfachContainerComponent } from '@admin-client/admin-settings'; import { PostfachContainerComponent } from '@admin-client/admin-settings';
describe('PostfachPageComponent', () => { describe('PostfachPageComponent', () => {
...@@ -11,7 +10,6 @@ describe('PostfachPageComponent', () => { ...@@ -11,7 +10,6 @@ describe('PostfachPageComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [PostfachPageComponent, MockComponent(PostfachContainerComponent)], declarations: [PostfachPageComponent, MockComponent(PostfachContainerComponent)],
imports: [ReactiveFormsModule],
}).compileComponents(); }).compileComponents();
}); });
......
<p class="mb-2 block font-bold">Die Administrations-Oberfläche ist nicht verfügbar.</p>
<p>
Prüfen Sie, ob folgendes zutrifft:<br />
Ihnen ist die Rolle Admin_Admin zugewiesen.<br />
Bitte bei der verantwortlichen Person des User-Managements bzw. des Keycloaks melden.<br />
</p>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UnavailablePageComponent } from './unavailable-page.component';
describe('UnavailablePageComponent', () => {
let component: UnavailablePageComponent;
let fixture: ComponentFixture<UnavailablePageComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [UnavailablePageComponent],
}).compileComponents();
fixture = TestBed.createComponent(UnavailablePageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
@Component({
selector: 'unavailable-page',
templateUrl: './unavailable-page.component.html',
styles: [],
})
export class UnavailablePageComponent {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment