Skip to content
Snippets Groups Projects
Commit 73bb863e authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6477 organisationseinheitResourceService und externeFachstelleResourceService

parent a8d9d01b
No related branches found
No related tags found
No related merge requests found
Showing
with 239 additions and 106 deletions
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
@for(collaboration of collaborations; track collaboration.zustaendigeStelle){ @for(collaboration of collaborations; track collaboration.zustaendigeStelle){
@if(isOrganisationsEinheit(collaboration)){ @if(isOrganisationsEinheit(collaboration)){
<alfa-organisations-einheit-list-item-container <alfa-organisations-einheit-list-item-container
[zustaendigeStelleResourceUri] = "collaboration.zustaendigeStelle" [organisationsEinheitResourceUri]="collaboration.zustaendigeStelle"
data-test-id="organisations-einheit-list-item" data-test-id="organisations-einheit-list-item"
> >
<alfa-collaboration-request [collaboration]="collaboration"/> <alfa-collaboration-request [collaboration]="collaboration"/>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
} }
@if(isExterneFachstelle(collaboration)){ @if(isExterneFachstelle(collaboration)){
<alfa-externe-fachstelle-list-item-container <alfa-externe-fachstelle-list-item-container
[zustaendigeStelleResourceUri] = "collaboration.zustaendigeStelle" [externeFachstelleResourceUri] = "collaboration.zustaendigeStelle"
data-test-id="externe-fachstelle-list-item" data-test-id="externe-fachstelle-list-item"
> >
<alfa-collaboration-request [collaboration]="collaboration"/> <alfa-collaboration-request [collaboration]="collaboration"/>
......
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lib",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
# externe-fachstelle-shared
This library was generated with [Nx](https://nx.dev).
## Running unit tests
Run `nx test externe-fachstelle-shared` to execute the unit tests.
export default {
displayName: 'externe-fachstelle-shared',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../coverage/libs/externe-fachstelle-shared',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
{
"name": "externe-fachstelle-shared",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/externe-fachstelle-shared/src",
"prefix": "alfa",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"tsConfig": "libs/externe-fachstelle-shared/tsconfig.spec.json",
"jestConfig": "libs/externe-fachstelle-shared/jest.config.ts"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
}
}
}
export * from './lib/externe-fachstelle-resource.service';
...@@ -3,10 +3,10 @@ import { ResourceListService } from '@alfa-client/tech-shared'; ...@@ -3,10 +3,10 @@ import { ResourceListService } from '@alfa-client/tech-shared';
import { mock, Mock } from '@alfa-client/test-utils'; import { mock, Mock } from '@alfa-client/test-utils';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { faker } from '@faker-js/faker/locale/de'; import { faker } from '@faker-js/faker/locale/de';
import { ZustaendigeStelleResourceService } from './zustaendige-stelle-resource.service'; import { ExterneFachstelleResourceService } from './externe-fachstelle-resource.service';
describe('ZustaendigeStelleResourceService', () => { describe('externeFachstelleResourceService', () => {
let service: ZustaendigeStelleResourceService; let service: ExterneFachstelleResourceService;
let collaborationListResourceService: Mock<CollaborationListResourceService>; let collaborationListResourceService: Mock<CollaborationListResourceService>;
const resourceUri = faker.internet.url(); const resourceUri = faker.internet.url();
...@@ -17,21 +17,21 @@ describe('ZustaendigeStelleResourceService', () => { ...@@ -17,21 +17,21 @@ describe('ZustaendigeStelleResourceService', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
ZustaendigeStelleResourceService, ExterneFachstelleResourceService,
{ provide: CollaborationListResourceService, useValue: collaborationListResourceService }, { provide: CollaborationListResourceService, useValue: collaborationListResourceService },
], ],
}); });
service = TestBed.inject(ZustaendigeStelleResourceService); service = TestBed.inject(ExterneFachstelleResourceService);
}); });
it('should be created', () => { it('should be created', () => {
expect(service).toBeTruthy(); expect(service).toBeTruthy();
}); });
describe('getLinkedResource', () => { describe('getOrganisationsEinheit', () => {
it('should call collaborationListService getLinkedResource', () => { it('should call collaborationListService getLinkedResource', () => {
service.getLinkedResource(resourceUri); service.getExterneFachstelle(resourceUri);
expect(collaborationListResourceService.getLinkedResource).toHaveBeenCalledWith(resourceUri); expect(collaborationListResourceService.getLinkedResource).toHaveBeenCalledWith(resourceUri);
}); });
......
import { CollaborationListResourceService } from '@alfa-client/collaboration-shared'; import { CollaborationListResourceService } from '@alfa-client/collaboration-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared';
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { Resource } from '@ngxp/rest';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@Injectable() @Injectable()
export class ZustaendigeStelleResourceService { export class ExterneFachstelleResourceService {
private collaborationListResourceService = inject(CollaborationListResourceService); private collaborationListResourceService = inject(CollaborationListResourceService);
getLinkedResource<F extends Resource>(resourceUri: string): Observable<StateResource<F>> { getExterneFachstelle(resourceUri: string): Observable<StateResource<ExterneFachstelleResource>> {
return this.collaborationListResourceService.getLinkedResource<F>(resourceUri); return this.collaborationListResourceService.getLinkedResource<ExterneFachstelleResource>(resourceUri);
} }
} }
import '@testing-library/jest-dom';
import 'jest-preset-angular/setup-jest';
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
teardown: { destroyAfterEach: false },
errorOnUnknownProperties: true,
errorOnUnknownElements: true,
});
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"target": "es2022"
}
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"target": "es2015",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "jest.config.ts"],
"include": ["**/*.ts"]
}
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"],
"target": "ES2022",
"useDefineForClassFields": false
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts", "jest.config.ts"]
}
<ozgcloud-spinner [stateResource]="externeFachstelleStateResource"> <alfa-externe-fachstelle-list-item [externeFachstelleStateResource]="externeFachstelleStateResource$ | async">
@if(externeFachstelleStateResource.resource){
<alfa-externe-fachstelle-list-item [externeFachstelle]="externeFachstelleStateResource.resource">
<ng-content /> <ng-content />
</alfa-externe-fachstelle-list-item> </alfa-externe-fachstelle-list-item>
\ No newline at end of file
}
</ozgcloud-spinner>
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ExterneFachstelleResourceService } from '@alfa-client/externe-fachstelle-shared';
import { createStateResource } from '@alfa-client/tech-shared'; import { createStateResource } from '@alfa-client/tech-shared';
import { mock, Mock } from '@alfa-client/test-utils'; import { mock, Mock } from '@alfa-client/test-utils';
import { ZustaendigeStelleResourceService } from 'libs/zustaendige-stelle-shared/src/lib/zustaendige-stelle-resource.service';
import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle'; import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { ExterneFachstelleListItemContainerComponent } from './externe-fachstelle-list-item-container.component'; import { ExterneFachstelleListItemContainerComponent } from './externe-fachstelle-list-item-container.component';
...@@ -11,21 +11,21 @@ describe('ExterneFachstelleListItemContainerComponent', () => { ...@@ -11,21 +11,21 @@ describe('ExterneFachstelleListItemContainerComponent', () => {
let component: ExterneFachstelleListItemContainerComponent; let component: ExterneFachstelleListItemContainerComponent;
let fixture: ComponentFixture<ExterneFachstelleListItemContainerComponent>; let fixture: ComponentFixture<ExterneFachstelleListItemContainerComponent>;
let zustaendigeStelleResourceService: Mock<ZustaendigeStelleResourceService>; let externeFachstelleResourceService: Mock<ExterneFachstelleResourceService>;
const externeFachstelle = createExterneFachstelle(); const externeFachstelle = createExterneFachstelle();
const externeFachstelleStateResource = createStateResource(externeFachstelle); const externeFachstelleStateResource = createStateResource(externeFachstelle);
beforeEach(async () => { beforeEach(async () => {
zustaendigeStelleResourceService = { externeFachstelleResourceService = {
...mock(ZustaendigeStelleResourceService), ...mock(ExterneFachstelleResourceService),
getLinkedResource: jest.fn().mockReturnValue(of(externeFachstelleStateResource)), getExterneFachstelle: jest.fn().mockReturnValue(of(externeFachstelleStateResource)),
}; };
await TestBed.configureTestingModule({ imports: [ExterneFachstelleListItemContainerComponent] }) await TestBed.configureTestingModule({ imports: [ExterneFachstelleListItemContainerComponent] })
.overrideComponent(ExterneFachstelleListItemContainerComponent, { .overrideComponent(ExterneFachstelleListItemContainerComponent, {
set: { set: {
providers: [{ provide: ZustaendigeStelleResourceService, useValue: zustaendigeStelleResourceService }], providers: [{ provide: ExterneFachstelleResourceService, useValue: externeFachstelleResourceService }],
}, },
}) })
.compileComponents(); .compileComponents();
...@@ -40,27 +40,10 @@ describe('ExterneFachstelleListItemContainerComponent', () => { ...@@ -40,27 +40,10 @@ describe('ExterneFachstelleListItemContainerComponent', () => {
}); });
describe('ngOnInit', () => { describe('ngOnInit', () => {
it('should call getOrganisationsEinheit', () => { it('should call externeFachstelleResourceService getExterneFachstelle Resource', () => {
const getOrganisationsEinheitSpy = jest.spyOn(component, 'getExterneFachstelle');
component.ngOnInit(); component.ngOnInit();
expect(getOrganisationsEinheitSpy).toHaveBeenCalled; expect(externeFachstelleResourceService.getExterneFachstelle).toHaveBeenCalled();
});
}); });
describe('getExterneFachstelle', () => {
it('should call zustaendigeStelleResourceService getLinked Resource', () => {
component.ngOnInit();
expect(zustaendigeStelleResourceService.getLinkedResource).toHaveBeenCalled();
});
it('should get externeFachstelle', fakeAsync(() => {
component.ngOnInit();
tick();
expect(component.externeFachstelleStateResource).toBe(externeFachstelleStateResource);
}));
}); });
}); });
import { ExterneFachstelleResourceService } from '@alfa-client/externe-fachstelle-shared';
import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared';
import { UiModule } from '@alfa-client/ui'; import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared';
import { ExterneFachstelleResource, ZustaendigeStelleResourceService } from '@alfa-client/zustaendige-stelle-shared'; import { CommonModule } from '@angular/common';
import { Component, inject, Input, OnInit } from '@angular/core'; import { Component, inject, Input, OnInit } from '@angular/core';
import { ResourceUri } from '@ngxp/rest'; import { ResourceUri } from '@ngxp/rest';
import { isNil } from 'lodash-es'; import { Observable, of } from 'rxjs';
import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-item/externe-fachstelle-list-item.component'; import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-item/externe-fachstelle-list-item.component';
@Component({ @Component({
selector: 'alfa-externe-fachstelle-list-item-container', selector: 'alfa-externe-fachstelle-list-item-container',
standalone: true, standalone: true,
imports: [ExterneFachstelleListItemComponent, UiModule], imports: [CommonModule, ExterneFachstelleListItemComponent],
providers: [ZustaendigeStelleResourceService], providers: [ExterneFachstelleResourceService],
templateUrl: './externe-fachstelle-list-item-container.component.html', templateUrl: './externe-fachstelle-list-item-container.component.html',
styleUrl: './externe-fachstelle-list-item-container.component.scss', styleUrl: './externe-fachstelle-list-item-container.component.scss',
}) })
export class ExterneFachstelleListItemContainerComponent implements OnInit { export class ExterneFachstelleListItemContainerComponent implements OnInit {
private zustaendigeStelleResourceService: ZustaendigeStelleResourceService = inject(ZustaendigeStelleResourceService); private externeFachstelleResourceService: ExterneFachstelleResourceService = inject(ExterneFachstelleResourceService);
@Input() zustaendigeStelleResourceUri: ResourceUri; @Input() externeFachstelleResourceUri: ResourceUri;
externeFachstelleStateResource: StateResource<ExterneFachstelleResource> = createEmptyStateResource(); externeFachstelleStateResource$: Observable<StateResource<ExterneFachstelleResource>> =
of(createEmptyStateResource<ExterneFachstelleResource>());
ngOnInit() { ngOnInit() {
this.getExterneFachstelle(); this.externeFachstelleStateResource$ = this.externeFachstelleResourceService.getExterneFachstelle(
this.externeFachstelleResourceUri,
);
} }
getExterneFachstelle() {
this.zustaendigeStelleResourceService
.getLinkedResource<ExterneFachstelleResource>(this.zustaendigeStelleResourceUri)
.subscribe((stateResource) => {
this.externeFachstelleStateResource = stateResource;
});
}
protected readonly isNaN = isNaN;
protected readonly isNil = isNil;
} }
<ozgcloud-spinner [stateResource]="externeFachstelleStateResource">
@if (externeFachstelleStateResource.resource; as resource) {
<div class="border border-grayborder bg-background-100 p-4 shadow shadow-grayborder"> <div class="border border-grayborder bg-background-100 p-4 shadow shadow-grayborder">
<div class="flex flex-1 gap-6"> <div class="flex flex-1 gap-6">
<div class="flex flex-1 gap-3"> <div class="flex flex-1 gap-3">
<ods-external-unit-icon /> <ods-external-unit-icon />
<div class="flex flex-1 flex-col text-base"> <div class="flex flex-1 flex-col text-base">
<p class="text-primary">Externe Fachstelle</p> <p class="text-primary">Externe Fachstelle</p>
<p class="text-text font-bold">{{ externeFachstelle.name }}</p> <p class="text-text font-bold">{{ resource.name }}</p>
</div> </div>
</div> </div>
<div class="flex-1"> <div class="flex-1">
<div class="block">{{ externeFachstelle.anschrift }}</div> <div class="block">{{ resource.anschrift }}</div>
<div class="block">Email: {{ externeFachstelle.email }}</div> <div class="block">Email: {{ resource.email }}</div>
</div> </div>
</div> </div>
<ng-content /> <ng-content />
</div> </div>
}
</ozgcloud-spinner>
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createStateResource, StateResource } from '@alfa-client/tech-shared';
import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared';
import { toResource } from 'libs/tech-shared/test/resource'; import { toResource } from 'libs/tech-shared/test/resource';
import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle'; import { createExterneFachstelle } from 'libs/zustaendige-stelle-shared/test/externe-fachstelle';
...@@ -10,6 +11,7 @@ describe('ExterneFachstelleListItemComponent', () => { ...@@ -10,6 +11,7 @@ describe('ExterneFachstelleListItemComponent', () => {
let fixture: ComponentFixture<ExterneFachstelleListItemComponent>; let fixture: ComponentFixture<ExterneFachstelleListItemComponent>;
const externeFachstelle: ExterneFachstelleResource = toResource(createExterneFachstelle()); const externeFachstelle: ExterneFachstelleResource = toResource(createExterneFachstelle());
const externeFachstelleState: StateResource<ExterneFachstelleResource> = createStateResource(externeFachstelle);
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
...@@ -18,7 +20,7 @@ describe('ExterneFachstelleListItemComponent', () => { ...@@ -18,7 +20,7 @@ describe('ExterneFachstelleListItemComponent', () => {
fixture = TestBed.createComponent(ExterneFachstelleListItemComponent); fixture = TestBed.createComponent(ExterneFachstelleListItemComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
component.externeFachstelle = externeFachstelle; component.externeFachstelleStateResource = externeFachstelleState;
fixture.detectChanges(); fixture.detectChanges();
}); });
......
import { StateResource } from '@alfa-client/tech-shared';
import { UiModule } from '@alfa-client/ui';
import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared'; import { ExterneFachstelleResource } from '@alfa-client/zustaendige-stelle-shared';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system'; import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system';
...@@ -5,10 +7,10 @@ import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@o ...@@ -5,10 +7,10 @@ import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@o
@Component({ @Component({
selector: 'alfa-externe-fachstelle-list-item', selector: 'alfa-externe-fachstelle-list-item',
standalone: true, standalone: true,
imports: [PublicAdministrationIconComponent, ExternalUnitIconComponent], imports: [PublicAdministrationIconComponent, ExternalUnitIconComponent, UiModule],
templateUrl: './externe-fachstelle-list-item.component.html', templateUrl: './externe-fachstelle-list-item.component.html',
styleUrl: './externe-fachstelle-list-item.component.scss', styleUrl: './externe-fachstelle-list-item.component.scss',
}) })
export class ExterneFachstelleListItemComponent { export class ExterneFachstelleListItemComponent {
@Input() externeFachstelle: ExterneFachstelleResource; @Input() externeFachstelleStateResource: StateResource<ExterneFachstelleResource>;
} }
/*
* Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den
* Ministerpräsidenten des Landes Schleswig-Holstein
* Staatskanzlei
* Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
*
* Lizenziert unter der EUPL, Version 1.2 oder - sobald
* diese von der Europäischen Kommission genehmigt wurden -
* Folgeversionen der EUPL ("Lizenz");
* Sie dürfen dieses Werk ausschließlich gemäß
* dieser Lizenz nutzen.
* Eine Kopie der Lizenz finden Sie hier:
*
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* Sofern nicht durch anwendbare Rechtsvorschriften
* gefordert oder in schriftlicher Form vereinbart, wird
* die unter der Lizenz verbreitete Software "so wie sie
* ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
* ausdrücklich oder stillschweigend - verbreitet.
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import 'jest-preset-angular/setup-jest'; import 'jest-preset-angular/setup-jest';
......
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lib",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lib",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment