Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ yarn-error.log
/libpeerconnection.log
testem.log
/typings
.yalc
yalc.lock

# System files
.DS_Store
Expand Down
10,342 changes: 6,102 additions & 4,240 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,36 @@
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"build:watch": "mkdirp dist && nodemon --ignore dist --ext js,yml,yaml,ts,html,css,scss,json,md --exec \"rimraf dist && npm run build && cd dist && yalc publish --push --sig\"",
"test": "ng test"
},
"prettier": "@openmfp/config-prettier",
"dependencies": {
"tslib": "^2.3.0"
},
"devDependencies": {
"@angular-builders/jest": "^19.0.0 || ^20.0.0",
"@angular-devkit/build-angular": "^19.2.15",
"@angular/build": "^19.2.15",
"@angular/cli": "^19.2.15",
"@angular/compiler-cli": "^19.2.14",
"@angular/localize": "^19.0.0 || ^20.0.0",
"@angular-builders/jest": "^20.0.0",
"@angular-devkit/build-angular": "^20.0.0",
"@angular-eslint/builder": "^20.2.0",
"@angular/cli": "^20.2.0",
"@angular/build": "^20.2.1",
"@angular/compiler-cli": "^20.2.1",
"@angular/localize": "^20.2.1",
"@briebug/jest-schematic": "^6.0.0",
"@openmfp/portal-ui-lib": "0.174.2",
"@types/jest": "^30.0.0",
"@types/jmespath": "0.15.2",
"@openmfp/portal-ui-lib": "^0.172.0",
"@ui5/webcomponents-ngx": "^0.4.8",
"@ui5/webcomponents-ngx": "^0.5.0",
"jest": "^29.7.0",
"jest-jasmine2": "29.7.0",
"jest-junit": "16.0.0",
"jest-mock-extended": "3.0.7",
"jmespath": "0.16.0",
"ng-packagr": "^19.2.0",
"ng-packagr": "^20.2.0",
"ts-jest": "29.3.2",
"typescript": "~5.5.2"
"typescript": "~5.8.0",
"rimraf": "6.0.1",
"mkdirp": "^3.0.1",
"nodemon": "3.1.10"
}
}
2 changes: 1 addition & 1 deletion projects/lib/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
coverageThreshold: {
global: {
branches: 67,
functions: 90,
functions: 95,
lines: 91,
statements: -16,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { TestBed } from '@angular/core/testing';
import { ApplicationInitStatus } from '@angular/core';
import { Router } from '@angular/router';
import { EnvConfigService } from '@openmfp/portal-ui-lib';
import { organizationInitializer } from './organization-initializer';

describe('organizationInitializer', () => {
let envMock: jest.Mocked<EnvConfigService>;
let routerMock: jest.Mocked<Router>;

beforeEach(() => {
envMock = {
getEnvConfig: jest.fn(),
} as unknown as jest.Mocked<EnvConfigService>;

routerMock = {
navigate: jest.fn(),
} as unknown as jest.Mocked<Router>;

TestBed.configureTestingModule({
providers: [
organizationInitializer(),
{ provide: EnvConfigService, useValue: envMock },
{ provide: Router, useValue: routerMock },
],
});
});

it('should call getEnvConfig and not navigate on success', async () => {
envMock.getEnvConfig.mockResolvedValueOnce(undefined as any);

await TestBed.inject(ApplicationInitStatus).donePromise;

expect(envMock.getEnvConfig).toHaveBeenCalledTimes(1);
expect(routerMock.navigate).not.toHaveBeenCalled();
});

it('should navigate to "welcome" when getEnvConfig throws', async () => {
envMock.getEnvConfig.mockRejectedValueOnce(new Error('fail'));

await TestBed.inject(ApplicationInitStatus).donePromise;

expect(envMock.getEnvConfig).toHaveBeenCalledTimes(1);
expect(routerMock.navigate).toHaveBeenCalledWith(['welcome']);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { inject, provideAppInitializer } from '@angular/core';
import { Router } from '@angular/router';
import { EnvConfigService } from '@openmfp/portal-ui-lib';

export const organizationInitializer = () => {
return provideAppInitializer(async () => {
const envService = inject(EnvConfigService)
const router = inject(Router)

try {
await envService.getEnvConfig()
} catch {
router.navigate(['welcome']);
}
});
};
6 changes: 6 additions & 0 deletions projects/lib/organization/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "./public-api.ts"
}
}
1 change: 1 addition & 0 deletions projects/lib/organization/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './initializers/organization-initializer';
2 changes: 1 addition & 1 deletion projects/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tslib": "^2.3.0"
},
"peerDependencies": {
"@openmfp/portal-ui-lib": "^0.172.0",
"@openmfp/portal-ui-lib": "0.174.2",
"@angular/common": "^19.0.0 || ^20.0.0",
"@angular/compiler": "^19.0.0 || ^20.0.0",
"@angular/core": "^19.0.0 || ^20.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
AuthService,
FieldDefinition,
LuigiCoreService,
LuigiNode,
PortalConfig,
Resource,
ResourceNodeContext,
ResourceService,
generateGraphQLFields,
} from '@openmfp/portal-ui-lib';
import { LuigiNode } from '@openmfp/portal-ui-lib/lib/models';
import '@ui5/webcomponents/dist/ComboBox.js';
import { Observable, of } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
Expand Down