@trackunit/react-core-contexts-test 0.1.151 → 0.1.153

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.cjs2.js CHANGED
@@ -61,26 +61,26 @@ const defaultOptions = {
61
61
  errorPolicy: "all",
62
62
  },
63
63
  };
64
- const isDebugging = !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG;
65
64
  /**
66
65
  * This is a wrapper around the MockedProvider that logs errors to the console.
67
66
  */
68
67
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- function ApolloMockedProviderWithError(props) {
68
+ function ApolloMockedProviderWithError(props, forceDebugging = false) {
69
+ const isDebugging = process ? !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG : false;
70
70
  const { mocks } = props, otherProps = __rest(props, ["mocks"]);
71
- const mockLink = new testing.MockLink(mocks, false, { showWarnings: isDebugging });
71
+ const mockLink = new testing.MockLink(mocks, false, { showWarnings: forceDebugging || isDebugging });
72
72
  const errorLoggingLink = error.onError(({ graphQLErrors, networkError }) => {
73
73
  if (graphQLErrors) {
74
74
  // eslint-disable-next-line array-callback-return
75
75
  graphQLErrors.map(({ message, locations, path }) => {
76
- if (isDebugging) {
76
+ if (forceDebugging || isDebugging) {
77
77
  // eslint-disable-next-line no-console
78
78
  console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
79
79
  }
80
80
  });
81
81
  }
82
82
  if (networkError) {
83
- if (isDebugging) {
83
+ if (forceDebugging || isDebugging) {
84
84
  // eslint-disable-next-line no-console
85
85
  console.log(`[Network error]: ${networkError}`);
86
86
  }
@@ -652,8 +652,8 @@ class TrackunitProvidersMockBuilder {
652
652
  * @param testChildren - the child element being tested.
653
653
  * @param addTestRootContainer - if you want to add a root container to the test.
654
654
  */
655
- getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
656
- return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsxRuntime.jsx("div", { style: {
655
+ getMockedCompositionRoot(testChildren, addTestRootContainer = true, forceDebugging = false) {
656
+ return (jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsxRuntime.jsx(reactRouterDom.MemoryRouter, Object.assign({}, this.selectedRouterProps, { children: jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: this.selectedCurrentUserContext, children: jsxRuntime.jsx(reactCoreHooks.AnalyticsContext.Provider, { value: this.selectedAnalyticsContext, children: jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, { value: this.selectedUserSubscriptionContext, children: jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, { value: this.selectedOemBrandingContext, children: jsxRuntime.jsx(reactCoreHooks.TokenProvider, { value: this.selectedTokenContext, children: jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: this.selectedToastContext, children: jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsxRuntime.jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, forceDebugging: forceDebugging, children: jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: this.selectedNavigationContext, children: jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsxRuntime.jsx("div", { style: {
657
657
  "--tw-scale-x": "0.99",
658
658
  "--tw-scale-y": "0.99",
659
659
  }, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsxRuntime.jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) })) }));
@@ -698,7 +698,7 @@ class TrackunitProvidersMockBuilder {
698
698
  * This will return the children in the correct mocked hierarchy of context providers.
699
699
  */
700
700
  storybook(child) {
701
- return this.getMockedCompositionRoot(child, false);
701
+ return this.getMockedCompositionRoot(child, false, true);
702
702
  }
703
703
  }
704
704
  /**
package/index.esm2.js CHANGED
@@ -55,26 +55,26 @@ const defaultOptions = {
55
55
  errorPolicy: "all",
56
56
  },
57
57
  };
58
- const isDebugging = !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG;
59
58
  /**
60
59
  * This is a wrapper around the MockedProvider that logs errors to the console.
61
60
  */
62
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
- function ApolloMockedProviderWithError(props) {
62
+ function ApolloMockedProviderWithError(props, forceDebugging = false) {
63
+ const isDebugging = process ? !!process.env.VSCODE_INSPECTOR_OPTIONS || !!process.env.DEBUG : false;
64
64
  const { mocks } = props, otherProps = __rest(props, ["mocks"]);
65
- const mockLink = new MockLink(mocks, false, { showWarnings: isDebugging });
65
+ const mockLink = new MockLink(mocks, false, { showWarnings: forceDebugging || isDebugging });
66
66
  const errorLoggingLink = onError(({ graphQLErrors, networkError }) => {
67
67
  if (graphQLErrors) {
68
68
  // eslint-disable-next-line array-callback-return
69
69
  graphQLErrors.map(({ message, locations, path }) => {
70
- if (isDebugging) {
70
+ if (forceDebugging || isDebugging) {
71
71
  // eslint-disable-next-line no-console
72
72
  console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
73
73
  }
74
74
  });
75
75
  }
76
76
  if (networkError) {
77
- if (isDebugging) {
77
+ if (forceDebugging || isDebugging) {
78
78
  // eslint-disable-next-line no-console
79
79
  console.log(`[Network error]: ${networkError}`);
80
80
  }
@@ -646,8 +646,8 @@ class TrackunitProvidersMockBuilder {
646
646
  * @param testChildren - the child element being tested.
647
647
  * @param addTestRootContainer - if you want to add a root container to the test.
648
648
  */
649
- getMockedCompositionRoot(testChildren, addTestRootContainer = true) {
650
- return (jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsx("div", { style: {
649
+ getMockedCompositionRoot(testChildren, addTestRootContainer = true, forceDebugging = false) {
650
+ return (jsx(EnvironmentContextProvider, { value: this.selectedEnvironmentContext, children: jsx(MemoryRouter, Object.assign({}, this.selectedRouterProps, { 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(FilterBarProvider, { value: { filterBarValues: this.selectedFilterBarValues }, children: jsx(AssetSortingProvider, { value: this.selectedAssetSortingContext, children: jsx(ApolloMockedProviderWithError, { mocks: this.selectedApolloMocks, addTypename: false, forceDebugging: forceDebugging, children: jsx(NavigationContextProvider, { value: this.selectedNavigationContext, children: jsx(CurrentUserPreferenceProvider, { value: this.selectedCurrentUserPreferenceContext, children: addTestRootContainer ? (jsx("div", { style: {
651
651
  "--tw-scale-x": "0.99",
652
652
  "--tw-scale-y": "0.99",
653
653
  }, className: "inline-block h-[1000px] w-[1024px]", "data-testid": "testRoot", children: testChildren })) : (jsx("div", { children: testChildren })) }) }) }) }) }) }) }) }) }) }) }) })) }));
@@ -692,7 +692,7 @@ class TrackunitProvidersMockBuilder {
692
692
  * This will return the children in the correct mocked hierarchy of context providers.
693
693
  */
694
694
  storybook(child) {
695
- return this.getMockedCompositionRoot(child, false);
695
+ return this.getMockedCompositionRoot(child, false, true);
696
696
  }
697
697
  }
698
698
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "0.1.151",
3
+ "version": "0.1.153",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -2,4 +2,4 @@
2
2
  /**
3
3
  * This is a wrapper around the MockedProvider that logs errors to the console.
4
4
  */
5
- export declare function ApolloMockedProviderWithError(props: any): JSX.Element;
5
+ export declare function ApolloMockedProviderWithError(props: any, forceDebugging?: boolean): JSX.Element;
@@ -340,7 +340,7 @@ export declare class TrackunitProvidersMockBuilder {
340
340
  * @param testChildren - the child element being tested.
341
341
  * @param addTestRootContainer - if you want to add a root container to the test.
342
342
  */
343
- protected getMockedCompositionRoot(testChildren: React.ReactNode, addTestRootContainer?: boolean): JSX.Element;
343
+ protected getMockedCompositionRoot(testChildren: React.ReactNode, addTestRootContainer?: boolean, forceDebugging?: boolean): JSX.Element;
344
344
  /**
345
345
  * This will return the mocked composition root.
346
346
  */