Skip to content

Commit 039164f

Browse files
Version Packages (next)
1 parent 1fdd87f commit 039164f

7 files changed

Lines changed: 73 additions & 32 deletions

File tree

.changeset/pre.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"cookbook-app-react-people_fix-doc-link",
106106
"cookbook-app-react-router_openapi-mock-fixture",
107107
"cookbook-app-react-router_rename-configure-fixture",
108+
"cookbook-app-react-router_stop-reading-window-location",
108109
"cookbook-app-react_add-app-test",
109110
"dev-portal_migrate-browser-tests",
110111
"docs-restructure",
@@ -165,9 +166,12 @@
165166
"vitest-plugin-react-app_default-viewport",
166167
"vitest-plugin-react-app_define-project",
167168
"vitest-plugin-react-app_document-override",
169+
"vitest-plugin-react-app_exclude-dts-warmup",
168170
"vitest-plugin-react-app_initial-release",
169171
"vitest-plugin-react-app_migration-guide",
172+
"vitest-plugin-react-app_optional-feature-flag-mock",
170173
"vitest-plugin-react-app_rename-configure-fixtures",
174+
"vitest-plugin-react-app_revert-memory-history",
171175
"vitest-plugin-react-app_why-browser-mode"
172176
]
173177
}

cookbooks/app-react-router/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## 5.0.4-next.2
4+
5+
### Patch Changes
6+
7+
- 1fdd87f: Tests no longer read or seed `window.location`/`window.history`. Now that
8+
`resolveFusion` defaults navigation to in-memory history, real browser
9+
location never reflects the app's navigation state — assertions read
10+
`app.navigation.path.pathname` instead, and link `href` assertions match on
11+
path rather than full origin.
12+
313
## 5.0.4-next.1
414

515
### Patch Changes

cookbooks/app-react-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@equinor/fusion-framework-cookbook-app-react-router",
3-
"version": "5.0.4-next.1",
3+
"version": "5.0.4-next.2",
44
"description": "",
55
"private": true,
66
"type": "module",

cookbooks/app-react-router/src/components/Navigation.test.tsx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,35 @@ testWithRouter('navigating to a page updates the URL', async ({ render, app }) =
2424
await unmount();
2525
});
2626

27-
testWithRouter('the active link swaps when navigating to a different page', async ({ render, app }) => {
28-
const { getByText, unmount } = await render(<Navigation />);
29-
30-
// active state is only reflected as a styled-components color, not a DOM attribute
31-
const colorOf = (label: string) => getComputedStyle(getByText(label).element()).color;
32-
33-
// navigate via the router's own click handler first, so its internal location is
34-
// guaranteed to be in sync rather than relying on the initial location above
35-
await getByText('Home').click();
36-
await vi.waitFor(() => expect(app.navigation.path.pathname).toBe('/'));
37-
38-
// Users is never navigated to in this test, so its color is a stable "inactive" reference
39-
const inactiveColor = colorOf('Users');
40-
await vi.waitFor(() => {
41-
expect(colorOf('Home')).not.toBe(inactiveColor);
42-
expect(colorOf('Products')).toBe(inactiveColor);
43-
});
44-
45-
await getByText('Products').click();
46-
47-
// the URL changes synchronously on click, so styling lags at least one render behind it —
48-
// retry on the color itself rather than on the pathname, which would resolve too early
49-
await vi.waitFor(() => {
50-
expect(colorOf('Home')).toBe(inactiveColor);
51-
expect(colorOf('Products')).not.toBe(inactiveColor);
52-
});
53-
54-
await unmount();
55-
});
27+
testWithRouter(
28+
'the active link swaps when navigating to a different page',
29+
async ({ render, app }) => {
30+
const { getByText, unmount } = await render(<Navigation />);
31+
32+
// active state is only reflected as a styled-components color, not a DOM attribute
33+
const colorOf = (label: string) => getComputedStyle(getByText(label).element()).color;
34+
35+
// navigate via the router's own click handler first, so its internal location is
36+
// guaranteed to be in sync rather than relying on the initial location above
37+
await getByText('Home').click();
38+
await vi.waitFor(() => expect(app.navigation.path.pathname).toBe('/'));
39+
40+
// Users is never navigated to in this test, so its color is a stable "inactive" reference
41+
const inactiveColor = colorOf('Users');
42+
await vi.waitFor(() => {
43+
expect(colorOf('Home')).not.toBe(inactiveColor);
44+
expect(colorOf('Products')).toBe(inactiveColor);
45+
});
46+
47+
await getByText('Products').click();
48+
49+
// the URL changes synchronously on click, so styling lags at least one render behind it —
50+
// retry on the color itself rather than on the pathname, which would resolve too early
51+
await vi.waitFor(() => {
52+
expect(colorOf('Home')).toBe(inactiveColor);
53+
expect(colorOf('Products')).not.toBe(inactiveColor);
54+
});
55+
56+
await unmount();
57+
},
58+
);

cookbooks/app-react-router/src/components/product/ProductCard.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ testWithRouter(
1919
await expect.element(getByText(/ in stock/i)).toBeInTheDocument();
2020

2121
const link = getByRole('link', { name: /view details/i });
22-
await expect.element(link).toHaveAttribute('href', expect.stringContaining(`/products/${baseProduct.id}`));
22+
await expect
23+
.element(link)
24+
.toHaveAttribute('href', expect.stringContaining(`/products/${baseProduct.id}`));
2325

2426
await unmount();
2527
},

packages/vitest-plugin/react-app/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# @equinor/fusion-framework-vitest-plugin-react-app
22

3+
## 1.0.0-next.5
4+
5+
### Minor Changes
6+
7+
- 1fdd87f: `resolveFusion` (and both the `/test` fixtures and `testApp`) now enable the feature-flag
8+
mock by default, with no flags enabled, so `useFeature` needs no `localStorage` or URL
9+
seeding in tests.
10+
11+
`@equinor/fusion-framework-module-feature-flag` is an optional peer dependency: the mock is
12+
only wired up when the package is actually installed, so apps that don't use feature flags
13+
aren't forced to add it. Install it to get the default mock; call `enableFeatureFlagMock`
14+
again inside `configureFusion` to seed specific flags.
15+
16+
### Patch Changes
17+
18+
- 1fdd87f: Exclude `.d.ts` files from the default `server.warmup.clientFiles` and `optimizeDeps.entries`
19+
globs in `defineProject`. Previously, an app shipping a CJS-style declaration file (for example
20+
one using `export =`) failed the Vite warmup scan, since it was loaded as ESM.
21+
- 1fdd87f: Revert the mocked framework's default navigation history from browser history back to in-memory
22+
history. Browser history leaked URL/history state between tests; `configureFusion`/`enableNavigation`
23+
can still opt back into browser history for a test that specifically needs it.
24+
325
## 1.0.0-next.4
426

527
### Major Changes

packages/vitest-plugin/react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@equinor/fusion-framework-vitest-plugin-react-app",
3-
"version": "1.0.0-next.4",
3+
"version": "1.0.0-next.5",
44
"description": "Vite plugin resolving an application's manifest, config, and module-configurator as virtual modules for testing.",
55
"type": "module",
66
"exports": {

0 commit comments

Comments
 (0)