diff --git a/end-to-end-test/local/specs/namespace-columns-in-cna-tables.spec.js b/end-to-end-test/local/specs/namespace-columns-in-cna-tables.spec.js index 383d30ba067..247bb3c57b1 100644 --- a/end-to-end-test/local/specs/namespace-columns-in-cna-tables.spec.js +++ b/end-to-end-test/local/specs/namespace-columns-in-cna-tables.spec.js @@ -2,6 +2,14 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, } = require('../../shared/specUtils'); +const { + namespaceColumnsAreNotDisplayed, + waitForTable, + clickColumnSelectionButton, + selectColumn, + namespaceColumnsAreDisplayed, + getRowByGene, +} = require('./namespace-columns-utils'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -45,39 +53,3 @@ describe('namespace columns in cna tables', function() { }); }); }); - -function clickColumnSelectionButton(patientCnaTable) { - $(`[data-test=${patientCnaTable}]`) - .$('button*=Columns') - .click(); -} - -function selectColumn(namespaceColumn1) { - $(`[data-id="${namespaceColumn1}"]`).click(); -} - -waitForMutationTable = () => { - $('[data-test=LazyMobXTable]').waitForDisplayed(); -}; - -waitForTable = table => { - $(`[data-test=${table}]`).waitForDisplayed(); -}; - -namespaceColumnsAreDisplayed = columns => { - for (const column of columns) { - if (!$(`//span[text()='${column}']`).isDisplayed()) { - return false; - } - } - return true; -}; - -namespaceColumnsAreNotDisplayed = columns => { - return !namespaceColumnsAreDisplayed(columns); -}; - -getRowByGene = (tableName, gene) => { - const tableRows = $$(`[data-test="${tableName}"] tr`); - return tableRows.find(r => r.$('td=' + gene).isExisting()); -}; diff --git a/end-to-end-test/local/specs/namespace-columns-in-mutation-tables.spec.js b/end-to-end-test/local/specs/namespace-columns-in-mutation-tables.spec.js index d88fee312ef..cba61c62198 100644 --- a/end-to-end-test/local/specs/namespace-columns-in-mutation-tables.spec.js +++ b/end-to-end-test/local/specs/namespace-columns-in-mutation-tables.spec.js @@ -2,6 +2,10 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, } = require('../../shared/specUtils'); +const { + namespaceColumnsAreNotDisplayed, + namespaceColumnsAreDisplayed, +} = require('./namespace-columns-utils'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const resultsViewUrl = `${CBIOPORTAL_URL}/results/mutations?cancer_study_list=study_es_0&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cfusion%2Cgistic&case_set_id=study_es_0_all&gene_list=BRCA1&geneset_list=%20&tab_index=tab_visualize&Action=Submit`; @@ -108,20 +112,6 @@ waitForPatientViewMutationTable = () => { $('[data-test=patientview-mutation-table]').waitForDisplayed(); }; -namespaceColumnsAreDisplayed = () => { - return ( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() - ); -}; - -namespaceColumnsAreNotDisplayed = () => { - return !( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() - ); -}; - filterIconOfHeader = selector => { return $(selector) .parentElement() diff --git a/end-to-end-test/local/specs/namespace-columns-in-struct-var-tables.spec.js b/end-to-end-test/local/specs/namespace-columns-in-struct-var-tables.spec.js new file mode 100644 index 00000000000..f4599925d14 --- /dev/null +++ b/end-to-end-test/local/specs/namespace-columns-in-struct-var-tables.spec.js @@ -0,0 +1,55 @@ +const assert = require('assert'); +const { + goToUrlAndSetLocalStorageWithProperty, +} = require('../../shared/specUtils'); +const { + namespaceColumnsAreNotDisplayed, + waitForTable, + clickColumnSelectionButton, + selectColumn, + namespaceColumnsAreDisplayed, + getRowByGene, +} = require('./namespace-columns-utils'); + +const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); + +describe('namespace columns in struct var tables', function() { + describe('patient view', () => { + const patientViewUrl = `${CBIOPORTAL_URL}/patient?studyId=study_es_0&caseId=TCGA-A2-A04P`; + const namespaceColumn1 = 'StructVarNs Column1'; + const namespaceValue1 = 'value1'; + const namespaceColumn2 = 'StructVarNs Column2'; + const namespaceValue2 = 'value2'; + const namespaceColumns = [namespaceColumn1, namespaceColumn2]; + const patientStructVarTable = 'patientview-structural-variant-table'; + const geneWithCustomNamespaceData = 'KIAA1549'; + + it('hides namespace columns when no property set', () => { + goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, {}); + waitForTable(patientStructVarTable); + assert(namespaceColumnsAreNotDisplayed(namespaceColumns)); + }); + + it('shows columns when column menu is used', () => { + clickColumnSelectionButton(patientStructVarTable); + selectColumn(namespaceColumn1); + selectColumn(namespaceColumn2); + clickColumnSelectionButton(patientStructVarTable); + assert(namespaceColumnsAreDisplayed(namespaceColumns)); + }); + + /** + * Expected custom namespace columns to be shown + */ + it('displays custom namespace data', () => { + const rowWithNamespaceData = getRowByGene( + patientStructVarTable, + geneWithCustomNamespaceData + ); + assert(!!rowWithNamespaceData); + const text = rowWithNamespaceData.getText(); + assert(text.includes(namespaceValue1)); + assert(text.includes(namespaceValue2)); + }); + }); +}); diff --git a/end-to-end-test/local/specs/namespace-columns-utils.js b/end-to-end-test/local/specs/namespace-columns-utils.js new file mode 100644 index 00000000000..fcad900a9d4 --- /dev/null +++ b/end-to-end-test/local/specs/namespace-columns-utils.js @@ -0,0 +1,40 @@ +function clickColumnSelectionButton(patientCnaTable) { + $(`[data-test=${patientCnaTable}]`) + .$('button*=Columns') + .click(); +} + +function selectColumn(namespaceColumn1) { + $(`[data-id="${namespaceColumn1}"]`).click(); +} + +waitForTable = table => { + $(`[data-test=${table}]`).waitForDisplayed(); +}; + +namespaceColumnsAreDisplayed = columns => { + for (const column of columns) { + if (!$(`//span[text()='${column}']`).isDisplayed()) { + return false; + } + } + return true; +}; + +namespaceColumnsAreNotDisplayed = columns => { + return !namespaceColumnsAreDisplayed(columns); +}; + +getRowByGene = (tableName, gene) => { + const tableRows = $$(`[data-test="${tableName}"] tr`); + return tableRows.find(r => r.$('td=' + gene).isExisting()); +}; + +module.exports = { + getRowByGene, + namespaceColumnsAreNotDisplayed, + namespaceColumnsAreDisplayed, + waitForTable, + selectColumn, + clickColumnSelectionButton, +}; diff --git a/src/pages/patientView/PatientViewPageTabs.tsx b/src/pages/patientView/PatientViewPageTabs.tsx index 523f2a107a7..e070f5dc2e7 100644 --- a/src/pages/patientView/PatientViewPageTabs.tsx +++ b/src/pages/patientView/PatientViewPageTabs.tsx @@ -339,6 +339,10 @@ export function tabs( ? sampleManager.getActiveSampleIdsInOrder() : [] } + namespaceColumns={ + pageComponent.patientViewPageStore.namespaceColumnConfig + .structVar + } />