@trackunit/react-core-contexts-test 1.12.65 → 1.14.0
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/index.cjs.js +1 -0
- package/index.cjs2.js +47 -1
- package/index.esm.js +1 -1
- package/index.esm2.js +48 -3
- package/package.json +3 -3
- package/src/TrackunitProvidersMockBuilder.d.ts +9 -1
- package/src/index.d.ts +1 -0
- package/src/mocks/mockGeolocationContext.d.ts +2 -0
- package/src/utils/mergeDeepVars.d.ts +9 -0
- package/src/utils/queryFor.d.ts +8 -0
package/index.cjs.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.TrackunitProvidersMockBuilder = index.TrackunitProvidersMockBuilder;
|
|
|
25
25
|
exports.doNothing = index.doNothing;
|
|
26
26
|
exports.flushPromises = index.flushPromises;
|
|
27
27
|
exports.flushPromisesInAct = index.flushPromisesInAct;
|
|
28
|
+
exports.mergeDeepVars = index.mergeDeepVars;
|
|
28
29
|
exports.mockAnalyticsContext = index.mockAnalyticsContext;
|
|
29
30
|
exports.mockAssetSortingContext = index.mockAssetSortingContext;
|
|
30
31
|
exports.mockCurrentUserContext = index.mockCurrentUserContext;
|
package/index.cjs2.js
CHANGED
|
@@ -13461,6 +13461,11 @@ const mockErrorHandlerContext = {
|
|
|
13461
13461
|
setTag: sharedUtils.doNothing,
|
|
13462
13462
|
};
|
|
13463
13463
|
|
|
13464
|
+
const mockGeolocationContext = {
|
|
13465
|
+
position: null,
|
|
13466
|
+
getPosition: () => Promise.resolve(null),
|
|
13467
|
+
};
|
|
13468
|
+
|
|
13464
13469
|
const mockModalDialogContext = {
|
|
13465
13470
|
openModal: doNothing,
|
|
13466
13471
|
closeModal: doNothing,
|
|
@@ -13774,6 +13779,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
13774
13779
|
this.selectedOemBrandingContext = mockOemBrandingContext;
|
|
13775
13780
|
this.selectedUserSubscriptionContext = mockUserSubscriptionContext;
|
|
13776
13781
|
this.selectedFilterBarValues = mockFilterBarContext;
|
|
13782
|
+
this.selectedGeolocationContext = mockGeolocationContext;
|
|
13777
13783
|
this.selectedExportDataContext = mockExportDataContextState;
|
|
13778
13784
|
}
|
|
13779
13785
|
/**
|
|
@@ -13951,6 +13957,16 @@ class TrackunitProvidersMockBuilder {
|
|
|
13951
13957
|
this.selectedFilterBarValues = { ...this.selectedFilterBarValues, ...filterBarValues };
|
|
13952
13958
|
return this;
|
|
13953
13959
|
}
|
|
13960
|
+
/**
|
|
13961
|
+
* Use this to pass in a different geolocation context.
|
|
13962
|
+
* Defaults to mockGeolocationContext.
|
|
13963
|
+
*
|
|
13964
|
+
* This context is used by the useGeolocation hook from lib "@trackunit/react-core-hooks"
|
|
13965
|
+
*/
|
|
13966
|
+
geolocation(geolocationContext) {
|
|
13967
|
+
this.selectedGeolocationContext = { ...mockGeolocationContext, ...geolocationContext };
|
|
13968
|
+
return this;
|
|
13969
|
+
}
|
|
13954
13970
|
/**
|
|
13955
13971
|
* Use this to pass in a differerent current user subscription.
|
|
13956
13972
|
* Defaults to mockUserSubscriptionContext.
|
|
@@ -14279,7 +14295,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
14279
14295
|
* @param testChildren - the child element being tested.
|
|
14280
14296
|
*/
|
|
14281
14297
|
getMockedCompositionRoot(testChildren) {
|
|
14282
|
-
return (jsxRuntime.jsx(reactCoreContextsApi.ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsxRuntime.jsx(reactCoreContextsApi.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreContextsApi.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreContextsApi.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreContextsApi.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreContextsApi.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreContextsApi.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreContextsApi.ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsxRuntime.jsx(reactCoreContextsApi.FilterBarProvider, { value: this.selectedFilterBarValues, children: jsxRuntime.jsx(reactCoreContextsApi.ExportDataContext.Provider, { value: this.selectedExportDataContext, children: jsxRuntime.jsx(reactCoreContextsApi.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { addTypename: false, mocks: this.selectedApolloMocks, children: jsxRuntime.jsx(reactCoreContextsApi.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreContextsApi.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsxRuntime.jsx(reactCoreContextsApi.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactCoreContextsApi.ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: jsxRuntime.jsx(reactCoreContextsApi.TimeRangeProvider, { value: this.selectedTimeRangeContext, children: jsxRuntime.jsx(reactCoreContextsApi.WidgetConfigProvider, { value: this.selectedWidgetConfigContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
14298
|
+
return (jsxRuntime.jsx(reactCoreContextsApi.ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsxRuntime.jsx(reactCoreContextsApi.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreContextsApi.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreContextsApi.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreContextsApi.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreContextsApi.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreContextsApi.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreContextsApi.ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsxRuntime.jsx(reactCoreContextsApi.FilterBarProvider, { value: this.selectedFilterBarValues, children: jsxRuntime.jsx(reactCoreContextsApi.ExportDataContext.Provider, { value: this.selectedExportDataContext, children: jsxRuntime.jsx(reactCoreContextsApi.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { addTypename: false, mocks: this.selectedApolloMocks, children: jsxRuntime.jsx(reactCoreContextsApi.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreContextsApi.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsxRuntime.jsx(reactCoreContextsApi.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactCoreContextsApi.ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: jsxRuntime.jsx(reactCoreContextsApi.TimeRangeProvider, { value: this.selectedTimeRangeContext, children: jsxRuntime.jsx(reactCoreContextsApi.WidgetConfigProvider, { value: this.selectedWidgetConfigContext, children: jsxRuntime.jsx(reactCoreContextsApi.GeolocationProvider, { value: this.selectedGeolocationContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
14283
14299
|
}
|
|
14284
14300
|
getMockedCompositionRootWithRouter(testChildren) {
|
|
14285
14301
|
const childrenWithRouter = (jsxRuntime.jsx(RouterContainer, { addTestRootContainer: true, rootRoute: this.selectedRootRoute, selectedRouterProps: this.selectedRouterProps, children: testChildren }));
|
|
@@ -14427,6 +14443,35 @@ const safeStringify = (obj) => {
|
|
|
14427
14443
|
});
|
|
14428
14444
|
};
|
|
14429
14445
|
|
|
14446
|
+
/**
|
|
14447
|
+
* Deep merge for GraphQL mock variables that preserves `undefined` values.
|
|
14448
|
+
*
|
|
14449
|
+
* Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
|
|
14450
|
+
* from the defaults and only overrides keys explicitly present in the source.
|
|
14451
|
+
* This is critical for Apollo MockedProvider's exact variable matching.
|
|
14452
|
+
*/
|
|
14453
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14454
|
+
const mergeDeepVars = (defaults, overrides) => {
|
|
14455
|
+
if (!overrides)
|
|
14456
|
+
return { ...defaults };
|
|
14457
|
+
const src = overrides;
|
|
14458
|
+
const result = { ...defaults };
|
|
14459
|
+
for (const key of Object.keys(src)) {
|
|
14460
|
+
const overrideVal = src[key];
|
|
14461
|
+
const defaultVal = result[key];
|
|
14462
|
+
const bothObjects = typeof overrideVal === "object" &&
|
|
14463
|
+
overrideVal !== null &&
|
|
14464
|
+
!Array.isArray(overrideVal) &&
|
|
14465
|
+
typeof defaultVal === "object" &&
|
|
14466
|
+
defaultVal !== null &&
|
|
14467
|
+
!Array.isArray(defaultVal);
|
|
14468
|
+
result[key] = bothObjects
|
|
14469
|
+
? mergeDeepVars(defaultVal, overrideVal)
|
|
14470
|
+
: overrideVal;
|
|
14471
|
+
}
|
|
14472
|
+
return result;
|
|
14473
|
+
};
|
|
14474
|
+
|
|
14430
14475
|
/**
|
|
14431
14476
|
*
|
|
14432
14477
|
* @param document Document that represents the specific GQL query / mutation schema.
|
|
@@ -14571,6 +14616,7 @@ exports.act = act;
|
|
|
14571
14616
|
exports.doNothing = doNothing;
|
|
14572
14617
|
exports.flushPromises = flushPromises;
|
|
14573
14618
|
exports.flushPromisesInAct = flushPromisesInAct;
|
|
14619
|
+
exports.mergeDeepVars = mergeDeepVars;
|
|
14574
14620
|
exports.mockAnalyticsContext = mockAnalyticsContext;
|
|
14575
14621
|
exports.mockAssetSortingContext = mockAssetSortingContext;
|
|
14576
14622
|
exports.mockCurrentUserContext = mockCurrentUserContext;
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { D as Debugger, T as TrackunitProvidersMockBuilder,
|
|
1
|
+
export { D as Debugger, T as TrackunitProvidersMockBuilder, n as doNothing, f as flushPromises, b as flushPromisesInAct, l as mergeDeepVars, m as mockAnalyticsContext, c as mockAssetSortingContext, d as mockCurrentUserContext, e as mockEnvironmentContext, g as mockFilterBarContext, h as mockNavigationContext, i as mockOemBrandingContext, j as mockToastContext, k as mockUserSubscriptionContext, q as queryFor, o as queryForHook, t as trackunitProviders, u as useDebugger, v as validateIrisApp } from './index.esm2.js';
|
|
2
2
|
import '@trackunit/iris-app-runtime-core-api';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
package/index.esm2.js
CHANGED
|
@@ -5,7 +5,7 @@ import React__default, { createContext, useContext, Children, createElement, isV
|
|
|
5
5
|
import * as DeprecatedReactTestUtils from 'react-dom/test-utils';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
7
|
import * as ReactDOMClient from 'react-dom/client';
|
|
8
|
-
import { ErrorHandlingContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, ConfirmationDialogProvider, FilterBarProvider, ExportDataContext, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider, EnvironmentContextProvider, ModalDialogContextProvider, TimeRangeProvider, WidgetConfigProvider } from '@trackunit/react-core-contexts-api';
|
|
8
|
+
import { ErrorHandlingContextProvider, CurrentUserProvider, AnalyticsContext, UserSubscriptionProvider, OemBrandingContextProvider, TokenProvider, ToastProvider, ConfirmationDialogProvider, FilterBarProvider, ExportDataContext, AssetSortingProvider, NavigationContextProvider, CurrentUserPreferenceProvider, EnvironmentContextProvider, ModalDialogContextProvider, TimeRangeProvider, WidgetConfigProvider, GeolocationProvider } from '@trackunit/react-core-contexts-api';
|
|
9
9
|
import { omit } from 'es-toolkit';
|
|
10
10
|
import { ApolloLink } from '@apollo/client';
|
|
11
11
|
import { loadDevMessages, loadErrorMessages } from '@apollo/client/dev';
|
|
@@ -13439,6 +13439,11 @@ const mockErrorHandlerContext = {
|
|
|
13439
13439
|
setTag: doNothing$1,
|
|
13440
13440
|
};
|
|
13441
13441
|
|
|
13442
|
+
const mockGeolocationContext = {
|
|
13443
|
+
position: null,
|
|
13444
|
+
getPosition: () => Promise.resolve(null),
|
|
13445
|
+
};
|
|
13446
|
+
|
|
13442
13447
|
const mockModalDialogContext = {
|
|
13443
13448
|
openModal: doNothing,
|
|
13444
13449
|
closeModal: doNothing,
|
|
@@ -13752,6 +13757,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
13752
13757
|
this.selectedOemBrandingContext = mockOemBrandingContext;
|
|
13753
13758
|
this.selectedUserSubscriptionContext = mockUserSubscriptionContext;
|
|
13754
13759
|
this.selectedFilterBarValues = mockFilterBarContext;
|
|
13760
|
+
this.selectedGeolocationContext = mockGeolocationContext;
|
|
13755
13761
|
this.selectedExportDataContext = mockExportDataContextState;
|
|
13756
13762
|
}
|
|
13757
13763
|
/**
|
|
@@ -13929,6 +13935,16 @@ class TrackunitProvidersMockBuilder {
|
|
|
13929
13935
|
this.selectedFilterBarValues = { ...this.selectedFilterBarValues, ...filterBarValues };
|
|
13930
13936
|
return this;
|
|
13931
13937
|
}
|
|
13938
|
+
/**
|
|
13939
|
+
* Use this to pass in a different geolocation context.
|
|
13940
|
+
* Defaults to mockGeolocationContext.
|
|
13941
|
+
*
|
|
13942
|
+
* This context is used by the useGeolocation hook from lib "@trackunit/react-core-hooks"
|
|
13943
|
+
*/
|
|
13944
|
+
geolocation(geolocationContext) {
|
|
13945
|
+
this.selectedGeolocationContext = { ...mockGeolocationContext, ...geolocationContext };
|
|
13946
|
+
return this;
|
|
13947
|
+
}
|
|
13932
13948
|
/**
|
|
13933
13949
|
* Use this to pass in a differerent current user subscription.
|
|
13934
13950
|
* Defaults to mockUserSubscriptionContext.
|
|
@@ -14257,7 +14273,7 @@ class TrackunitProvidersMockBuilder {
|
|
|
14257
14273
|
* @param testChildren - the child element being tested.
|
|
14258
14274
|
*/
|
|
14259
14275
|
getMockedCompositionRoot(testChildren) {
|
|
14260
|
-
return (jsx(ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsx(CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsx(AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsx(UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsx(OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsx(TokenProvider, { value: this.selectedTokenContext, children: jsx(ToastProvider, { value: this.selectedToastContext, children: jsx(ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsx(FilterBarProvider, { value: this.selectedFilterBarValues, children: jsx(ExportDataContext.Provider, { value: this.selectedExportDataContext, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { addTypename: false, mocks: this.selectedApolloMocks, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: jsx(TimeRangeProvider, { value: this.selectedTimeRangeContext, children: jsx(WidgetConfigProvider, { value: this.selectedWidgetConfigContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
14276
|
+
return (jsx(ErrorHandlingContextProvider, { value: this.selectedErrorHandler, children: jsx(CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsx(AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsx(UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsx(OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsx(TokenProvider, { value: this.selectedTokenContext, children: jsx(ToastProvider, { value: this.selectedToastContext, children: jsx(ConfirmationDialogProvider, { value: this.selectedConfirmationDialogContext, children: jsx(FilterBarProvider, { value: this.selectedFilterBarValues, children: jsx(ExportDataContext.Provider, { value: this.selectedExportDataContext, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { addTypename: false, mocks: this.selectedApolloMocks, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(ModalDialogContextProvider, { value: this.selectedModalDialogContext, children: jsx(TimeRangeProvider, { value: this.selectedTimeRangeContext, children: jsx(WidgetConfigProvider, { value: this.selectedWidgetConfigContext, children: jsx(GeolocationProvider, { value: this.selectedGeolocationContext, children: testChildren }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
14261
14277
|
}
|
|
14262
14278
|
getMockedCompositionRootWithRouter(testChildren) {
|
|
14263
14279
|
const childrenWithRouter = (jsx(RouterContainer, { addTestRootContainer: true, rootRoute: this.selectedRootRoute, selectedRouterProps: this.selectedRouterProps, children: testChildren }));
|
|
@@ -14405,6 +14421,35 @@ const safeStringify = (obj) => {
|
|
|
14405
14421
|
});
|
|
14406
14422
|
};
|
|
14407
14423
|
|
|
14424
|
+
/**
|
|
14425
|
+
* Deep merge for GraphQL mock variables that preserves `undefined` values.
|
|
14426
|
+
*
|
|
14427
|
+
* Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
|
|
14428
|
+
* from the defaults and only overrides keys explicitly present in the source.
|
|
14429
|
+
* This is critical for Apollo MockedProvider's exact variable matching.
|
|
14430
|
+
*/
|
|
14431
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14432
|
+
const mergeDeepVars = (defaults, overrides) => {
|
|
14433
|
+
if (!overrides)
|
|
14434
|
+
return { ...defaults };
|
|
14435
|
+
const src = overrides;
|
|
14436
|
+
const result = { ...defaults };
|
|
14437
|
+
for (const key of Object.keys(src)) {
|
|
14438
|
+
const overrideVal = src[key];
|
|
14439
|
+
const defaultVal = result[key];
|
|
14440
|
+
const bothObjects = typeof overrideVal === "object" &&
|
|
14441
|
+
overrideVal !== null &&
|
|
14442
|
+
!Array.isArray(overrideVal) &&
|
|
14443
|
+
typeof defaultVal === "object" &&
|
|
14444
|
+
defaultVal !== null &&
|
|
14445
|
+
!Array.isArray(defaultVal);
|
|
14446
|
+
result[key] = bothObjects
|
|
14447
|
+
? mergeDeepVars(defaultVal, overrideVal)
|
|
14448
|
+
: overrideVal;
|
|
14449
|
+
}
|
|
14450
|
+
return result;
|
|
14451
|
+
};
|
|
14452
|
+
|
|
14408
14453
|
/**
|
|
14409
14454
|
*
|
|
14410
14455
|
* @param document Document that represents the specific GQL query / mutation schema.
|
|
@@ -14543,4 +14588,4 @@ const validateIrisApp = async (irisApp) => {
|
|
|
14543
14588
|
return null;
|
|
14544
14589
|
};
|
|
14545
14590
|
|
|
14546
|
-
export { Debugger as D, TrackunitProvidersMockBuilder as T, act as a, flushPromisesInAct as b, mockAssetSortingContext as c, mockCurrentUserContext as d, mockEnvironmentContext as e, flushPromises as f, mockFilterBarContext as g, mockNavigationContext as h, mockOemBrandingContext as i, mockToastContext as j, mockUserSubscriptionContext as k,
|
|
14591
|
+
export { Debugger as D, TrackunitProvidersMockBuilder as T, act as a, flushPromisesInAct as b, mockAssetSortingContext as c, mockCurrentUserContext as d, mockEnvironmentContext as e, flushPromises as f, mockFilterBarContext as g, mockNavigationContext as h, mockOemBrandingContext as i, mockToastContext as j, mockUserSubscriptionContext as k, mergeDeepVars as l, mockAnalyticsContext as m, doNothing as n, queryForHook as o, queryFor as q, renderHook as r, trackunitProviders as t, useDebugger as u, validateIrisApp as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts-test",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@trackunit/shared-utils": "1.13.75",
|
|
14
14
|
"graphql": "^16.10.0",
|
|
15
15
|
"@tanstack/router-core": "1.114.29",
|
|
16
|
-
"@trackunit/iris-app-runtime-core-api": "1.
|
|
17
|
-
"@trackunit/react-core-contexts-api": "1.
|
|
16
|
+
"@trackunit/iris-app-runtime-core-api": "1.13.0",
|
|
17
|
+
"@trackunit/react-core-contexts-api": "1.14.0",
|
|
18
18
|
"es-toolkit": "^1.39.10"
|
|
19
19
|
},
|
|
20
20
|
"module": "./index.esm.js",
|
|
@@ -2,7 +2,7 @@ import { MockedResponse } from "@apollo/client/testing";
|
|
|
2
2
|
import { AnyRoute, RegisteredRouter } from "@tanstack/react-router";
|
|
3
3
|
import { RenderResult } from "@testing-library/react";
|
|
4
4
|
import { AnalyticsRuntimeApiSync, AssetSortingState, ConfirmationDialogRuntimeApi, CurrentUserPreferenceState, CurrentUserState, EnvironmentState, ErrorHandlingContextValue, FilterBarContext, ModalDialogRuntimeApi, NavigationRuntimeApi, OemBrandingRuntimeApi, TimeRangeContext, TokenContext, UserSubscription, WidgetConfigContext } from "@trackunit/iris-app-runtime-core-api";
|
|
5
|
-
import { ExportDataContextState, ToastContextValue } from "@trackunit/react-core-contexts-api";
|
|
5
|
+
import { ExportDataContextState, GeolocationContextValue, ToastContextValue } from "@trackunit/react-core-contexts-api";
|
|
6
6
|
import { ReactElement, ReactNode } from "react";
|
|
7
7
|
import { MemoryRouterProps } from "./utils/routingUtils";
|
|
8
8
|
/**
|
|
@@ -34,6 +34,7 @@ export declare class TrackunitProvidersMockBuilder<TRouterTree extends AnyRoute>
|
|
|
34
34
|
protected selectedOemBrandingContext: OemBrandingRuntimeApi;
|
|
35
35
|
protected selectedUserSubscriptionContext: UserSubscription;
|
|
36
36
|
protected selectedFilterBarValues: FilterBarContext;
|
|
37
|
+
protected selectedGeolocationContext: GeolocationContextValue;
|
|
37
38
|
protected selectedExportDataContext: ExportDataContextState;
|
|
38
39
|
/**
|
|
39
40
|
* Use this Analytics Context.
|
|
@@ -182,6 +183,13 @@ export declare class TrackunitProvidersMockBuilder<TRouterTree extends AnyRoute>
|
|
|
182
183
|
* @returns { TrackunitProvidersMockBuilder } - The builder.
|
|
183
184
|
*/
|
|
184
185
|
filterBarValues(filterBarValues: Partial<FilterBarContext>): this;
|
|
186
|
+
/**
|
|
187
|
+
* Use this to pass in a different geolocation context.
|
|
188
|
+
* Defaults to mockGeolocationContext.
|
|
189
|
+
*
|
|
190
|
+
* This context is used by the useGeolocation hook from lib "@trackunit/react-core-hooks"
|
|
191
|
+
*/
|
|
192
|
+
geolocation(geolocationContext: Partial<GeolocationContextValue>): this;
|
|
185
193
|
/**
|
|
186
194
|
* Use this to pass in a differerent current user subscription.
|
|
187
195
|
* Defaults to mockUserSubscriptionContext.
|
package/src/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./mocks/mockToastContext";
|
|
|
9
9
|
export * from "./mocks/mockUserSubscriptionContext";
|
|
10
10
|
export * from "./TrackunitProvidersMockBuilder";
|
|
11
11
|
export * from "./useDebugger";
|
|
12
|
+
export * from "./utils/mergeDeepVars";
|
|
12
13
|
export * from "./utils/doNothing";
|
|
13
14
|
export * from "./utils/queryFor";
|
|
14
15
|
export * from "./utils/validateIrisApp";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeepPartialNullable } from "./queryFor";
|
|
2
|
+
/**
|
|
3
|
+
* Deep merge for GraphQL mock variables that preserves `undefined` values.
|
|
4
|
+
*
|
|
5
|
+
* Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
|
|
6
|
+
* from the defaults and only overrides keys explicitly present in the source.
|
|
7
|
+
* This is critical for Apollo MockedProvider's exact variable matching.
|
|
8
|
+
*/
|
|
9
|
+
export declare const mergeDeepVars: <TDefaults extends Record<string, any>>(defaults: TDefaults, overrides?: DeepPartialNullable<NoInfer<TDefaults>> | Partial<NoInfer<TDefaults>>) => TDefaults;
|
package/src/utils/queryFor.d.ts
CHANGED
|
@@ -4,6 +4,14 @@ export type DeepPartialNullable<TValue> = TValue extends Array<any> ? DeepPartia
|
|
|
4
4
|
[KeyProperty in keyof TValue]?: DeepPartialNullable<TValue[KeyProperty]> | null;
|
|
5
5
|
} : TValue | null;
|
|
6
6
|
type DeepPartialNullableArray<TValue> = Array<DeepPartialNullable<TValue>>;
|
|
7
|
+
/**
|
|
8
|
+
* Like Pick<T, K>, but each picked value is DeepPartialNullable.
|
|
9
|
+
* The keys themselves stay required so callers must supply them,
|
|
10
|
+
* while nested fields become optional (filled by generated defaults).
|
|
11
|
+
*/
|
|
12
|
+
export type PickDeepPartialNullable<TValue, TKeys extends keyof TValue> = {
|
|
13
|
+
[Key in TKeys]: DeepPartialNullable<TValue[Key]>;
|
|
14
|
+
};
|
|
7
15
|
/**
|
|
8
16
|
*
|
|
9
17
|
* @param document Document that represents the specific GQL query / mutation schema.
|