Skip to content

Commit 4e487c2

Browse files
committed
refactor(jobmonitor)!: virtualized DataTable split, SearchBar decomposition, context split, SWR tuning
Rework the Job Monitor stack end to end: - split the monolithic shared/DataTable.tsx into a DataTable/ module (DataTable, DataTableHeader, DataTableToolbar, SplitActionButton) virtualized with @tanstack/react-virtual instead of react-virtuoso; react-virtuoso is dropped from dependencies - extract a reusable shared/PieChart component (with stories and a11y legend tests) and a shared visuallyHidden helper - decompose the SearchBar: state moves into a useSearchBarReducer, URL/filter synchronisation into useFilterSync, and suggestion fetching into useSearchSuggestions; equations gain stable ids and the Operators.EGUALS typo becomes Operators.EQUALS - restructure the Job Monitor: column definitions move to jobColumns.tsx, per-application persistence to useJobMonitorPersistence, and shared state to a JobMonitorContext; jobDataService migrates to the services/fetcher client with SWR keys tuned to avoid refetch storms - finish the fetcher migration: hooks/utils.tsx loses the legacy tuple-based fetcher (now services/client with named options and abort support), hooks/metadata.tsx and the gubbins OwnerMonitor consume the new client, and the package root exports the explicit final API surface - jest config/setup updated for react-virtual (structured-clone ponyfill, layout mocks); e2e specs updated and a mobile viewport spec added; next.config gains a services alias for dev HMR and the app a test:headless script BREAKING CHANGE: the tuple-based fetcher export is gone from @dirac-grid/diracx-web-components/hooks; use the object-based fetcher from @dirac-grid/diracx-web-components/services instead. Operators.EGUALS is renamed Operators.EQUALS, and the DataTable API changed with the module split.
1 parent 8e25460 commit 4e487c2

60 files changed

Lines changed: 5019 additions & 2249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 29 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/diracx-web-components/jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ const config = {
1010
// The test environment that will be used for testing
1111
testEnvironment: "jest-environment-jsdom",
1212

13+
// Coverage is only collected when jest runs with --coverage
14+
// (see the test:coverage script). Stories, mocks and build output are
15+
// excluded; no thresholds are enforced yet.
16+
collectCoverageFrom: [
17+
"src/**/*.{ts,tsx}",
18+
"!src/**/*.d.ts",
19+
"!src/**/*.stories.{ts,tsx}",
20+
],
21+
coveragePathIgnorePatterns: ["/node_modules/", "/dist/", "/stories/"],
22+
1323
moduleNameMapper: {
1424
"^@axa-fr/react-oidc$": "<rootDir>/stories/mocks/react-oidc.mock.tsx",
1525
"^../../hooks/metadata$": "<rootDir>/stories/mocks/metadata.mock.tsx",

packages/diracx-web-components/jest.setup.ts

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import structuredClonePonyfill from "@ungap/structured-clone";
12
import "@testing-library/jest-dom";
23

3-
// Polyfill structuredClone for jsdom (used by @mui/x-charts)
4+
// Polyfill structuredClone for jsdom (used by @mui/x-charts).
5+
// jest-environment-jsdom does not expose Node's native structuredClone, and
6+
// Node's v8-serialize trick creates values from the wrong realm (instanceof
7+
// breaks). @ungap/structured-clone implements the structured-clone algorithm
8+
// in the current realm (unlike JSON round-tripping, it preserves Dates,
9+
// Maps, Sets, …).
410
if (typeof globalThis.structuredClone === "undefined") {
5-
globalThis.structuredClone = <T>(val: T): T =>
6-
JSON.parse(JSON.stringify(val));
11+
globalThis.structuredClone = ((val: unknown) =>
12+
structuredClonePonyfill(val)) as typeof globalThis.structuredClone;
713
}
814

915
// Polyfill PointerEvent for jsdom (used by @mui/x-internal-gestures)
@@ -20,4 +26,52 @@ if (typeof globalThis.PointerEvent === "undefined") {
2026
};
2127
}
2228

29+
// Mock layout measurements for @tanstack/react-virtual (jsdom has no layout engine).
30+
// Only override offsetHeight/offsetWidth — these are the properties the virtualizer
31+
// uses to determine container size. We do NOT override getBoundingClientRect globally
32+
// because MUI Popover relies on the native implementation.
33+
//
34+
// This is a global override for every test; if a future test needs real layout
35+
// measurements (e.g. to assert that an element is actually visible), call
36+
// restoreRealLayoutMeasurements() in a beforeEach hook.
37+
const originalOffsetHeight = Object.getOwnPropertyDescriptor(
38+
HTMLElement.prototype,
39+
"offsetHeight",
40+
);
41+
const originalOffsetWidth = Object.getOwnPropertyDescriptor(
42+
HTMLElement.prototype,
43+
"offsetWidth",
44+
);
45+
46+
Object.defineProperty(HTMLElement.prototype, "offsetHeight", {
47+
configurable: true,
48+
get() {
49+
return 600;
50+
},
51+
});
52+
Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
53+
configurable: true,
54+
get() {
55+
return 800;
56+
},
57+
});
58+
59+
// Exported so individual tests can opt out of the mocked layout values.
60+
export function restoreRealLayoutMeasurements() {
61+
if (originalOffsetHeight) {
62+
Object.defineProperty(
63+
HTMLElement.prototype,
64+
"offsetHeight",
65+
originalOffsetHeight,
66+
);
67+
}
68+
if (originalOffsetWidth) {
69+
Object.defineProperty(
70+
HTMLElement.prototype,
71+
"offsetWidth",
72+
originalOffsetWidth,
73+
);
74+
}
75+
}
76+
2377
jest.mock("@axa-fr/react-oidc");

packages/diracx-web-components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"@mui/x-charts": "^8.0.0",
3636
"@mui/x-date-pickers": "^8.0.0",
3737
"@tanstack/react-table": "^8.20.5",
38-
"dayjs": "^1.11.13",
39-
"react-virtuoso": "^4.12.3"
38+
"@tanstack/react-virtual": "^3.13.23",
39+
"dayjs": "^1.11.13"
4040
},
4141
"peerDependencies": {
4242
"@axa-fr/react-oidc": ">=7.24.0 <7.27.0",

0 commit comments

Comments
 (0)