Skip to content

Commit

Permalink
Impl. structural variants table in study view
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop authored and Bas Leenknegt committed Jul 25, 2023
1 parent 9626fb1 commit 48669a1
Show file tree
Hide file tree
Showing 38 changed files with 3,052 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
goToUrlAndSetLocalStorageWithProperty,
getElementByTestHandle,
} = require('../../shared/specUtils');
const { waitForTable } = require('./namespace-columns-utils');
const { waitForTable } = require('./namespace-columns-utils.spec');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
goToUrlAndSetLocalStorageWithProperty,
getElementByTestHandle,
} = require('../../shared/specUtils');
const { waitForTable } = require('./namespace-columns-utils');
const { waitForTable } = require('./namespace-columns-utils.spec');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
selectColumn,
namespaceColumnsAreDisplayed,
getRowByGene,
} = require('./namespace-columns-utils');
} = require('./namespace-columns-utils.spec');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
selectColumn,
namespaceColumnsAreDisplayed,
getRowByGene,
} = require('./namespace-columns-utils');
} = require('./namespace-columns-utils.spec');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

Expand Down
154 changes: 154 additions & 0 deletions end-to-end-test/local/specs/struct-var-table.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
var assert = require('assert');
var goToUrlAndSetLocalStorage = require('../../shared/specUtils')
.goToUrlAndSetLocalStorage;
var waitForStudyView = require('../../shared/specUtils').waitForStudyView;

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');
// TODO remove feature flag after merge.
const studyViewUrl = `${CBIOPORTAL_URL}/study/summary?id=study_es_0&featureFlags=STUDY_VIEW_STRUCT_VAR_TABLE`;
const structVarTable = '//*[@data-test="structural variant pairs-table"]';
const filterCheckBox = '[data-test=labeledCheckbox]';
const structVarFilterPillTag = '[data-test=pill-tag]';
const uncheckedSvIcon = '[data-test=structVarQueryCheckboxUnchecked]';
const checkedSvIcon = '[data-test=structVarQueryCheckboxChecked]';
const structVarNameCell = '[data-test=structVarNameCell]';
const toast = '.Toastify div[role=alert]';

describe('study view structural variant table', function() {
beforeEach(() => {
goToUrlAndSetLocalStorage(studyViewUrl, true);
waitForStudyView();
});

it('adds structural variant to study view filter', () => {
$(structVarTable)
.$(filterCheckBox)
.click();
$('[data-test=selectSamplesButton]').waitForExist();
$('[data-test=selectSamplesButton]').click();
assert($(structVarFilterPillTag).isExisting());
});

it('shows all checkboxes when row is hovered', () => {
$(structVarNameCell).waitForExist();
const firstSvRowCell = $$(structVarNameCell)[0];
assert.equal($$(structVarNameCell)[1].getText(), 'SND1');
assert.equal($$(structVarNameCell)[2].getText(), 'BRAF');

movePointerWithRetry(firstSvRowCell, () =>
$(uncheckedSvIcon).waitForDisplayed()
);
assert.equal($$(uncheckedSvIcon).length, 3);
});

it('shows only checked checkboxes when row is not hovered', () => {
$(structVarNameCell).waitForExist();
const gene1Cell = $$(structVarNameCell)[1];
movePointerWithRetry(gene1Cell, () =>
$(uncheckedSvIcon).waitForDisplayed()
);
assert.equal($$(uncheckedSvIcon).length, 3);

gene1Cell.waitForClickable();
gene1Cell.click();

// hover somewhere else:
movePointerWithRetry($('span=Gene 2'), $(checkedSvIcon).waitForExist());

assert.equal($$(uncheckedSvIcon).length, 0);
assert.equal($$(checkedSvIcon).length, 1);
});

it('adds gene1::gene2 to Results View query', () => {
$(structVarNameCell).waitForExist();
const firstSvRowCell = $$(structVarNameCell)[0];

movePointerWithRetry(firstSvRowCell, () => {
$$(uncheckedSvIcon)[0].waitForClickable();
});
const gene1And2Checkbox = $$(uncheckedSvIcon)[0];
gene1And2Checkbox.click();
$(toast).waitForDisplayed();
clearToast();

const resultsViewQueryBox = openResultViewQueryBox();
assert.equal('SND1: FUSION::BRAF ;', resultsViewQueryBox.getValue());
});

it('adds gene1::* to Results View query', () => {
$(structVarNameCell).waitForExist();
const gene1Cell = $$(structVarNameCell)[1];
movePointerWithRetry(gene1Cell, () =>
$(uncheckedSvIcon).waitForDisplayed()
);
gene1Cell.waitForClickable();
gene1Cell.click();
$(toast).waitForDisplayed();
clearToast();

const resultsViewQueryBox = openResultViewQueryBox();
assert.equal('SND1: FUSION:: ;', resultsViewQueryBox.getValue());
});

it('adds *::gene2 to Results View query', () => {
$(structVarNameCell).waitForExist();
const gene2Cell = $$(structVarNameCell)[2];
movePointerWithRetry(gene2Cell, () =>
$(uncheckedSvIcon).waitForDisplayed()
);
gene2Cell.waitForClickable();
gene2Cell.click();
$(toast).waitForDisplayed();
clearToast();

const resultsViewQueryBox = openResultViewQueryBox();
assert.equal('BRAF: ::FUSION ;', resultsViewQueryBox.getValue());
});
});

function openResultViewQueryBox() {
const resultsViewQueryBox = $('[data-test=geneSet]');
resultsViewQueryBox.waitForClickable();
resultsViewQueryBox.click();
return resultsViewQueryBox;
}

function clearToast() {
const toastify = $('.Toastify button');
toastify.waitForClickable();
toastify.click();
browser.pause(100);
}

function movePointerTo(element) {
element.waitForDisplayed();
element.scrollIntoView();
const x = element.getLocation('x');
const y = element.getLocation('y');
browser.performActions([
{
type: 'pointer',
parameters: { pointerType: 'mouse' },
actions: [
{ type: 'pointerMove', duration: 0, x, y },
{ type: 'pointerMove', duration: 0, x, y },
],
},
]);
}

/**
* When scrolling to the new location, some tooltips might pop up and interfere.
* A retry solves this problem: the second time the pointer is already near/at the desired location
*/
function movePointerWithRetry(element, isOk) {
movePointerTo(element);
try {
if (isOk()) {
return;
}
} catch (e) {
// retry
}
movePointerTo(element);
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"buildBootstrap": "sass --style :compressed src/globalStyles/bootstrap-entry.scss src/globalStyles/prefixed-bootstrap.min.css",
"heroku-postbuild": "yarn run build && yarn add [email protected] -g",
"updateAPI": "yarn run fetchAPI && yarn run buildAPI && yarn run updateOncoKbAPI && yarn run updateGenomeNexusAPI",
"fetchAPILocal": "export CBIOPORTAL_URL=http://localhost:8090 && curl -L -k ${CBIOPORTAL_URL}/api/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI-docs.json && curl -L -k ${CBIOPORTAL_URL}/api/api-docs?group=internal | json | grep -v host | grep -v basePath | grep -v termsOfService > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json",
"fetchAPI": "./scripts/env_vars.sh && eval \"$(./scripts/env_vars.sh)\" && curl -L -k ${CBIOPORTAL_URL}/api/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI-docs.json && curl -L -k ${CBIOPORTAL_URL}/api/api-docs?group=internal | json | grep -v host | grep -v basePath | grep -v termsOfService > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json",
"fetchAPILocal": "export CBIOPORTAL_URL=http://localhost:8090 && curl -s -L -k ${CBIOPORTAL_URL}/api/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI-docs.json && curl -s -L -k ${CBIOPORTAL_URL}/api/api-docs?group=internal | json | grep -v host | grep -v basePath | grep -v termsOfService > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json",
"fetchAPI": "./scripts/env_vars.sh && eval \"$(./scripts/env_vars.sh)\" && curl -s -L -k ${CBIOPORTAL_URL}/api/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI-docs.json && curl -s -L -k ${CBIOPORTAL_URL}/api/api-docs?group=internal | json | grep -v host | grep -v basePath | grep -v termsOfService > packages/cbioportal-ts-api-client/src/generated/CBioPortalAPIInternal-docs.json",
"buildAPI": "node scripts/generate-api.js packages/cbioportal-ts-api-client/src/generated CBioPortalAPI CBioPortalAPIInternal",
"updateOncoKbAPI": "yarn run fetchOncoKbAPI && yarn run buildOncoKbAPI",
"fetchOncoKbAPI": "curl -k https://www.oncokb.org/api/v1/v2/api-docs?group=Public%20APIs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/oncokb-ts-api-client/src/generated/OncoKbAPI-docs.json",
"fetchOncoKbAPI": "curl -s -k https://www.oncokb.org/api/v1/v2/api-docs?group=Public%20APIs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/oncokb-ts-api-client/src/generated/OncoKbAPI-docs.json",
"buildOncoKbAPI": "node scripts/generate-api.js packages/oncokb-ts-api-client/src/generated OncoKbAPI",
"updateG2SAPI": "yarn run fetchG2SAPI && yarn run buildG2SAPI",
"fetchG2SAPI": "curl -k http://g2s.genomenexus.org/v2/api-docs?group=api > packages/genome-nexus-ts-api-client/src/generated/Genome2StructureAPI-docs.json",
"fetchG2SAPI": "curl -s -k http://g2s.genomenexus.org/v2/api-docs?group=api > packages/genome-nexus-ts-api-client/src/generated/Genome2StructureAPI-docs.json",
"buildG2SAPI": "node scripts/generate-api.js packages/genome-nexus-ts-api-client/src/generated Genome2StructureAPI",
"updateGenomeNexusAPI": "yarn run fetchGenomeNexusAPI && yarn run buildGenomeNexusAPI",
"fetchGenomeNexusAPI": "./scripts/env_vars.sh && eval \"$(./scripts/env_vars.sh)\" && curl -k ${GENOME_NEXUS_URL}/v2/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/genome-nexus-ts-api-client/src/generated/GenomeNexusAPI-docs.json && curl -k ${GENOME_NEXUS_URL}/v2/api-docs?group=internal | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/genome-nexus-ts-api-client/src/generated/GenomeNexusAPIInternal-docs.json",
"fetchGenomeNexusAPI": "./scripts/env_vars.sh && eval \"$(./scripts/env_vars.sh)\" && curl -s -k ${GENOME_NEXUS_URL}/v2/api-docs | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/genome-nexus-ts-api-client/src/generated/GenomeNexusAPI-docs.json && curl -s -k ${GENOME_NEXUS_URL}/v2/api-docs?group=internal | json | grep -v basePath | grep -v termsOfService | grep -v host > packages/genome-nexus-ts-api-client/src/generated/GenomeNexusAPIInternal-docs.json",
"buildGenomeNexusAPI": "node scripts/generate-api.js packages/genome-nexus-ts-api-client/src/generated GenomeNexusAPI GenomeNexusAPIInternal",
"updateHotspotGenes": "./scripts/get_hotspot_genes.sh > src/shared/static-data/hotspotGenes.json",
"compileOqlParser": "cd src/shared/lib/oql && pegjs oql-parser.pegjs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5874,6 +5874,65 @@
},
"title": "ServerStatusMessage"
},
"StructuralVariantFilterQuery": {
"type": "object",
"properties": {
"gene1Query": {
"$ref": "#/definitions/StructuralVariantGeneSubQuery"
},
"gene2Query": {
"$ref": "#/definitions/StructuralVariantGeneSubQuery"
},
"includeDriver": {
"type": "boolean"
},
"includeGermline": {
"type": "boolean"
},
"includeSomatic": {
"type": "boolean"
},
"includeUnknownOncogenicity": {
"type": "boolean"
},
"includeUnknownStatus": {
"type": "boolean"
},
"includeUnknownTier": {
"type": "boolean"
},
"includeVUS": {
"type": "boolean"
},
"tiersBooleanMap": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
},
"title": "StructuralVariantFilterQuery"
},
"StructuralVariantGeneSubQuery": {
"type": "object",
"properties": {
"entrezId": {
"type": "integer",
"format": "int32"
},
"hugoSymbol": {
"type": "string"
},
"specialValue": {
"type": "string",
"enum": [
"ANY_GENE",
"NO_GENE"
]
}
},
"title": "StructuralVariantGeneSubQuery"
},
"StudyViewFilter": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -5958,6 +6017,12 @@
"sampleTreatmentTargetFilters": {
"$ref": "#/definitions/AndedSampleTreatmentFilters"
},
"structuralVariantFilters": {
"type": "array",
"items": {
"$ref": "#/definitions/StudyViewStructuralVariantFilter"
}
},
"studyIds": {
"type": "array",
"items": {
Expand All @@ -5967,6 +6032,28 @@
},
"title": "StudyViewFilter"
},
"StudyViewStructuralVariantFilter": {
"type": "object",
"properties": {
"molecularProfileIds": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
}
},
"structVarQueries": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/StructuralVariantFilterQuery"
}
}
}
},
"title": "StudyViewStructuralVariantFilter"
},
"TypeOfCancer": {
"type": "object",
"required": [
Expand Down
39 changes: 39 additions & 0 deletions packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,36 @@ export type SampleTreatmentRow = {
export type ServerStatusMessage = {
'status': string

};
export type StructuralVariantFilterQuery = {
'gene1Query': StructuralVariantGeneSubQuery

'gene2Query': StructuralVariantGeneSubQuery

'includeDriver': boolean

'includeGermline': boolean

'includeSomatic': boolean

'includeUnknownOncogenicity': boolean

'includeUnknownStatus': boolean

'includeUnknownTier': boolean

'includeVUS': boolean

'tiersBooleanMap': {}

};
export type StructuralVariantGeneSubQuery = {
'entrezId': number

'hugoSymbol': string

'specialValue': "ANY_GENE" | "NO_GENE"

};
export type StudyViewFilter = {
'alterationFilter': AlterationFilter
Expand Down Expand Up @@ -739,8 +769,17 @@ export type StudyViewFilter = {

'sampleTreatmentTargetFilters': AndedSampleTreatmentFilters

'structuralVariantFilters': Array < StudyViewStructuralVariantFilter >

'studyIds': Array < string >

};
export type StudyViewStructuralVariantFilter = {
'molecularProfileIds': Array < string >

'structVarQueries': Array < Array < StructuralVariantFilterQuery >
>

};
export type TypeOfCancer = {
'cancerTypeId': string
Expand Down
Loading

0 comments on commit 48669a1

Please sign in to comment.