Skip to content

Commit

Permalink
Fix compare button for treatment tables on study view (#5097)
Browse files Browse the repository at this point in the history
* fix missing compare button for treatment tables

* add compare button tests

---------

Co-authored-by: Bryan Lai <[email protected]>
  • Loading branch information
gblaih and Bryan Lai authored Jan 28, 2025
1 parent 3ff4904 commit ed681f1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
42 changes: 42 additions & 0 deletions end-to-end-test/remote/specs/core/studyview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,24 @@ describe('study view treatments table', () => {
assertScreenShotMatch(res);
});

it('compare button appears when selecting multiple rows in sample treatments', async () => {
const sampleTreatmentsFirstCheckbox =
'[data-test="SAMPLE_TREATMENTS-table"] .ReactVirtualized__Table__row:nth-child(1) input';
const sampleTreatmentsSecondCheckbox =
'[data-test="SAMPLE_TREATMENTS-table"] .ReactVirtualized__Table__row:nth-child(2) input';
const sampleTreatmentsCompareButton = '[data-test="table-compare-btn"]';
const url = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014`;
await goToUrlAndSetLocalStorage(url);

await (await getElement(sampleTreatmentsFirstCheckbox)).waitForExist();
await clickElement(sampleTreatmentsFirstCheckbox);
await (await getElement(sampleTreatmentsSecondCheckbox)).waitForExist();
await clickElement(sampleTreatmentsSecondCheckbox);
assert(
await (await getElement(sampleTreatmentsCompareButton)).isExisting()
);
});

it('can filter a study by patient treatments', async () => {
const url = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014`;
await goToUrlAndSetLocalStorage(url);
Expand All @@ -1004,6 +1022,30 @@ describe('study view treatments table', () => {
const res = await checkElementWithMouseDisabled('#mainColumn');
assertScreenShotMatch(res);
});

it('compare button appears when selecting multiple rows in patient treatments', async () => {
const url = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014`;
await goToUrlAndSetLocalStorage(url);

const patientTreatmentsFirstCheckbox =
'[data-test="PATIENT_TREATMENTS-table"] .ReactVirtualized__Table__row:nth-child(1) input';
const patientTreatmentsSecondCheckbox =
'[data-test="PATIENT_TREATMENTS-table"] .ReactVirtualized__Table__row:nth-child(2) input';
const patientTreatmentsCompareButton =
'[data-test="table-compare-btn"]';

await (await getElement(patientTreatmentsFirstCheckbox)).waitForExist();
await clickElement(patientTreatmentsFirstCheckbox);
await (
await getElement(patientTreatmentsSecondCheckbox)
).waitForExist();
await clickElement(patientTreatmentsSecondCheckbox);
assert(
await (
await getElement(patientTreatmentsCompareButton)
).isExisting()
);
});
});

describe('study view mutations table', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,10 @@ export class StudyViewPageStore
promises,
async (
selectedSampleSet: ComplexKeyMap<Sample>,
sampleTreatments: SampleTreatmentRow[]
sampleTreatments: SampleTreatmentReport
) => {
const treatmentKeysMap = _.keyBy(treatmentUniqueKeys);
const desiredTreatments = sampleTreatments.filter(
const desiredTreatments = sampleTreatments.treatments.filter(
t =>
treatmentUniqueKey(t, isPatientType) in
treatmentKeysMap
Expand Down
5 changes: 4 additions & 1 deletion src/pages/studyView/charts/ChartContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ export class ChartContainer extends React.Component<IChartContainerProps, {}> {
get comparisonPagePossible(): boolean {
return (
this.props.promise.isComplete &&
this.props.promise.result!.length > 1 &&
(this.props.promise.result.treatments ??
this.props.promise.result.patientTreatments ??
this.props.promise.result)!.length > 1 &&
COMPARISON_CHART_TYPES.indexOf(this.props.chartType) > -1 &&
!this.props.chartMeta.mutationOptionType
);
Expand Down Expand Up @@ -492,6 +494,7 @@ export class ChartContainer extends React.Component<IChartContainerProps, {}> {
content: (
<div
data-tour="mutated-genes-table-compare-btn"
data-test="table-compare-btn"
style={{ display: 'flex', alignItems: 'center' }}
>
<ComparisonVsIcon
Expand Down

0 comments on commit ed681f1

Please sign in to comment.