@equinor/fusion-framework 8.1.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -9
- package/CHANGELOG.md +0 -1961
- package/docs/testing-api.md +0 -25
- package/docs/testing-choosing-a-layer.md +0 -90
- package/docs/testing-design.md +0 -63
- package/docs/testing-extending.md +0 -102
- package/docs/testing.md +0 -178
- package/src/FrameworkConfigurator.ts +0 -273
- package/src/__tests__/FrameworkConfigurator.test.ts +0 -35
- package/src/__tests__/mock/application-module.test.ts +0 -87
- package/src/__tests__/mock/documented-usage.test.ts +0 -98
- package/src/__tests__/mock/mock-framework.test.ts +0 -278
- package/src/index.ts +0 -44
- package/src/init.ts +0 -61
- package/src/mock/FrameworkMockConfigurator.ts +0 -270
- package/src/mock/index.ts +0 -62
- package/src/mock/mock-framework.ts +0 -72
- package/src/types.ts +0 -82
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -36
- package/vitest.config.ts +0 -10
package/src/mock/index.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-configuration Fusion Framework instances for tests.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Lets an application initialize the real framework — real modules, real
|
|
6
|
-
* configuration pipeline, real lifecycle — while the boundaries that reach
|
|
7
|
-
* outside the process are substituted with deterministic fakes. No credentials,
|
|
8
|
-
* no network access and no configuration are required.
|
|
9
|
-
*
|
|
10
|
-
* This entry point holds **no mock logic**. Each module owns and exports its own
|
|
11
|
-
* test double from its `./mock` entry point; this entry point only composes the
|
|
12
|
-
* built-in set into a ready-to-use instance. An application module follows the
|
|
13
|
-
* same pattern and plugs in identically.
|
|
14
|
-
*
|
|
15
|
-
* This entry point is test-runner agnostic: it contains no dependency on Vitest
|
|
16
|
-
* or any other test framework, so the same helpers work under any runner.
|
|
17
|
-
*
|
|
18
|
-
* Fixture generators with realistic fake data (e.g. `createContextItems`) live
|
|
19
|
-
* on each module's own `/mock/fixtures` entry point instead of here, since they
|
|
20
|
-
* pull in an extra dependency ({@link https://fakerjs.dev/ | faker}) that
|
|
21
|
-
* plain configurator mocking doesn't need.
|
|
22
|
-
*
|
|
23
|
-
* @packageDocumentation
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export { mockFramework, type FrameworkMockConfigureFn } from './mock-framework.js';
|
|
27
|
-
export { FrameworkMockConfigurator } from './FrameworkMockConfigurator.js';
|
|
28
|
-
|
|
29
|
-
// Re-exported so a test can reach the built-in module mocks without importing
|
|
30
|
-
// each module's `./mock` entry point directly. The mocks are owned by their modules.
|
|
31
|
-
export {
|
|
32
|
-
enableMsalMock,
|
|
33
|
-
msalMockModule,
|
|
34
|
-
MsalMockConfigurator,
|
|
35
|
-
MsalMockClient,
|
|
36
|
-
createMsalMockClient,
|
|
37
|
-
createMockToken,
|
|
38
|
-
type AuthConfigMockFn,
|
|
39
|
-
type MsalMockUser,
|
|
40
|
-
type MockTokenClaims,
|
|
41
|
-
} from '@equinor/fusion-framework-module-msal/mock';
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
mockServiceDiscovery,
|
|
45
|
-
enableServiceDiscoveryMock,
|
|
46
|
-
serviceDiscoveryMockModule,
|
|
47
|
-
ServiceDiscoveryMockClient,
|
|
48
|
-
ServiceDiscoveryMockConfigurator,
|
|
49
|
-
createMockService,
|
|
50
|
-
defaultServiceDiscoveryMockServices,
|
|
51
|
-
type ServiceDiscoveryConfigMockFn,
|
|
52
|
-
type MockService,
|
|
53
|
-
type ServiceDiscoveryMockClientOptions,
|
|
54
|
-
} from '@equinor/fusion-framework-module-service-discovery/mock';
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
enableContextMock,
|
|
58
|
-
contextMockModule,
|
|
59
|
-
ContextMockConfigurator,
|
|
60
|
-
type ContextMockConfigFn,
|
|
61
|
-
type ContextResolverFn,
|
|
62
|
-
} from '@equinor/fusion-framework-module-context/mock';
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
2
|
-
|
|
3
|
-
import { init } from '../init.js';
|
|
4
|
-
import type { Fusion } from '../types.js';
|
|
5
|
-
|
|
6
|
-
import { FrameworkMockConfigurator } from './FrameworkMockConfigurator.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Configures a mocked framework before it is initialized.
|
|
10
|
-
*
|
|
11
|
-
* @typeParam TModules - Module descriptors beyond the built-in set.
|
|
12
|
-
* @param configurator - The configurator to configure.
|
|
13
|
-
*/
|
|
14
|
-
export type FrameworkMockConfigureFn<TModules extends Array<AnyModule> = []> = (
|
|
15
|
-
configurator: FrameworkMockConfigurator<TModules>,
|
|
16
|
-
) => void | Promise<void>;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Starts a Fusion framework instance that needs no credentials and no network.
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* The real framework is started: the real module set, the real configuration
|
|
23
|
-
* pipeline and the real lifecycle. Only the boundaries that would need
|
|
24
|
-
* credentials or network access are substituted, so a test exercises the wiring
|
|
25
|
-
* an application actually depends on rather than a reimplementation of it.
|
|
26
|
-
*
|
|
27
|
-
* The configurator passed to `configure` is a {@link FrameworkMockConfigurator},
|
|
28
|
-
* which *is* a `FrameworkConfigurator`. Every `enableX` helper therefore accepts
|
|
29
|
-
* it unchanged — including the ones an application team writes for their own
|
|
30
|
-
* modules.
|
|
31
|
-
*
|
|
32
|
-
* Spying on individual calls is left to the test runner. The framework makes the
|
|
33
|
-
* runtime substitutable; `vi.spyOn`, `bun:test` `spyOn` and `t.mock.method` all
|
|
34
|
-
* work against the resulting instance with no framework support.
|
|
35
|
-
*
|
|
36
|
-
* @typeParam TModules - Module descriptors beyond the built-in set. Supply this
|
|
37
|
-
* when a test registers application modules, so they are typed on the result.
|
|
38
|
-
* @template TModules - Module descriptors beyond the built-in set.
|
|
39
|
-
* @param configure - Callback that configures the framework before it starts.
|
|
40
|
-
* @returns The initialized framework instance.
|
|
41
|
-
*
|
|
42
|
-
* @example Zero configuration
|
|
43
|
-
* ```typescript
|
|
44
|
-
* const fusion = await mockFramework();
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Configure the built-in mocks
|
|
48
|
-
* ```typescript
|
|
49
|
-
* const fusion = await mockFramework((configurator) => {
|
|
50
|
-
* configurator.msal.setAccount({ name: 'Ada Lovelace' });
|
|
51
|
-
* configurator.serviceDiscovery.setBaseUri('http://localhost:6669');
|
|
52
|
-
* });
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @example Register an application module
|
|
56
|
-
* ```typescript
|
|
57
|
-
* const fusion = await mockFramework<[InvoiceModule]>((configurator) => {
|
|
58
|
-
* enableInvoicesMock(configurator, { total: 42 });
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* await fusion.modules.invoices.getInvoice('1');
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export async function mockFramework<TModules extends Array<AnyModule> = []>(
|
|
65
|
-
configure?: FrameworkMockConfigureFn<TModules>,
|
|
66
|
-
): Promise<Fusion<TModules>> {
|
|
67
|
-
const configurator = new FrameworkMockConfigurator<TModules>();
|
|
68
|
-
await configure?.(configurator);
|
|
69
|
-
return await init(configurator);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default mockFramework;
|
package/src/types.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { CombinedModules, ModulesInstance } from '@equinor/fusion-framework-module';
|
|
2
|
-
import type { AnyModule } from '@equinor/fusion-framework-module';
|
|
3
|
-
|
|
4
|
-
import type { ContextModule } from '@equinor/fusion-framework-module-context';
|
|
5
|
-
import type { EventModule } from '@equinor/fusion-framework-module-event';
|
|
6
|
-
import type { HttpModule } from '@equinor/fusion-framework-module-http';
|
|
7
|
-
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
8
|
-
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
9
|
-
import type { ServicesModule } from '@equinor/fusion-framework-module-services';
|
|
10
|
-
import type { TelemetryModule } from '@equinor/fusion-framework-module-telemetry';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Union of all built-in Fusion Framework module descriptors, optionally
|
|
14
|
-
* combined with additional custom modules.
|
|
15
|
-
*
|
|
16
|
-
* Use this type to describe the full set of modules the framework
|
|
17
|
-
* configurator will manage. The built-in set includes:
|
|
18
|
-
* - {@link ContextModule} — application/project context selection
|
|
19
|
-
* - {@link EventModule} — cross-module event bus
|
|
20
|
-
* - {@link HttpModule} — HTTP client factory
|
|
21
|
-
* - {@link MsalModule} — Microsoft Authentication Library integration
|
|
22
|
-
* - {@link ServicesModule} — typed service clients
|
|
23
|
-
* - {@link ServiceDiscoveryModule} — runtime service endpoint resolution
|
|
24
|
-
* - {@link TelemetryModule} — telemetry and logging
|
|
25
|
-
*
|
|
26
|
-
* @template TModules - Additional module descriptors to merge with the
|
|
27
|
-
* built-in modules. Defaults to `unknown` (no extra modules).
|
|
28
|
-
*/
|
|
29
|
-
export type FusionModules<TModules extends Array<AnyModule> | unknown = unknown> = CombinedModules<
|
|
30
|
-
TModules,
|
|
31
|
-
[
|
|
32
|
-
ContextModule,
|
|
33
|
-
EventModule,
|
|
34
|
-
HttpModule,
|
|
35
|
-
MsalModule,
|
|
36
|
-
ServicesModule,
|
|
37
|
-
ServiceDiscoveryModule,
|
|
38
|
-
TelemetryModule,
|
|
39
|
-
]
|
|
40
|
-
>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Resolved instance map for all Fusion Framework modules.
|
|
44
|
-
*
|
|
45
|
-
* This is the runtime counterpart of {@link FusionModules}: after the
|
|
46
|
-
* framework has been initialized with {@link init}, every module
|
|
47
|
-
* descriptor is replaced by its live instance (clients, providers,
|
|
48
|
-
* managers, etc.).
|
|
49
|
-
*
|
|
50
|
-
* @template TModules - Additional module descriptors whose instances
|
|
51
|
-
* should be included. Defaults to `unknown`.
|
|
52
|
-
*/
|
|
53
|
-
export type FusionModulesInstance<TModules extends Array<AnyModule> | unknown = unknown> =
|
|
54
|
-
ModulesInstance<FusionModules<TModules>>;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Root object returned by {@link init} after bootstrapping the framework.
|
|
58
|
-
*
|
|
59
|
-
* The `Fusion` object is also assigned to `window.Fusion` so that portal
|
|
60
|
-
* shells, micro-frontends, and widgets can access the running framework
|
|
61
|
-
* instance globally.
|
|
62
|
-
*
|
|
63
|
-
* @template TModules - Additional module descriptors beyond the built-in
|
|
64
|
-
* set. Defaults to `unknown`.
|
|
65
|
-
*/
|
|
66
|
-
export interface Fusion<TModules extends Array<AnyModule> | unknown = unknown> {
|
|
67
|
-
/** Map of all initialized module instances keyed by module name. */
|
|
68
|
-
modules: FusionModulesInstance<TModules>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Callback signature for rendering a Fusion application into a DOM element.
|
|
73
|
-
*
|
|
74
|
-
* Portal hosts call this function when mounting an application, passing the
|
|
75
|
-
* root element and a reference to the host's module instances so the
|
|
76
|
-
* application can share authentication, HTTP clients, and other services.
|
|
77
|
-
*
|
|
78
|
-
* @param el - The DOM element into which the application should render.
|
|
79
|
-
* @param args - Initialization arguments containing a reference to the
|
|
80
|
-
* host framework's module instances.
|
|
81
|
-
*/
|
|
82
|
-
export type FusionRenderFn = (el: HTMLElement, args: { ref: ModulesInstance<AnyModule[]> }) => void;
|
package/src/version.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist/esm",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"declarationDir": "./dist/types"
|
|
7
|
-
},
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "../modules/module"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "../modules/event"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "../modules/telemetry"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"path": "../modules/http"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "../modules/msal"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"path": "../modules/service-discovery"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"path": "../modules/services"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"path": "../modules/context"
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"include": ["src/**/*"],
|
|
35
|
-
"exclude": ["node_modules", "lib"]
|
|
36
|
-
}
|
package/vitest.config.ts
DELETED