Skip to content

Commit

Permalink
Refactor app loading configuration and mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Oct 15, 2024
1 parent 72edbb2 commit 96edbd0
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 103 deletions.
14 changes: 7 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@
"@equinor/eds-core-react": "^0.36.0",
"@equinor/eds-icons": "^0.17.0",
"@equinor/eds-tokens": "^0.9.0",
"@equinor/fusion-framework": "^7.2.7",
"@equinor/fusion-framework": "^7.2.8",
"@equinor/fusion-framework-app": "^9.1.10",
"@equinor/fusion-framework-module-ag-grid": "^32.2.0",
"@equinor/fusion-framework-module-app": "^6.0.0",
"@equinor/fusion-framework-module-context": "^5.0.12",
"@equinor/fusion-framework-module-feature-flag": "^1.1.9",
"@equinor/fusion-framework-module-http": "^6.1.0",
"@equinor/fusion-framework-module-http": "^6.2.0",
"@equinor/fusion-framework-module-navigation": "^4.0.7",
"@equinor/fusion-framework-module-service-discovery": "^8.0.0",
"@equinor/fusion-framework-module-services": "^4.1.4",
"@equinor/fusion-framework-module-signalr": "^4.0.0",
"@equinor/fusion-framework-module-service-discovery": "^8.0.1",
"@equinor/fusion-framework-module-services": "^4.1.5",
"@equinor/fusion-framework-module-signalr": "^4.0.1",
"@equinor/fusion-framework-react": "^7.3.0",
"@equinor/fusion-framework-react-app": "^5.2.10",
"@equinor/fusion-framework-react-components-bookmark": "0.5.0",
"@equinor/fusion-framework-react-components-bookmark": "0.5.2",
"@equinor/fusion-framework-react-components-people-provider": "^1.4.9",
"@equinor/fusion-framework-react-module-signalr": "^3.0.15",
"@equinor/fusion-framework-react-module-signalr": "^3.0.16",
"@equinor/fusion-observable": "^8.4.1",
"@equinor/fusion-react-context-selector": "^0.6.6",
"@equinor/fusion-react-person": "^0.9.2",
Expand Down
13 changes: 5 additions & 8 deletions client/packages/core/src/app/hooks/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { vi } from 'vitest';

import { AppConfig, AppManifest, AppModuleProvider } from '@equinor/fusion-framework-module-app';
import { AppConfig, AppManifest, AppModuleProvider, ConfigEnvironment } from '@equinor/fusion-framework-module-app';
import { BehaviorSubject } from 'rxjs';

const config: AppConfig<AppConfigMock> = {
const config = {
environment: {
env: 'test',
},
};
type AppConfigMock = {
env: string;
};
} as AppConfig<ConfigEnvironment & { env: string }>;

export const getAppConfigMock = vi.fn();
export const getAppManifestMock = vi.fn();
Expand All @@ -21,9 +18,9 @@ export const appProvider = new AppModuleProvider({
client: {
[Symbol.dispose]: vi.fn(),

getAppConfig: <A = AppConfigMock>() => {
getAppConfig: <TEnv>() => {
getAppConfigMock();
return new BehaviorSubject<AppConfig<A>>(config as AppConfig<A>);
return new BehaviorSubject(config as AppConfig<ConfigEnvironment & TEnv>);
},
getAppManifest: ({ appKey }) => {
getAppManifestMock();
Expand Down
8 changes: 7 additions & 1 deletion client/packages/core/src/app/hooks/use-app-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ let legacyAppScript = {};

vi.mock('./use-legacy-app-loader', async () => {
return {
useLegacyAppLoader: () => useMemo(() => legacyAppScript, []),
useLegacyAppLoader: () =>
useMemo(
() => ({
legacyAppScript,
}),
[]
),
};
});

Expand Down
15 changes: 14 additions & 1 deletion client/packages/core/src/app/hooks/use-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { createAppElement } from '../utils/app-element';
import { appRender } from '../render';
import { getLegacyClientConfig, getFusionLegacyEnvIdentifier } from '../utils';

import { AppConfig } from '@equinor/fusion-framework-app';
import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
import { Client } from '@portal/types';

export const useAppLoader = (appKey: string) => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error | undefined>();
Expand Down Expand Up @@ -55,7 +59,16 @@ export const useAppLoader = (appKey: string) => {
client: getLegacyClientConfig(),
},
},
},
} as AppConfig<
ConfigEnvironment & {
appKey: string;
env: string;
loadingText: string;
endpoints: {
client: Client;
};
}
>,
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion client/packages/core/src/app/render/app-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Fusion } from '@equinor/fusion-framework-react';

export type RenderConfig = {
fusion: Fusion<[AppModule]>;
env: AppEnv<unknown, unknown>;
env: AppEnv;
};

export const appRender = (args: { script?: AppScriptModule; element: HTMLDivElement; config: RenderConfig }) => {
Expand Down
100 changes: 15 additions & 85 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,6 @@
rxjs "^7.8.1"
uuid "^10.0.0"

"@equinor/fusion-framework-module-http@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-http/-/fusion-framework-module-http-6.1.0.tgz#7381468650df868ff2cd68b954671f0aba09a3d4"
integrity sha512-YFqVeOVImIc6N07+hsxJPB2q3QbgOZPkY6NK01jvRkqYhF2cJqaY2RH65sFJDE8TiYp6uMksXpF81FdpKPDh5Q==
dependencies:
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-module-msal" "^3.1.5"
rxjs "^7.8.1"

"@equinor/fusion-framework-module-http@^6.2.0":
version "6.2.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-http/-/fusion-framework-module-http-6.2.0.tgz#8bace19a3cc7f500068e1e36694d4032a46bcb67"
Expand All @@ -597,17 +588,6 @@
dependencies:
"@remix-run/router" "^1.8.0"

"@equinor/fusion-framework-module-service-discovery@^8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-service-discovery/-/fusion-framework-module-service-discovery-8.0.0.tgz#de9f3ab9bfad9d9f3d4001468f363ca0abd4b2b9"
integrity sha512-UsLCEGNKwp/VXmO/1Yyib43Ax4UkrmffxcJWqkwJIuCMdtJlukqFj1HEPqUlHpe/HVtuoxwFO3TnHNny05sVSw==
dependencies:
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-module-http" "^6.1.0"
"@equinor/fusion-query" "^5.1.3"
rxjs "^7.8.1"
zod "^3.23.8"

"@equinor/fusion-framework-module-service-discovery@^8.0.1":
version "8.0.1"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-service-discovery/-/fusion-framework-module-service-discovery-8.0.1.tgz#d3630f01e0f78cb774b3f21e42ce91b0a3aeb773"
Expand All @@ -619,24 +599,17 @@
rxjs "^7.8.1"
zod "^3.23.8"

"@equinor/fusion-framework-module-services@^4.1.4":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-services/-/fusion-framework-module-services-4.1.4.tgz#0a1a218138f55ad0817f0f1c0db0d951e7046d66"
integrity sha512-jpWnGx85VcTR9ZRf4K/4tHFhypJzngEDtAtDo4uD7O2pfz4WdzCEGKfwkYpagHXWvvkoYoMlYpwvLA6UnV8bUw==
dependencies:
odata-query "^7.0.4"

"@equinor/fusion-framework-module-services@^4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-services/-/fusion-framework-module-services-4.1.5.tgz#d2bbbd975459f02aeff807097eb2db0e2defcec1"
integrity sha512-ZbMZZLwDTjn+g5jleIrpLRjlevXu3x03Jboy2wicF9QJk8ChYkYYmoqZcp9bva36kvXSglWxMKNcAndpzHeubg==
dependencies:
odata-query "^7.0.4"

"@equinor/fusion-framework-module-signalr@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-signalr/-/fusion-framework-module-signalr-4.0.0.tgz#9110223813ad39e56254e539f9e200d94595899f"
integrity sha512-bX0N0l+su9mgVpFxLaHHDXwKGZ42xRTzJ6YL0yQlsAIdOBNcZYpN13hnCJpQWHSIWMDm5NQJuc2GtmL9dy89Ag==
"@equinor/fusion-framework-module-signalr@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-signalr/-/fusion-framework-module-signalr-4.0.1.tgz#cf6bd0de415914cb3a27f422f6a3325598acb931"
integrity sha512-5dp4fFthhj+7sRvMpJc6CFtz5BwsTe6o9HR4/bHfBz6BTsqsSRPv2c4A3CrG+Vfpps2yXTrX3hPJ5pE/JFPYnA==
dependencies:
"@microsoft/signalr" "^7.0.10"
rxjs "^7.8.1"
Expand All @@ -662,13 +635,13 @@
"@equinor/fusion-framework-react-module" "^3.1.6"
"@equinor/fusion-framework-react-module-http" "^8.0.0"

"@equinor/[email protected].0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-components-bookmark/-/fusion-framework-react-components-bookmark-0.5.0.tgz#95dc7b31019842dc885b9808106fb57d67c9ba34"
integrity sha512-KYnC2v7/p+VG2rohVaPMJoXM8U3vVFRoKF8AAzr1msGTSFjJteHr3BfaJmn77bS0dDnMHCmiw1mCKs7CpUdsmg==
"@equinor/[email protected].2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-components-bookmark/-/fusion-framework-react-components-bookmark-0.5.2.tgz#22351be1a5b59979bb0ca6c0b55e610714c14d96"
integrity sha512-jqkk7nLk+ul0mhbda3ULrtCSW3FDtGve36O79+LTnuVEk1KActNWSs74LsGiQnJvxmpEhGMeO9Jn0gNSKMJT6w==
dependencies:
"@equinor/fusion-framework-react" "^7.2.2"
"@equinor/fusion-framework-react-module-bookmark" "^2.1.16"
"@equinor/fusion-framework-react" "^7.3.0"
"@equinor/fusion-framework-react-module-bookmark" "^2.1.18"

"@equinor/fusion-framework-react-components-people-provider@^1.4.9":
version "1.4.9"
Expand All @@ -682,18 +655,6 @@
"@equinor/fusion-query" "^5.1.3"
rxjs "^7.8.1"

"@equinor/fusion-framework-react-module-bookmark@^2.1.16":
version "2.1.16"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-bookmark/-/fusion-framework-react-module-bookmark-2.1.16.tgz#b519b3fc41b911a330a9583ea5f006b71e655338"
integrity sha512-gZaNlLwN5aAv7WGNoHUhhUZUDXM3pBAfP0yE5U5Xh2i6ZpvbkziwlXos5G2YZ+xZVMnIUQ6ZOq+g0K+n1xfDPg==
dependencies:
"@equinor/fusion-framework-module-bookmark" "^1.2.12"
"@equinor/fusion-framework-module-context" "^5.0.12"
"@equinor/fusion-framework-react" "^7.2.2"
"@equinor/fusion-framework-react-module" "^3.1.6"
"@equinor/fusion-observable" "^8.4.1"
"@equinor/fusion-query" "^5.1.3"

"@equinor/fusion-framework-react-module-bookmark@^2.1.18":
version "2.1.18"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-bookmark/-/fusion-framework-react-module-bookmark-2.1.18.tgz#a930275e99d5221d7d7f86d17e64bbf9b0d4f803"
Expand All @@ -706,22 +667,17 @@
"@equinor/fusion-observable" "^8.4.1"
"@equinor/fusion-query" "^5.1.3"

"@equinor/fusion-framework-react-module-http@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-http/-/fusion-framework-react-module-http-7.0.0.tgz#82a4eb93574b7f1ceef2e5aa6e1259628f565279"
integrity sha512-/anG6wKXwnSPHrswnXGLfZyy4QW3rVQYDXdPheClkVoIoLLrKkxnReYXLCpMR7YviVnUxehbBuNP3CHlKoO41g==

"@equinor/fusion-framework-react-module-http@^8.0.0":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-http/-/fusion-framework-react-module-http-8.0.0.tgz#24aa95a6f997cb13f6b504985a438b2ec2c7041a"
integrity sha512-7B6luEmVGPdG11f9vW5rCz4RFUdc+NOjXNpJykG7bLGIkP6oUs80uOhm5mm+NqTClTf42CQaptjOroHEBAav2A==

"@equinor/fusion-framework-react-module-signalr@^3.0.15":
version "3.0.15"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-signalr/-/fusion-framework-react-module-signalr-3.0.15.tgz#adbdc7a88598b00599359e6854686f49e7a9eece"
integrity sha512-GTAQH5wVt8l7Uz4F8ncAtbie+F1PFHHMFpIz6g1YinzMmo5WKs8GN5YIQcgeTWyorD/VgSf3n0WSEzDctURZRA==
"@equinor/fusion-framework-react-module-signalr@^3.0.16":
version "3.0.16"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-module-signalr/-/fusion-framework-react-module-signalr-3.0.16.tgz#ffb970ffb0a2a05b8313f676b10a80ec49cfac44"
integrity sha512-HTVQccvvPhRVgDlawENt6r4t77xQHhVmbvp5hkHAxJZqXimUA0qzGUes6r2+f2iBKXfdww1GzSuQzBQGdoiT2A==
dependencies:
"@equinor/fusion-framework-module-signalr" "^4.0.0"
"@equinor/fusion-framework-module-signalr" "^4.0.1"

"@equinor/fusion-framework-react-module@^3.1.6":
version "3.1.6"
Expand All @@ -730,18 +686,6 @@
dependencies:
"@equinor/fusion-framework-module" "^4.3.5"

"@equinor/fusion-framework-react@^7.2.2":
version "7.2.2"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react/-/fusion-framework-react-7.2.2.tgz#093e20c6dd5020565ddb85d720d8601bccf6689a"
integrity sha512-F+Jo489ZV7sTQFmK5Xn+2mFqdvbxc6aFEmXXnOdDWBvwHAVtQqUu1BJoF4x2WWnAtXLWm9eCYIbwX3k+RGgIyg==
dependencies:
"@equinor/fusion-framework" "^7.2.7"
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-react-module" "^3.1.6"
"@equinor/fusion-framework-react-module-http" "^7.0.0"
"@equinor/fusion-observable" "^8.4.1"
rxjs "^7.8.1"

"@equinor/fusion-framework-react@^7.3.0":
version "7.3.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react/-/fusion-framework-react-7.3.0.tgz#4d4f9d387ebe197051b7d1643014f71236c77074"
Expand All @@ -754,20 +698,6 @@
"@equinor/fusion-observable" "^8.4.1"
rxjs "^7.8.1"

"@equinor/fusion-framework@^7.2.7":
version "7.2.7"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework/-/fusion-framework-7.2.7.tgz#8ac261f7f4af8ad433883a074139cab13469fd19"
integrity sha512-IOOB/hm/OhCXI1Ms7cZxJEklloE11g+JCZsMFwZlwz8HVAT4nKvqB+r907TXWGCFU1rF4tRrIFQC+iz7AFBFxA==
dependencies:
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-module-context" "^5.0.12"
"@equinor/fusion-framework-module-event" "^4.2.4"
"@equinor/fusion-framework-module-http" "^6.1.0"
"@equinor/fusion-framework-module-msal" "^3.1.5"
"@equinor/fusion-framework-module-service-discovery" "^8.0.0"
"@equinor/fusion-framework-module-services" "^4.1.4"
rxjs "^7.8.1"

"@equinor/fusion-framework@^7.2.8":
version "7.2.8"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework/-/fusion-framework-7.2.8.tgz#3ed261c393810d42682f8824e0426df4f734b545"
Expand Down

0 comments on commit 96edbd0

Please sign in to comment.