Skip to content

Commit fc2e58b

Browse files
authored
Merge pull request #410 from bcgsc/release/v6.25.2
Release v6.25.2
2 parents b1082e0 + dfa29cc commit fc2e58b

File tree

51 files changed

+2670
-1565
lines changed

Some content is hidden

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

51 files changed

+2670
-1565
lines changed

app/common.d.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ type ImageType = {
9494
} & RecordDefaults;
9595

9696
type GeneType = {
97-
cancerRelated: boolean;
97+
kbStatementRelated: boolean;
9898
drugTargetable: boolean;
9999
knownFusionPartner: boolean;
100100
knownSmallMutation: boolean;
@@ -148,6 +148,7 @@ type CopyNumberType = {
148148
cnvState: string | null;
149149
comments: string | null;
150150
copyChange: number | null;
151+
displayName: string | null;
151152
end: number | null;
152153
gene: GeneType | null;
153154
kbCategory: string | null;
@@ -166,6 +167,7 @@ type StructuralVariantType = {
166167
ctermGene: string | null;
167168
ctermTranscript: string | null;
168169
detectedIn: string | null;
170+
displayName: string | null;
169171
eventType: string | null;
170172
exon1: string | null;
171173
exon2: string | null;
@@ -188,6 +190,7 @@ type SmallMutationType = {
188190
altSeq: string | null;
189191
chromosome: number | null;
190192
comments: string | null;
193+
displayName: string | null;
191194
endPosition: number | null;
192195
gene: GeneType;
193196
germline: string | null;

app/commonComponents.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type SummaryProps = {
2+
templateName: string;
3+
isPrint: boolean;
4+
printVersion?: 'stable' | 'beta' | null;
5+
loadedDispatch?: (type: Record<'type', string>) => void;
6+
[x: string]: unknown;
7+
};
8+
9+
export {
10+
SummaryProps,
11+
};
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from 'react';
2-
import { screen, render, fireEvent } from '@testing-library/react';
2+
import '@testing-library/jest-dom';
3+
import { screen, render } from '@testing-library/react';
34

45
import GeneCellRenderer from '..';
56

67
const mockGene = 'EGFR';
78
const mockFusionCommas = 'CABLES1,DCC';
89
const mockFusionColons = 'CABLES1 :: DCC';
9-
const expectedFusions = ['CABLES1', 'DCC'];
10-
1110
// eslint-disable-next-line react/display-name
1211
jest.mock('../../GeneViewer', () => () => (<div role="presentation" />));
1312

@@ -23,30 +22,6 @@ describe('GeneCellRenderer', () => {
2322
expect(asFragment()).toMatchSnapshot();
2423
});
2524

26-
test('It renders the gene and the link button', async () => {
27-
render(
28-
<GeneCellRenderer
29-
value={mockGene}
30-
link
31-
/>,
32-
);
33-
34-
expect(await screen.findByText(mockGene)).toBeInTheDocument();
35-
expect(await screen.findByRole('button')).toBeInTheDocument();
36-
});
37-
38-
test('It renders the gene without a link button', async () => {
39-
render(
40-
<GeneCellRenderer
41-
value={mockGene}
42-
link={false}
43-
/>,
44-
);
45-
46-
expect(await screen.findByText(mockGene)).toBeInTheDocument();
47-
expect(screen.queryByRole('button')).not.toBeInTheDocument();
48-
});
49-
5025
test('It renders a fusion gene with a comma', async () => {
5126
render(
5227
<GeneCellRenderer
@@ -55,9 +30,6 @@ describe('GeneCellRenderer', () => {
5530
/>,
5631
);
5732

58-
expectedFusions.forEach((fusion) => {
59-
expect(screen.getByText(fusion)).toBeInTheDocument();
60-
});
6133
expect(screen.getByText(',')).toBeInTheDocument();
6234
});
6335

@@ -69,21 +41,6 @@ describe('GeneCellRenderer', () => {
6941
/>,
7042
);
7143

72-
expectedFusions.forEach((fusion) => {
73-
expect(screen.getByText(fusion)).toBeInTheDocument();
74-
});
7544
expect(screen.getByText('::')).toBeInTheDocument();
7645
});
77-
78-
test('The GeneViewer is shown upon link button click', async () => {
79-
render(
80-
<GeneCellRenderer
81-
value={mockGene}
82-
link
83-
/>,
84-
);
85-
86-
fireEvent.click(await screen.findByRole('button'));
87-
expect(await screen.findByRole('presentation')).toBeInTheDocument();
88-
});
8946
});

app/components/DataTable/components/GeneCellRenderer/__tests__/__snapshots__/GeneCellRenderer.test.tsx.snap

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
exports[`GeneCellRenderer It matches the snapshot 1`] = `
44
<DocumentFragment>
5-
<span
6-
class="gene__text"
7-
role="button"
8-
tabindex="0"
9-
>
10-
EGFR
11-
</span>
5+
<div
6+
role="presentation"
7+
/>
128
</DocumentFragment>
139
`;

app/components/DataTable/components/GeneCellRenderer/index.tsx

+16-42
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,22 @@ type GeneCellRendererProps = {
1212
const GeneCellRenderer = ({
1313
value,
1414
link = false,
15-
}: GeneCellRendererProps): JSX.Element => {
16-
const [showGeneViewer, setShowGeneViewer] = useState(false);
15+
}: GeneCellRendererProps) => (
16+
value && value.split(/\s*::\s*|,\s?/).map((val, index) => (
17+
// eslint-disable-next-line react/no-array-index-key
18+
<React.Fragment key={`${val}_${index}`}>
19+
{index > 0 && (
20+
<span>
21+
{value.includes(' :: ') ? ' :: ' : ', '}
22+
</span>
23+
)}
24+
<GeneViewer
25+
isLink={link}
26+
gene={val}
27+
/>
28+
</React.Fragment>
29+
))
1730

18-
return (
19-
<>
20-
{value && value.split(/\s*::\s*|,\s?/).map((val, index) => (
21-
<React.Fragment key={index}>
22-
{index > 0 && (
23-
<span>
24-
{value.includes(' :: ') ? ' :: ' : ', '}
25-
</span>
26-
)}
27-
{link ? (
28-
<>
29-
<span
30-
tabIndex={0}
31-
role="button"
32-
onClick={() => setShowGeneViewer(true)}
33-
onKeyDown={() => setShowGeneViewer(true)}
34-
className="gene__text"
35-
>
36-
{val}
37-
</span>
38-
<>
39-
{showGeneViewer && (
40-
<GeneViewer
41-
isOpen={showGeneViewer}
42-
gene={val}
43-
onClose={() => setShowGeneViewer(false)}
44-
/>
45-
)}
46-
</>
47-
</>
48-
) : (
49-
<span>
50-
{val}
51-
</span>
52-
)}
53-
</React.Fragment>
54-
))}
55-
</>
56-
);
57-
};
31+
);
5832

5933
export default GeneCellRenderer;

app/components/DataTable/components/GeneViewer/__tests__/GeneViewer.test.tsx

+58-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { when, resetAllWhenMocks } from 'jest-when';
33
import {
4-
screen, render, waitFor,
4+
screen, render, waitFor, fireEvent, act,
55
} from '@testing-library/react';
66
import { ModuleRegistry } from '@ag-grid-community/core';
77
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
@@ -29,6 +29,7 @@ const mockReport = {
2929

3030
const withReportContext = (Component) => function ReportContextHOC(props) {
3131
return (
32+
// eslint-disable-next-line react/jsx-no-constructed-context-values
3233
<ReportContext.Provider value={{ report: mockReport, setReport: () => {} }}>
3334
<Component {...props} />
3435
</ReportContext.Provider>
@@ -52,30 +53,67 @@ describe('GeneViewer', () => {
5253
const { asFragment } = render(
5354
<Component
5455
gene={mockGene}
55-
isOpen
5656
/>,
5757
);
5858

5959
expect(asFragment()).toMatchSnapshot();
6060
});
6161

62-
test('It calls onClose if the gene does not exist', async () => {
62+
test('It renders the gene name', async () => {
63+
render(
64+
<Component
65+
gene={mockGene}
66+
/>,
67+
);
68+
69+
expect(await screen.findByText(mockGene)).toBeInTheDocument();
70+
});
71+
72+
test('It renders the gene and the link button, if isLink prop is given', async () => {
73+
render(
74+
<Component
75+
gene={mockGene}
76+
isLink
77+
/>,
78+
);
79+
80+
expect(await screen.findByText(mockGene)).toBeInTheDocument();
81+
expect(screen.getByRole('button')).toBeInTheDocument();
82+
});
83+
84+
test('It renders a modal when the gene name is clicked', async () => {
85+
render(
86+
<Component
87+
gene={mockGene}
88+
isLink
89+
/>,
90+
);
91+
act(() => {
92+
fireEvent.click(screen.getByRole('button'));
93+
});
94+
expect(screen.getByRole('dialog')).toBeInTheDocument();
95+
});
96+
97+
test('It closes the dialog if gene does not exist', async () => {
6398
when(api.get as (endpoint: string) => Partial<ApiCall>)
6499
.calledWith(`/reports/${mockReport.ident}/gene-viewer/${mockErrorGene}`)
65100
.mockImplementation(() => ({ request: async () => { throw new Error(); } }));
66101

67-
const mockOnClose = jest.fn();
68-
69102
render(
70103
<Component
71104
gene={mockErrorGene}
72-
isOpen
73-
onClose={mockOnClose}
105+
isLink
74106
/>,
75107
);
76-
77-
await waitFor(() => expect(mockOnClose).toHaveBeenCalledTimes(1));
78-
await waitFor(() => expect(mockOnClose).toHaveBeenCalledWith());
108+
const button = await screen.findByText(mockErrorGene);
109+
act(() => {
110+
fireEvent.click(button);
111+
});
112+
const dialog = screen.getByRole('dialog');
113+
expect(dialog).toBeInTheDocument();
114+
await waitFor(() => {
115+
expect(dialog).not.toBeInTheDocument();
116+
});
79117
});
80118

81119
test('Tabs are all shown', async () => {
@@ -86,18 +124,20 @@ describe('GeneViewer', () => {
86124
render(
87125
<Component
88126
gene={mockGene}
89-
isOpen
90-
onClose={() => {}}
127+
isLink
91128
/>,
92129
);
93130

94-
const promises = [];
131+
const button = await screen.findByText(mockGene);
132+
133+
act(() => {
134+
fireEvent.click(button);
135+
});
136+
137+
await screen.getByRole('dialog');
138+
95139
for (const key of Object.keys(mockGeneResults)) {
96-
promises.push(screen.findByText(key, { exact: false }));
97-
}
98-
const resolved = await Promise.all(promises);
99-
for (const elem of resolved) {
100-
expect(elem).toBeInTheDocument();
140+
screen.getByText(key, { exact: false });
101141
}
102142
});
103143
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`GeneViewer It matches the snapshot 1`] = `<DocumentFragment />`;
3+
exports[`GeneViewer It matches the snapshot 1`] = `
4+
<DocumentFragment>
5+
<span>
6+
TP53
7+
</span>
8+
</DocumentFragment>
9+
`;

0 commit comments

Comments
 (0)