Skip to content

Commit 0e827fa

Browse files
committed
Address review: fix renderAppComponent option name, add configureFusion test
- docs/advanced.md: the 'choose a rendering API' table row for renderAppComponent still said configureApp, but that imperative helper's own option was never renamed -- it's still configure. - testApp.test.tsx: add coverage for the configureFusion fixture, asserting a memory history pushed onto ahead of framework initialization is observable from a rendered component, proving configureFusion ran before the framework finished resolving.
1 parent defae88 commit 0e827fa

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/react/app/src/__tests__/testApp.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { describe, expect } from 'vitest';
33
import { enableContextMock } from '@equinor/fusion-framework-module-context/mock';
44
import type { ContextItem } from '@equinor/fusion-framework-module-context';
55
import { useCurrentContext } from '@equinor/fusion-framework-react-app/context';
6+
import { useFramework } from '@equinor/fusion-framework-react';
7+
import { createHistory, enableNavigation } from '@equinor/fusion-framework-module-navigation';
8+
import type { NavigationModule } from '@equinor/fusion-framework-module-navigation';
69

710
import { testApp } from '@equinor/fusion-framework-vitest-plugin-react-app/test';
811

@@ -44,4 +47,30 @@ describe('testApp', () => {
4447
await expect.element(screen.getByText(projectA.title as string)).toBeVisible();
4548
});
4649
});
50+
51+
describe('with a configured parent framework', () => {
52+
const NavigationLocation = () => {
53+
const { navigation } = useFramework<[NavigationModule]>().modules;
54+
return <p>{navigation.history.location.pathname}</p>;
55+
};
56+
57+
// pushed on the history instance itself, before it's handed to the framework configurator,
58+
// so a passing assertion also proves `configureFusion` ran ahead of framework initialization
59+
const history = createHistory('memory');
60+
history.push('/configured-by-configure-fusion');
61+
62+
const test = testApp.extend(
63+
'configureFusion',
64+
{ injected: true },
65+
() => (configurator) =>
66+
enableNavigation(configurator, { configure: (config) => config.setHistory(history) }),
67+
);
68+
69+
test('resolves the fusion instance with the configured navigation history', async ({
70+
render,
71+
}) => {
72+
const screen = await render(<NavigationLocation />);
73+
await expect.element(screen.getByText('/configured-by-configure-fusion')).toBeVisible();
74+
});
75+
});
4776
});

packages/vitest-plugin/react-app/docs/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ and the general `test.extend`/`test.override` mechanics Fusion builds on.
1515
| `test` from `/test` | The app's manifest, config, and module configurator should resolve automatically |
1616
| `render` from `/test` | A standard `describe` or `it` block needs the automatically resolved app scope |
1717
| `renderAppHook` | A hook needs an app scope with explicitly supplied options |
18-
| `renderAppComponent` | A component needs explicit `env`, `configureApp`, or parent `fusion` options |
18+
| `renderAppComponent` | A component needs explicit `env`, `configure`, or parent `fusion` options |
1919
| `testApp` | A reusable fixture should not depend on Vite's automatic app-file resolution |
2020

2121
All Fusion rendering APIs initialize modules asynchronously and must be awaited. The lower

0 commit comments

Comments
 (0)