Skip to content

Commit 3dcbb5f

Browse files
rjohanekraejohanek
andauthored
[DT-947]Fix flaky CohortEditor unit tests (#5153)
Co-authored-by: rjohanek <[email protected]>
1 parent bc3dc84 commit 3dcbb5f

File tree

9 files changed

+58
-8
lines changed

9 files changed

+58
-8
lines changed

.pnp.cjs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
36.2 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"react-dropzone": "^11.4.0",
5454
"react-favicon": "^2.0.3",
5555
"react-hyperscript-helpers": "^2.0.0",
56+
"react-lazy-named": "^1.2.2",
5657
"react-modal": "^3.16.1",
5758
"react-notifications-component": "^4.0.1",
5859
"react-oidc-context": "^2.1.0",

src/billing/SpendReport/SpendReport.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { SpinnerOverlay, useUniqueId } from '@terra-ui-packages/components';
22
import { subDays } from 'date-fns/fp';
33
import _ from 'lodash/fp';
4-
import { lazy, Suspense, useEffect, useState } from 'react';
4+
import { Suspense, useEffect, useState } from 'react';
55
import React from 'react';
6+
import lazy from 'react-lazy-named';
67
import { ErrorAlert } from 'src/alerts/ErrorAlert';
78
import { ExternalLink } from 'src/billing/NewBillingProjectWizard/StepWizard/ExternalLink';
89
import { CostCard } from 'src/billing/SpendReport/CostCard';
@@ -21,7 +22,7 @@ import { FormLabel } from 'src/libs/forms';
2122
import * as Nav from 'src/libs/nav';
2223
import { useCancellation } from 'src/libs/react-utils';
2324

24-
const LazyChart = lazy(() => import('src/components/Chart'));
25+
const LazyChart = lazy(() => import('src/components/Chart'), 'Chart');
2526
const maxWorkspacesInChart = 10;
2627

2728
const OtherMessaging = ({ cost, cloudPlatform }) => {

src/components/Chart.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ highchartsExporting(Highcharts);
1010
// this is needed to permit use of internally constructed links in a Highcharts formatter
1111
Highcharts.AST.bypassHTMLFiltering = true;
1212

13-
const Chart = ({ options }) => h(HighchartsReact, { highcharts: Highcharts, options });
14-
15-
export default Chart;
13+
export const Chart = ({ options }) => h(HighchartsReact, { highcharts: Highcharts, options });

src/dataset-builder/CohortEditor.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ jest.mock('lodash/fp', (): LodashFpExports => {
4242
};
4343
});
4444

45+
type ChartExports = typeof import('src/components/Chart');
46+
jest.mock('src/components/Chart', (): ChartExports => {
47+
return {
48+
...jest.requireActual('src/components/Chart'),
49+
Chart: jest.fn().mockReturnValue('Chart'),
50+
};
51+
});
52+
4553
describe('CohortEditor', () => {
4654
type CriteriaViewPropsOverrides = {
4755
criteria: AnyCriteria;
@@ -436,7 +444,7 @@ describe('CohortEditor', () => {
436444
expect(screen.getByText('Group 1')).toBeTruthy();
437445
});
438446

439-
it.skip('can add/delete criteria groups and maintain user understandable names', async () => {
447+
it('can add/delete criteria groups and maintain user understandable names', async () => {
440448
// Arrange
441449
showCohortEditor();
442450
const user = userEvent.setup();

src/dataset-builder/CohortEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Spinner, useLoadedData } from '@terra-ui-packages/components';
22
import _ from 'lodash/fp';
33
import React, { Fragment, useEffect, useRef, useState } from 'react';
44
import { div, h, h2, h3, strong } from 'react-hyperscript-helpers';
5-
import Chart from 'src/components/Chart';
5+
import { Chart } from 'src/components/Chart';
66
import { ButtonOutline, ButtonPrimary, GroupedSelect, Link, Select } from 'src/components/common';
77
import Slider from 'src/components/common/Slider';
88
import { icon } from 'src/components/icons';

src/dataset-builder/DatasetBuilderDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useLoadedData } from '@terra-ui-packages/components';
22
import _ from 'lodash/fp';
33
import { div, h, h1, h3 } from 'react-hyperscript-helpers';
4-
import Chart from 'src/components/Chart';
4+
import { Chart } from 'src/components/Chart';
55
import { ButtonOutline, spinnerOverlay } from 'src/components/common';
66
import FooterWrapper from 'src/components/FooterWrapper';
77
import { MarkdownViewer } from 'src/components/markdown';

yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14500,6 +14500,18 @@ __metadata:
1450014500
languageName: node
1450114501
linkType: hard
1450214502

14503+
"react-lazy-named@npm:^1.2.2":
14504+
version: 1.2.2
14505+
resolution: "react-lazy-named@npm:1.2.2"
14506+
dependencies:
14507+
lodash.get: ^4.4.2
14508+
peerDependencies:
14509+
react: ^16.6.0 || ^17.0.0-alpha
14510+
react-dom: ^16.6.0 || ^17.0.0-alpha
14511+
checksum: 0ba297c460c7174791a626d9d68873ba1670071b288faae423a1da5417897c01db983dfaa30906b9a2fd3a571fa3b5fc11b738f12096c8b10292ac8a179a9e8d
14512+
languageName: node
14513+
linkType: hard
14514+
1450314515
"react-lifecycles-compat@npm:^3.0.0, react-lifecycles-compat@npm:^3.0.4, react-lifecycles-compat@npm:~3.0.4":
1450414516
version: 3.0.4
1450514517
resolution: "react-lifecycles-compat@npm:3.0.4"
@@ -16240,6 +16252,7 @@ __metadata:
1624016252
react-dropzone: ^11.4.0
1624116253
react-favicon: ^2.0.3
1624216254
react-hyperscript-helpers: ^2.0.0
16255+
react-lazy-named: ^1.2.2
1624316256
react-modal: ^3.16.1
1624416257
react-notifications-component: ^4.0.1
1624516258
react-oidc-context: ^2.1.0

0 commit comments

Comments
 (0)