Skip to content

Commit 1ef0709

Browse files
feat: default org (#25)
* Default auth config * Add processing for a default organization. * fix tests * fix tests * Default idp provider --------- Co-authored-by: Grzegorz Krajniak <[email protected]>
1 parent f75f9ed commit 1ef0709

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

projects/wc/src/app/components/welcome/welcome.component.spec.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
import { WelcomeComponent } from './welcome.component';
22
import { signal } from '@angular/core';
33
import { TestBed } from '@angular/core/testing';
4-
import { I18nService } from '@openmfp/portal-ui-lib';
4+
import { I18nService, LuigiCoreService } from '@openmfp/portal-ui-lib';
55

66
describe('WelcomeComponent', () => {
77
let component: WelcomeComponent;
8-
let i18nService: jest.Mocked<I18nService>;
8+
let i18nServiceMock: jest.Mocked<I18nService>;
9+
let luigiCoreServiceMock: jest.Mocked<LuigiCoreService>;
10+
const header = {
11+
title: 'Welcome',
12+
logo: 'logo.png',
13+
favicon: 'favicon.ico',
14+
};
915

1016
beforeEach(async () => {
11-
i18nService = {
17+
i18nServiceMock = {
1218
fetchTranslationFile: jest.fn(),
1319
translationTable: { hello: 'world' },
1420
} as unknown as jest.Mocked<I18nService>;
1521

22+
luigiCoreServiceMock = {
23+
config: {
24+
settings: {
25+
header,
26+
},
27+
},
28+
} as unknown as jest.Mocked<LuigiCoreService>;
29+
1630
await TestBed.configureTestingModule({
1731
imports: [WelcomeComponent],
18-
providers: [{ provide: I18nService, useValue: i18nService }],
32+
providers: [
33+
{ provide: I18nService, useValue: i18nServiceMock },
34+
{ provide: LuigiCoreService, useValue: luigiCoreServiceMock },
35+
],
1936
}).compileComponents();
2037

2138
const fixture = TestBed.createComponent(WelcomeComponent);
@@ -30,14 +47,15 @@ describe('WelcomeComponent', () => {
3047
component.context = signal({
3148
key: 'value',
3249
}) as any;
33-
i18nService.fetchTranslationFile.mockResolvedValue({ hello: 'world' });
50+
i18nServiceMock.fetchTranslationFile.mockResolvedValue({ hello: 'world' });
3451

3552
await component.ngOnInit();
3653

37-
expect(i18nService.fetchTranslationFile).toHaveBeenCalledWith('en');
54+
expect(i18nServiceMock.fetchTranslationFile).toHaveBeenCalledWith('en');
3855
expect(component.enhancedContext()).toEqual({
3956
key: 'value',
4057
translationTable: { hello: 'world' },
4158
});
59+
expect(component.header()).toEqual(header);
4260
});
4361
});

projects/wc/src/app/components/welcome/welcome.component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { OrganizationManagementComponent } from '../organization-management/organization-management.component';
22
import { Component, OnInit, inject, input, signal } from '@angular/core';
33
import { LuigiClient } from '@luigi-project/client/luigi-element';
4-
import { I18nService } from '@openmfp/portal-ui-lib';
4+
import { I18nService, LuigiCoreService } from '@openmfp/portal-ui-lib';
55
import { ResourceNodeContext } from '@platform-mesh/portal-ui-lib/services';
66

7+
interface Header {
8+
title?: string;
9+
logo?: string;
10+
favicon?: string;
11+
}
12+
713
@Component({
814
selector: 'app-welcome',
915
template: `
1016
<div class="center-container">
11-
<div class="message-box">Welcome to the Portal!</div>
17+
<img src="{{ header()?.logo }}" width="100" alt="" />
18+
<div class="message-box">Welcome to the {{ header()?.title }}!</div>
1219
@if (enhancedContext()) {
1320
<organization-management
1421
[context]="enhancedContext()"
@@ -41,13 +48,18 @@ import { ResourceNodeContext } from '@platform-mesh/portal-ui-lib/services';
4148
})
4249
export class WelcomeComponent implements OnInit {
4350
private i18nService = inject(I18nService);
51+
private luigiCoreService = inject(LuigiCoreService);
4452

4553
context = input<ResourceNodeContext>();
4654
LuigiClient = input<LuigiClient>();
4755
enhancedContext = signal<ResourceNodeContext>(null);
4856

57+
header = signal<Header>({});
58+
4959
async ngOnInit() {
5060
await this.i18nService.fetchTranslationFile('en');
61+
const header = this.luigiCoreService.config.settings.header;
62+
this.header.set(header);
5163
this.enhancedContext.set({
5264
...this.context(),
5365
translationTable: this.i18nService.translationTable,

0 commit comments

Comments
 (0)