Skip to content

Commit 20bdec9

Browse files
committed
fix: fusion lint
1 parent 5647ec2 commit 20bdec9

26 files changed

Lines changed: 149 additions & 58 deletions

packages/dev-portal/src/configure.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { enableAgGrid } from '@equinor/fusion-framework-module-ag-grid';
1818
import { enableTelemetry } from '@equinor/fusion-framework-module-telemetry';
1919
import {
2020
enableContextNavigation,
21-
enableLegacyAppNavigationFix,
21+
legacyAppNavigationFix,
2222
} from '@equinor/fusion-framework-plugin-context-navigation';
2323
import {
2424
buildContextUrlForStrategy,
@@ -177,7 +177,7 @@ export const configure = async (config: FrameworkConfigurator) => {
177177

178178
config.onInitialized<[AppModule, NavigationModule]>((modules) => {
179179
// Reset legacy app routers on context navigation for apps with navigation <v7.
180-
enableLegacyAppNavigationFix({ event: modules.event });
180+
legacyAppNavigationFix({ event: modules.event });
181181

182182
// Expose framework modules globally for development debugging and inspection.
183183
// @ts-expect-error — `window` is not typed with `Fusion`

packages/plugins/context-navigation/src/configurator.ts renamed to packages/plugins/context-navigation/src/ContextNavigationConfigurator.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import type { ContextNavigationConfig, ContextNavigationNavigatedDetail } from '
22
import type { ContextNavigationAdapterInput } from './adapters/types';
33
import type { ReconcilerSourceFactory } from './sources/types';
44

5-
import { createPathAdapter } from './adapters/path-adapter';
6-
import { createQueryAdapter } from './adapters/query-adapter';
5+
import { createPathAdapter } from './adapters/create-path-adapter';
6+
import { createQueryAdapter } from './adapters/create-query-adapter';
77
import { createCustomAdapter } from './adapters/custom-adapter/create-custom-adapter';
8-
import { createResolveContextFromUrl } from './utils/resolve-context-from-url';
9-
import { createAppFirstSource } from './sources/app-first-source';
8+
import { resolveContextFromUrl } from './utils/resolve-context-from-url';
9+
import { appFirstSource } from './sources/app-first-source';
1010

1111
/**
1212
* Resolves the default origin used for URL construction.
@@ -160,8 +160,8 @@ export class ContextNavigationConfigurator {
160160
* @param factory - The source factory to use for the reconciler.
161161
* @returns The configurator instance for chaining.
162162
* @see ReconcilerSourceFactory
163-
* @see createAppFirstSource
164-
* @see createContextFirstSource
163+
* @see appFirstSource
164+
* @see contextFirstSource
165165
*/
166166
setSourceFactory(factory: ReconcilerSourceFactory): this {
167167
this.#config.sourceFactory = factory;
@@ -191,9 +191,9 @@ export class ContextNavigationConfigurator {
191191
nullContextUrl: this.#config.nullContextUrl,
192192
onTransition: this.#config.onTransition,
193193
navigationOptions: this.#config.navigationOptions ?? { replace: true },
194-
sourceFactory: this.#config.sourceFactory ?? createAppFirstSource(),
194+
sourceFactory: this.#config.sourceFactory ?? appFirstSource(),
195195
resolveInitialContext:
196-
this.#config.resolveInitialContext ?? createResolveContextFromUrl(adapters, origin),
196+
this.#config.resolveInitialContext ?? resolveContextFromUrl(adapters, origin),
197197
adapters,
198198
};
199199
}

packages/plugins/context-navigation/src/__tests__/active-app-navigation-events.test.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { describe, expect, it } from 'vitest';
33

44
import type { AppModulesInstance } from '@equinor/fusion-framework-module-app';
55
import type { ContextModule } from '@equinor/fusion-framework-module-context';
6-
import type { ContextNavigationPluginArgs } from '../plugin';
6+
import type { ContextNavigationPluginArgs } from '../create-context-navigation-plugin';
77

8-
import { activeAppNavigationEvents$ } from '../operators/active-app-navigation-events';
8+
import { activeAppNavigationEvents } from '../operators/active-app-navigation-events';
99

1010
describe('activeAppNavigationEvents$', () => {
1111
it('emits when app, instance, and navigation state are all present', () => {
12+
// Test double — only the context property is accessed by the operator under test
1213
const appModules = { context: {} } as unknown as AppModulesInstance<[ContextModule]>;
1314
const navigationState$ = new Subject<unknown>();
1415

@@ -18,13 +19,15 @@ describe('activeAppNavigationEvents$', () => {
1819
manifest$: new BehaviorSubject(null),
1920
});
2021

22+
// Test double — only current$ is read by the operator under test
2123
const app = { current$: currentApp$ } as unknown as ContextNavigationPluginArgs['app'];
24+
// Test double — only state$ is read by the operator under test
2225
const navigation = {
2326
state$: navigationState$,
2427
} as unknown as ContextNavigationPluginArgs['navigation'];
2528

2629
const emissions: unknown[] = [];
27-
const sub = activeAppNavigationEvents$(app, navigation).subscribe((val) => emissions.push(val));
30+
const sub = activeAppNavigationEvents(app, navigation).subscribe((val) => emissions.push(val));
2831

2932
navigationState$.next({});
3033

@@ -38,13 +41,15 @@ describe('activeAppNavigationEvents$', () => {
3841
const navigationState$ = new Subject<unknown>();
3942
const currentApp$ = new BehaviorSubject(null);
4043

44+
// Test double — only current$ is read by the operator under test
4145
const app = { current$: currentApp$ } as unknown as ContextNavigationPluginArgs['app'];
46+
// Test double — only state$ is read by the operator under test
4247
const navigation = {
4348
state$: navigationState$,
4449
} as unknown as ContextNavigationPluginArgs['navigation'];
4550

4651
const emissions: unknown[] = [];
47-
const sub = activeAppNavigationEvents$(app, navigation).subscribe((val) => emissions.push(val));
52+
const sub = activeAppNavigationEvents(app, navigation).subscribe((val) => emissions.push(val));
4853

4954
navigationState$.next({});
5055

@@ -60,13 +65,15 @@ describe('activeAppNavigationEvents$', () => {
6065
manifest$: new BehaviorSubject(null),
6166
});
6267

68+
// Test double — only current$ is read by the operator under test
6369
const app = { current$: currentApp$ } as unknown as ContextNavigationPluginArgs['app'];
70+
// Test double — only state$ is read by the operator under test
6471
const navigation = {
6572
state$: navigationState$,
6673
} as unknown as ContextNavigationPluginArgs['navigation'];
6774

6875
const emissions: unknown[] = [];
69-
const sub = activeAppNavigationEvents$(app, navigation).subscribe((val) => emissions.push(val));
76+
const sub = activeAppNavigationEvents(app, navigation).subscribe((val) => emissions.push(val));
7077

7178
navigationState$.next({});
7279

@@ -75,6 +82,7 @@ describe('activeAppNavigationEvents$', () => {
7582
});
7683

7784
it('re-emits on each navigation state change', () => {
85+
// Test double — only the context property is accessed by the operator under test
7886
const appModules = { context: {} } as unknown as AppModulesInstance<[ContextModule]>;
7987
const navigationState$ = new Subject<unknown>();
8088

@@ -84,13 +92,15 @@ describe('activeAppNavigationEvents$', () => {
8492
manifest$: new BehaviorSubject(null),
8593
});
8694

95+
// Test double — only current$ is read by the operator under test
8796
const app = { current$: currentApp$ } as unknown as ContextNavigationPluginArgs['app'];
97+
// Test double — only state$ is read by the operator under test
8898
const navigation = {
8999
state$: navigationState$,
90100
} as unknown as ContextNavigationPluginArgs['navigation'];
91101

92102
const emissions: unknown[] = [];
93-
const sub = activeAppNavigationEvents$(app, navigation).subscribe((val) => emissions.push(val));
103+
const sub = activeAppNavigationEvents(app, navigation).subscribe((val) => emissions.push(val));
94104

95105
navigationState$.next({});
96106
navigationState$.next({});
@@ -101,9 +111,11 @@ describe('activeAppNavigationEvents$', () => {
101111
});
102112

103113
it('switches to new app when current app changes', () => {
114+
// Test double — only the context property is accessed by the operator under test
104115
const appModulesA = { context: { name: 'A' } } as unknown as AppModulesInstance<
105116
[ContextModule]
106117
>;
118+
// Test double — only the context property is accessed by the operator under test
107119
const appModulesB = { context: { name: 'B' } } as unknown as AppModulesInstance<
108120
[ContextModule]
109121
>;
@@ -115,13 +127,15 @@ describe('activeAppNavigationEvents$', () => {
115127
manifest$: new BehaviorSubject(null),
116128
});
117129

130+
// Test double — only current$ is read by the operator under test
118131
const app = { current$: currentApp$ } as unknown as ContextNavigationPluginArgs['app'];
132+
// Test double — only state$ is read by the operator under test
119133
const navigation = {
120134
state$: navigationState$,
121135
} as unknown as ContextNavigationPluginArgs['navigation'];
122136

123137
const emissions: Array<{ appKey: string }> = [];
124-
const sub = activeAppNavigationEvents$(app, navigation).subscribe((val) => emissions.push(val));
138+
const sub = activeAppNavigationEvents(app, navigation).subscribe((val) => emissions.push(val));
125139

126140
navigationState$.next({});
127141
expect(emissions[0]?.appKey).toBe('app-a');

packages/plugins/context-navigation/src/__tests__/apply-navigation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import type { ContextNavigationAdapter } from '../adapters/types';
1313

1414
function makeContext(id: string): ContextItem {
15+
// Test double — only id and title are read by the code under test
1516
return { id, title: `Context ${id}` } as unknown as ContextItem;
1617
}
1718

@@ -20,6 +21,7 @@ function makeAdapter(overrides: Partial<ContextNavigationAdapter> = {}): Context
2021
id: 'test-adapter',
2122
canHandle: () => true,
2223
encode: ({ context, currentURL }) => {
24+
// Guard — adapter cannot encode without a context item
2325
if (!context) return null;
2426
return new URL(`/apps/my-app/${context.id}${currentURL.search}`, currentURL.origin);
2527
},
@@ -32,6 +34,7 @@ function makeAdapter(overrides: Partial<ContextNavigationAdapter> = {}): Context
3234
}
3335

3436
function makeDeps(overrides: Partial<ApplyNavigationDeps> = {}): ApplyNavigationDeps {
37+
// Test doubles — only the methods exercised by applyNavigation are provided
3538
return {
3639
event: {
3740
dispatchEvent: vi.fn(async () => ({ canceled: false })),
@@ -55,6 +58,7 @@ function makeDeps(overrides: Partial<ApplyNavigationDeps> = {}): ApplyNavigation
5558

5659
describe('applyNavigation', () => {
5760
const currentURL = new URL('/apps/my-app', 'https://example.com');
61+
// Test double — only the context property is accessed by the code under test
5862
const appModules = { context: {} } as unknown as AppModulesInstance<[ContextModule]>;
5963
let deps: ApplyNavigationDeps;
6064

@@ -121,6 +125,7 @@ describe('applyNavigation', () => {
121125
});
122126

123127
it('dispatches canceled skip when navigate event is canceled', async () => {
128+
// Test double — simulates dispatch returning canceled=true only for the navigate event
124129
deps = makeDeps({
125130
event: {
126131
dispatchEvent: vi.fn(async (name) => ({
@@ -147,6 +152,7 @@ describe('applyNavigation', () => {
147152
});
148153

149154
it('logs and does not throw when dispatch rejects', async () => {
155+
// Test double — simulates dispatch throwing to verify the .catch() path
150156
deps = makeDeps({
151157
event: {
152158
dispatchEvent: vi.fn(async () => {

packages/plugins/context-navigation/src/__tests__/enable.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
2-
import type { ContextNavigationBuilder } from '../enable';
2+
import type { ContextNavigationBuilder } from '../enable-context-navigation';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

55
const builderInstances: MockContextNavigationConfigurator[] = [];
@@ -16,15 +16,24 @@ const createConfigSpy = vi.fn(() => ({
1616
resolveInitialContext: vi.fn(async () => undefined),
1717
}));
1818

19+
/** Mock configurator that captures calls for assertion in tests. */
1920
class MockContextNavigationConfigurator {
21+
/**
22+
* Records that debug mode was configured; returns `this` for chaining.
23+
*
24+
* @param _enabled - Whether debug mode should be enabled.
25+
* @returns The configurator instance for chaining.
26+
*/
2027
setDebug(_enabled: boolean): this {
2128
return this;
2229
}
2330

31+
/** Delegates to the shared spy so tests can assert how config was created. */
2432
createConfig() {
2533
return createConfigSpy();
2634
}
2735

36+
/** Registers this instance in the outer `builderInstances` array for test inspection. */
2837
constructor() {
2938
builderInstances.push(this);
3039
}
@@ -53,8 +62,9 @@ describe('enableContextNavigation', () => {
5362
const registerPlugin = vi.fn();
5463
const addConfig = vi.fn();
5564

56-
const { enableContextNavigation } = await import('../enable');
65+
const { enableContextNavigation } = await import('../enable-context-navigation');
5766

67+
// Test double — only registerPlugin and addConfig are called by enableContextNavigation
5868
enableContextNavigation({
5969
registerPlugin,
6070
addConfig,
@@ -78,8 +88,9 @@ describe('enableContextNavigation', () => {
7888
event: { id: 'event' },
7989
};
8090

81-
const { enableContextNavigation } = await import('../enable');
91+
const { enableContextNavigation } = await import('../enable-context-navigation');
8292

93+
// Test double — only registerPlugin is called by enableContextNavigation
8394
enableContextNavigation(
8495
{
8596
registerPlugin,

0 commit comments

Comments
 (0)