Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ndt 202 dependabot update growthbook react #3666

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [1.214.4](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.214.3...v1.214.4) (2024-12-04)

## [1.214.3](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.214.2...v1.214.3) (2024-12-04)

## [1.214.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.214.1...v1.214.2) (2024-12-04)
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@fortawesome/react-fontawesome": "^0.2.2",
"@graphile-contrib/pg-many-to-many": "^1.0.2",
"@graphile/persisted-operations": "^0.1.1",
"@growthbook/growthbook-react": "^0.9.0",
"@growthbook/growthbook-react": "^1.2.1",
"@mui/base": "^5.0.0-alpha.115",
"@mui/icons-material": "^5.16.7",
"@mui/material": "^5.16.5",
Expand Down
10 changes: 7 additions & 3 deletions app/tests/pages/404.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { GrowthBookProvider } from '@growthbook/growthbook-react';
import { render, screen, within } from '@testing-library/react';
import Error404 from 'pages/404';
import GlobalTheme from 'styles/GlobalTheme';
import mockGrowthBook from 'tests/utils/mockGrowthBook';

jest.mock('next/router', () => ({
useRouter: jest.fn(),
}));

const renderStaticLayout = () => {
return render(
<GlobalTheme>
<Error404 />
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<Error404 />
</GlobalTheme>
</GrowthBookProvider>
);
};

Expand Down
10 changes: 7 additions & 3 deletions app/tests/pages/500.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { GrowthBookProvider } from '@growthbook/growthbook-react';
import { render, screen, within } from '@testing-library/react';
import Error500 from 'pages/500';
import GlobalTheme from 'styles/GlobalTheme';
import mockGrowthBook from 'tests/utils/mockGrowthBook';

jest.mock('next/router', () => ({
useRouter: jest.fn(),
}));

const renderStaticLayout = () => {
return render(
<GlobalTheme>
<Error500 />
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<Error500 />
</GlobalTheme>
</GrowthBookProvider>
);
};

Expand Down
58 changes: 32 additions & 26 deletions app/tests/utils/componentTestingHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import GlobalStyle from 'styles/GobalStyles';
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime';
import { AppProvider } from 'components/AppProvider';
import UnsavedChangesProvider from 'components/UnsavedChangesProvider';
import { GrowthBookProvider } from '@growthbook/growthbook-react';
import TestingHelper from './TestingHelper';
import mockGrowthBook from './mockGrowthBook';

interface ComponentTestingHelperOptions<TQuery extends OperationType> {
component: (props: any) => JSX.Element;
Expand Down Expand Up @@ -83,21 +85,23 @@ class ComponentTestingHelper<
extraProps: any = this.options.defaultComponentProps
) {
this.renderResult = render(
<GlobalTheme>
<GlobalStyle />
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<AppProvider>
<UnsavedChangesProvider>
<this.TestRenderer
getPropsFromTestQuery={getPropsFromTestQuery}
extraProps={extraProps}
/>
</UnsavedChangesProvider>
</AppProvider>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<GlobalStyle />
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<AppProvider>
<UnsavedChangesProvider>
<this.TestRenderer
getPropsFromTestQuery={getPropsFromTestQuery}
extraProps={extraProps}
/>
</UnsavedChangesProvider>
</AppProvider>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
</GrowthBookProvider>
);
return this.renderResult;
}
Expand All @@ -108,17 +112,19 @@ class ComponentTestingHelper<
extraProps: any = this.options.defaultComponentProps
) {
this.renderResult.rerender(
<GlobalTheme>
<GlobalStyle />
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<this.TestRenderer
getPropsFromTestQuery={getPropsFromTestQuery}
extraProps={extraProps}
/>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<GlobalStyle />
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<this.TestRenderer
getPropsFromTestQuery={getPropsFromTestQuery}
extraProps={extraProps}
/>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
</GrowthBookProvider>
);
return this.renderResult;
}
Expand Down
46 changes: 25 additions & 21 deletions app/tests/utils/formTestRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtim
import { useRef, useState } from 'react';
import { IChangeEvent } from '@rjsf/core';
import { FormBaseRef } from 'components/Form/FormBase';
import { GrowthBookProvider } from '@growthbook/growthbook-react';
import createMockRouter from './mockNextRouter';
import mockGrowthBook from './mockGrowthBook';

type Props = {
formData: any;
Expand Down Expand Up @@ -44,27 +46,29 @@ const FormTestRenderer: React.FC<Props> = ({

return (
<RelayEnvironmentProvider environment={env}>
<GlobalTheme>
<RouterContext.Provider value={createMockRouter()}>
<UnsavedChangesProvider>
<FormBase
ref={formRef}
theme={defaultTheme}
formData={formState}
onSubmit={handleSubmit}
schema={schema as RJSFSchema}
uiSchema={uiSchema}
formContext={formContext}
onChange={(e: IChangeEvent) => setFormState(e.formData)}
>
<button type="submit">Submit</button>
<button type="button" onClick={() => setFormState({})}>
Cancel
</button>
</FormBase>
</UnsavedChangesProvider>
</RouterContext.Provider>
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<RouterContext.Provider value={createMockRouter()}>
<UnsavedChangesProvider>
<FormBase
ref={formRef}
theme={defaultTheme}
formData={formState}
onSubmit={handleSubmit}
schema={schema as RJSFSchema}
uiSchema={uiSchema}
formContext={formContext}
onChange={(e: IChangeEvent) => setFormState(e.formData)}
>
<button type="submit">Submit</button>
<button type="button" onClick={() => setFormState({})}>
Cancel
</button>
</FormBase>
</UnsavedChangesProvider>
</RouterContext.Provider>
</GlobalTheme>
</GrowthBookProvider>
</RelayEnvironmentProvider>
);
};
Expand Down
71 changes: 71 additions & 0 deletions app/tests/utils/mockGrowthBook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const mockGrowthBook = {
context: {},
_renderer: null,
_trackedExperiments: [],
_trackedFeatures: [],
debug: false,
subscriptions: [],
_rtQueue: [],
_rtTimer: null,
assigned: {},
_forcedFeatureValues: {},
_attributeOverrides: {},
render: () => {},
setAttributes: jest.fn(),
urlIsValid: jest.fn(),
hasGroupOverlap: jest.fn(),
setFeatures: jest.fn(),
track: jest.fn(),
run: jest.fn(),
getFeatureValue: jest.fn(),
isOn: jest.fn(),
isOff: jest.fn(),
setAttributeOverrides: jest.fn(),
setForcedVariations: jest.fn(),
setForcedFeatures: jest.fn(),
getAttributes: jest.fn(),
getAllResults: jest.fn(),
getAllResultsById: jest.fn(),
getAllResultsByName: jest.fn(),
getAllResultsByNamespace: jest.fn(),
getAllResultsByType: jest.fn(),
getAllResultsByUser: jest.fn(),
getAllResultsByUserId: jest.fn(),
getAllResultsByUserName: jest.fn(),
getAllResultsByUserNamespace: jest.fn(),
getAllResultsByUserType: jest.fn(),
getAllResultsByUserVariation: jest.fn(),
getAllResultsByVariation: jest.fn(),
getAttributesById: jest.fn(),
getAttributesByName: jest.fn(),
getAttributesByNamespace: jest.fn(),
getAttributesByType: jest.fn(),
getAttributesByUser: jest.fn(),
getAttributesByUserId: jest.fn(),
getAttributesByUserName: jest.fn(),
getAttributesByUserNamespace: jest.fn(),
getAttributesByUserType: jest.fn(),
getAttributesByUserVariation: jest.fn(),
getAttributesByVariation: jest.fn(),
getFeatures: jest.fn(),
subscribe: jest.fn(),
destroy: jest.fn(),
setRenderer: jest.fn(),
refresh: jest.fn(),
forceVariation: jest.fn(),
trackFeatureUsage: jest.fn(),
getFeatureResult: jest.fn(),
feature: jest.fn(),
runExperiment: jest.fn(),
evalFeature: jest.fn().mockReturnValue(true),
conditionPasses: jest.fn(),
_run: jest.fn(),
log: jest.fn(),
mergeOverrides: jest.fn(),
getHashAttribute: jest.fn(),
getResult: jest.fn(),
getContextUrl: jest.fn(),
setContextUrl: jest.fn(),
};

export default mockGrowthBook;
32 changes: 18 additions & 14 deletions app/tests/utils/pageTestingHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import GlobalTheme from 'styles/GlobalTheme';
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime';
import { AppProvider } from 'components/AppProvider';
import UnsavedChangesProvider from 'components/UnsavedChangesProvider';
import { GrowthBookProvider } from '@growthbook/growthbook-react';
import TestingHelper from './TestingHelper';
import mockGrowthBook from './mockGrowthBook';

interface PageTestingHelperOptions<TQuery extends OperationType> {
pageComponent: (props: RelayProps<{}, TQuery>) => JSX.Element;
Expand Down Expand Up @@ -65,20 +67,22 @@ class PageTestingHelper<TQuery extends OperationType> extends TestingHelper {

public renderPage() {
return render(
<GlobalTheme>
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<AppProvider>
<UnsavedChangesProvider>
<this.options.pageComponent
CSN
preloadedQuery={this.initialQueryRef}
/>
</UnsavedChangesProvider>
</AppProvider>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
<GrowthBookProvider growthbook={mockGrowthBook as any}>
<GlobalTheme>
<RouterContext.Provider value={this.router}>
<RelayEnvironmentProvider environment={this.environment}>
<AppProvider>
<UnsavedChangesProvider>
<this.options.pageComponent
CSN
preloadedQuery={this.initialQueryRef}
/>
</UnsavedChangesProvider>
</AppProvider>
</RelayEnvironmentProvider>
</RouterContext.Provider>
</GlobalTheme>
</GrowthBookProvider>
);
}
}
Expand Down
25 changes: 16 additions & 9 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1883,17 +1883,19 @@
resolved "https://registry.yarnpkg.com/@graphile/persisted-operations/-/persisted-operations-0.1.1.tgz#9a753a5fc46f7935d97620e3bf5a703202304ffb"
integrity sha512-9GDVvGXCmg7Vo8Zbbpx083nHTgM8nPXV13K+IoS9qX5d1HyDcWDXvI+fj2Bb122dFOyhfCeGyhiYpWvMrABBgA==

"@growthbook/growthbook-react@^0.9.0":
version "0.9.0"
resolved "https://registry.yarnpkg.com/@growthbook/growthbook-react/-/growthbook-react-0.9.0.tgz#c0f3b71349addb04225fa5524a8a2fce3059bfb1"
integrity sha512-8WJ6ckj5Wzg+pDos3/DNF2BJNL7S8NeFu+LLTtv/p+hGW1Epkl2et0N1goMQRfnyIhtLerOgTBR9eZoy9AxK2Q==
"@growthbook/growthbook-react@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@growthbook/growthbook-react/-/growthbook-react-1.2.1.tgz#e49a44e0b8b46204099a35f56a86ba6c76292b31"
integrity sha512-IMJfOQyeLnZoX+CiGPxQ19vzYDs5uugWB0WdQRnzx6Cy0GxbpK30+EbjaHNt5enVDjdpBorOROvCbYM9qb26/A==
dependencies:
"@growthbook/growthbook" "^0.18.0"
"@growthbook/growthbook" "^1.2.1"

"@growthbook/growthbook@^0.18.0":
version "0.18.0"
resolved "https://registry.yarnpkg.com/@growthbook/growthbook/-/growthbook-0.18.0.tgz#7ce599a6d9eaacaef1fdc5340aeeb8730345b25c"
integrity sha512-Z7ydUgVdYN9Qcu3KIfmkcL2CnnIMyscd4EuFaDJ7oi/TJ+v3VrJer0pZzZ9MZlUaQU+j4Z7MDOCB2NBKENXLkQ==
"@growthbook/growthbook@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@growthbook/growthbook/-/growthbook-1.2.1.tgz#efc236afec8aa061d306d72ab1c9fa67697e513e"
integrity sha512-V0of0mGXZ69poOTPoZ8TFkJkPpC9T766NZiJ1qwzwFAl8ZsuunmguC6RP4muri4q5DRPDzf3lRUSWLk0g8bdbw==
dependencies:
dom-mutator "^0.6.0"

"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.3.0":
version "9.3.0"
Expand Down Expand Up @@ -6503,6 +6505,11 @@ dom-helpers@^5.0.1:
"@babel/runtime" "^7.8.7"
csstype "^3.0.2"

dom-mutator@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/dom-mutator/-/dom-mutator-0.6.0.tgz#079d7a4b3e8981a562cd777548b99baab51d65c5"
integrity sha512-iCt9o0aYfXMUkz/43ZOAUFQYotjGB+GNbYJiJdz4TgXkyToXbbRy5S6FbTp72lRBtfpUMwEc1KmpFEU4CZeoNg==

dom-serializer@^1.0.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.4.1.tgz#de5d41b1aea290215dc45a6dae8adcf1d32e2d30"
Expand Down
1 change: 1 addition & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -756,3 +756,4 @@ mutations/create_assessment_form [mutations/[email protected]] 2024
@1.214.1 2024-12-04T03:24:26Z CCBC Service Account <[email protected]> # release v1.214.1
@1.214.2 2024-12-04T18:39:28Z CCBC Service Account <[email protected]> # release v1.214.2
@1.214.3 2024-12-04T21:21:10Z CCBC Service Account <[email protected]> # release v1.214.3
@1.214.4 2024-12-04T22:49:42Z CCBC Service Account <[email protected]> # release v1.214.4
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.214.3",
"version": "1.214.4",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <[email protected]>",
Expand Down
Loading