diff --git a/end-to-end-test/local/specs/SurvivalChart.screenshot.spec.js b/end-to-end-test/local/specs/SurvivalChart.screenshot.spec.js index 21340dacc0c..2da024cce0c 100644 --- a/end-to-end-test/local/specs/SurvivalChart.screenshot.spec.js +++ b/end-to-end-test/local/specs/SurvivalChart.screenshot.spec.js @@ -1,54 +1,53 @@ -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForNetworkQuiet = require('../../shared/specUtils').waitForNetworkQuiet; -var openGroupComparison = require('../../shared/specUtils').openGroupComparison; -var assertScreenShotMatch = require('../../shared/lib/testUtils') - .assertScreenShotMatch; -var setInputText = require('../../shared/specUtils').setInputText; -var { - setDropdownOpen, - selectClinicalTabPlotType, - getElementByTestHandle, +const { assertScreenShotMatch } = require('../../shared/lib/testUtils'); +const { + openGroupComparison, + setInputText, setCheckboxChecked, -} = require('../../shared/specUtils'); + clickElement, + getElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('Screenshot test for extend survival chart (feature flag)', function() { this.retries(0); - before(function() { - openGroupComparison( + before(async function() { + await openGroupComparison( `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay&featureFlags=SURVIVAL_PLOT_EXTENDED`, 'chart-container-OS_STATUS', 100000 ); - $('.tabAnchor_survival').click(); - $('[data-test="ComparisonPageSurvivalTabDiv"]').waitForExist({ + await clickElement('.tabAnchor_survival'); + await getElement('[data-test="ComparisonPageSurvivalTabDiv"]', { timeout: 20000, }); }); - it('Survival chart with landmark event and hazard ratio disabled', function() { - var res = browser.checkElement('div[data-test=SurvivalChart]'); + it('Survival chart with landmark event and hazard ratio disabled', async () => { + const res = await browser.checkElement('div[data-test=SurvivalChart]'); assertScreenShotMatch(res); }); - it('Survival chart with landmark event at time point 20', function() { - setCheckboxChecked(true, 'input[data-test=landmarkLines]'); - setInputText('input[data-test=landmarkValues]', '20'); - var res = browser.checkElement('div[data-test=SurvivalChart]'); + it('Survival chart with landmark event at time point 20', async () => { + await setCheckboxChecked(true, 'input[data-test=landmarkLines]'); + await setInputText('input[data-test=landmarkValues]', '20'); + const res = await browser.checkElement('div[data-test=SurvivalChart]'); assertScreenShotMatch(res); }); - it('Survival chart with hazard ratio table', function() { - setCheckboxChecked(false, 'input[data-test=landmarkLines]'); - setCheckboxChecked(true, 'input[data-test=hazardRatioCheckbox]'); - var res = browser.checkElement('div[data-test=survivalTabView]'); + it('Survival chart with hazard ratio table', async () => { + await setCheckboxChecked(false, 'input[data-test=landmarkLines]'); + await setCheckboxChecked(true, 'input[data-test=hazardRatioCheckbox]'); + const res = await browser.checkElement( + 'div[data-test=survivalTabView]' + ); assertScreenShotMatch(res); }); - it('Survival chart with hazard ratio table and landmark line', function() { - setCheckboxChecked(true, 'input[data-test=landmarkLines]'); - setInputText('input[data-test=landmarkValues]', '20'); - setCheckboxChecked(true, 'input[data-test=hazardRatioCheckbox]'); - var res = browser.checkElement('div[data-test=survivalTabView]'); + it('Survival chart with hazard ratio table and landmark line', async () => { + await setCheckboxChecked(true, 'input[data-test=landmarkLines]'); + await setInputText('input[data-test=landmarkValues]', '20'); + await setCheckboxChecked(true, 'input[data-test=hazardRatioCheckbox]'); + const res = await browser.checkElement( + 'div[data-test=survivalTabView]' + ); assertScreenShotMatch(res); }); }); diff --git a/end-to-end-test/local/specs/annotation-filter-menu.spec.js b/end-to-end-test/local/specs/annotation-filter-menu.spec.js index b06f2a8a178..852a4e91e97 100644 --- a/end-to-end-test/local/specs/annotation-filter-menu.spec.js +++ b/end-to-end-test/local/specs/annotation-filter-menu.spec.js @@ -1,15 +1,17 @@ -var assert = require('assert'); +const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, -} = require('../../shared/specUtils'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; -var waitForStudyView = require('../../shared/specUtils').waitForStudyView; -var waitForComparisonTab = require('../../shared/specUtils') - .waitForComparisonTab; -var openAlterationTypeSelectionMenu = require('../../shared/specUtils') - .openAlterationTypeSelectionMenu; + goToUrlAndSetLocalStorage, + useExternalFrontend, + waitForStudyView, + waitForComparisonTab, + openAlterationTypeSelectionMenu, + getElement, + getNestedElement, + clickElement, + isDisplayed, + waitForElementDisplayed, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const studyViewUrl = `${CBIOPORTAL_URL}/study/summary?id=study_es_0`; @@ -36,36 +38,44 @@ const SV_COUNTS_SORT_DESC_10 = { describe('alteration filter menu', function() { describe('study view', () => { describe('filtering of gene tables', () => { - beforeEach(() => { - goToUrlAndSetLocalStorageWithProperty(studyViewUrl, true, { - /** - * Only use custom driver annotations from local db: - */ - show_oncokb: false, - }); - waitForStudyView(); - turnOffCancerGenesFilters(); - openAlterationFilterMenu(); + beforeEach(async () => { + await goToUrlAndSetLocalStorageWithProperty( + studyViewUrl, + true, + { + /** + * Only use custom driver annotations from local db: + */ + show_oncokb: false, + } + ); + await waitForStudyView(); + await turnOffCancerGenesFilters(); + await openAlterationFilterMenu(); }); // -+=+ MUTATION STATUS +=+- - it('filters mutation table when unchecking somatic checkbox', () => { - clickCheckBoxStudyView('Somatic'); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '6', - BRCA1: '1', - ATM: '1', - TP53: '1', - }); + it('filters mutation table when unchecking somatic checkbox', async () => { + await clickCheckBoxStudyView('Somatic'); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '6', + BRCA1: '1', + ATM: '1', + TP53: '1', + } + ); // somatic checkbox unchecked, filter structural variant table assert.strictEqual( - Object.keys(geneTableCounts('structural variants-table')) - .length, + Object.keys( + await geneTableCounts('structural variants-table') + ).length, 0 ); // does not filter cna table assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -85,33 +95,38 @@ describe('alteration filter menu', function() { ); }); - it('filters mutation table when unchecking germline checkbox', () => { - clickCheckBoxStudyView('Germline'); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '6', - ACP3: '5', - BRCA1: '4', - ATM: '1', - DTNB: '1', - ABLIM1: '1', - MSH3: '1', - MYB: '1', - TP53: '1', - PIEZO1: '1', - ADAMTS20: '1', - OR11H1: '1', - TMEM247: '1', - }); + it('filters mutation table when unchecking germline checkbox', async () => { + await clickCheckBoxStudyView('Germline'); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '6', + ACP3: '5', + BRCA1: '4', + ATM: '1', + DTNB: '1', + ABLIM1: '1', + MSH3: '1', + MYB: '1', + TP53: '1', + PIEZO1: '1', + ADAMTS20: '1', + OR11H1: '1', + TMEM247: '1', + } + ); // does not filter structural variant table // (sort and take top ten, as react does not render all rows) - sortPaneByCount('structural variants-table'); + await sortPaneByCount('structural variants-table'); assert.deepStrictEqual( - sortDescLimit(geneTableCounts('structural variants-table')), + sortDescLimit( + await geneTableCounts('structural variants-table') + ), SV_COUNTS_SORT_DESC_10 ); // does not filter cna table assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -131,38 +146,43 @@ describe('alteration filter menu', function() { ); }); - it('does not filter mutation table when unchecking unknown status checkbox', () => { + it('does not filter mutation table when unchecking unknown status checkbox', async () => { //NOTE this is failing because somatic status filtering appears not to // work on SVs where it once did // this is probably because SVs were mutations // it apparently regarded them as UNKNOWN, now they are KNOWN // FILL IN NUMBER OF SVs - $('[data-test=ShowUnknown]').click(); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '12', - ACP3: '5', - BRCA1: '5', - ATM: '2', - DTNB: '1', - ABLIM1: '1', - MSH3: '1', - MYB: '1', - TP53: '2', - PIEZO1: '1', - ADAMTS20: '1', - OR11H1: '1', - TMEM247: '1', - }); + await clickElement('[data-test=ShowUnknown]'); + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '12', + ACP3: '5', + BRCA1: '5', + ATM: '2', + DTNB: '1', + ABLIM1: '1', + MSH3: '1', + MYB: '1', + TP53: '2', + PIEZO1: '1', + ADAMTS20: '1', + OR11H1: '1', + TMEM247: '1', + } + ); // does not filter structural variant table // (take top ten, as react does not render all rows) assert.deepStrictEqual( - sortDescLimit(geneTableCounts('structural variants-table')), + sortDescLimit( + await geneTableCounts('structural variants-table') + ), SV_COUNTS_SORT_DESC_10 ); // does not filter cna table assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -183,24 +203,27 @@ describe('alteration filter menu', function() { }); // -+=+ DRIVER ANNOTATIONS +=+- - it('filters tables when unchecking driver checkbox', () => { - clickCheckBoxStudyView('Putative drivers'); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '12', - ACP3: '5', - BRCA1: '3', - PIEZO1: '1', - ATM: '2', - TP53: '2', - ADAMTS20: '1', - TMEM247: '1', - DTNB: '1', - MSH3: '1', - MYB: '1', - }); + it('filters tables when unchecking driver checkbox', async () => { + await clickCheckBoxStudyView('Putative drivers'); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '12', + ACP3: '5', + BRCA1: '3', + PIEZO1: '1', + ATM: '2', + TP53: '2', + ADAMTS20: '1', + TMEM247: '1', + DTNB: '1', + MSH3: '1', + MYB: '1', + } + ); assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { AURKAIP1_AMP: '7', ATAD3A_AMP: '7', @@ -220,23 +243,26 @@ describe('alteration filter menu', function() { ); }); - it('filters tables when unchecking passenger checkbox', () => { - clickCheckBoxStudyView('Putative passengers'); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '12', - ACP3: '5', - BRCA1: '4', - ATM: '2', - ABLIM1: '1', - TP53: '2', - ADAMTS20: '1', - OR11H1: '1', - }); + it('filters tables when unchecking passenger checkbox', async () => { + await clickCheckBoxStudyView('Putative passengers'); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '12', + ACP3: '5', + BRCA1: '4', + ATM: '2', + ABLIM1: '1', + TP53: '2', + ADAMTS20: '1', + OR11H1: '1', + } + ); // For Structural Variants: see custom-driver-annotations-in-study-view.spec.js assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -256,24 +282,27 @@ describe('alteration filter menu', function() { ); }); - it('filters tables when unchecking when unchecking unknown oncogenicity checkbox', () => { - $('[data-test=ShowUnknownOncogenicity]').click(); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA1: '3', - PIEZO1: '1', - DTNB: '1', - ABLIM1: '1', - MSH3: '1', - MYB: '1', - OR11H1: '1', - TMEM247: '1', - }); + it('filters tables when unchecking when unchecking unknown oncogenicity checkbox', async () => { + await clickElement('[data-test=ShowUnknownOncogenicity]'); + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA1: '3', + PIEZO1: '1', + DTNB: '1', + ABLIM1: '1', + MSH3: '1', + MYB: '1', + OR11H1: '1', + TMEM247: '1', + } + ); // For Structural Variants: see custom-driver-annotations-in-study-view.spec.js assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '1', ACAP3_AMP: '1', @@ -284,9 +313,9 @@ describe('alteration filter menu', function() { ); }); - it('filters structural variant tables when unchecking when unchecking somatic oncogenicity checkbox', () => { - $('[data-test=HideSomatic]').click(); - waitForStudyView(); + it('filters structural variant tables when unchecking when unchecking somatic oncogenicity checkbox', async () => { + await clickElement('[data-test=HideSomatic]'); + await waitForStudyView(); assert.strictEqual( Object.keys(geneTableCounts('structural variants-table')) .length, @@ -295,28 +324,31 @@ describe('alteration filter menu', function() { }); // -+=+ TIER ANNOTATIONS +=+- - it('does not filter tables when checking all tier checkboxes', () => { - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '12', - ACP3: '5', - BRCA1: '5', - ATM: '2', - DTNB: '1', - ABLIM1: '1', - MSH3: '1', - MYB: '1', - TP53: '2', - PIEZO1: '1', - ADAMTS20: '1', - OR11H1: '1', - TMEM247: '1', - }); + it('does not filter tables when checking all tier checkboxes', async () => { + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '12', + ACP3: '5', + BRCA1: '5', + ATM: '2', + DTNB: '1', + ABLIM1: '1', + MSH3: '1', + MYB: '1', + TP53: '2', + PIEZO1: '1', + ADAMTS20: '1', + OR11H1: '1', + TMEM247: '1', + } + ); // For Structural Variants: see custom-driver-annotations-in-study-view.spec.js assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -336,17 +368,20 @@ describe('alteration filter menu', function() { ); }); - it('filters tables when checking only Class 1 checkbox', () => { - selectTier('Class_1'); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA1: '3', - ABLIM1: '1', - DTNB: '1', - }); + it('filters tables when checking only Class 1 checkbox', async () => { + await selectTier('Class_1'); + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA1: '3', + ABLIM1: '1', + DTNB: '1', + } + ); assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ATAD3B_HOMDEL: '1', AGRN_AMP: '1', @@ -354,20 +389,23 @@ describe('alteration filter menu', function() { ); }); - it('filters tables when checking only Class 2 checkbox', () => { - selectTier('Class_2'); + it('filters tables when checking only Class 2 checkbox', async () => { + await selectTier('Class_2'); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - TMEM247: '1', - }); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + TMEM247: '1', + } + ); assert.deepStrictEqual( - geneTableCounts('structural variants-table'), + await geneTableCounts('structural variants-table'), { ALK: '1', EML4: '1' } ); assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ATAD3A_HOMDEL: '1', ACAP3_AMP: '1', @@ -375,36 +413,42 @@ describe('alteration filter menu', function() { ); }); - it('filters tables when checking only Class 3 checkbox', () => { - selectTier('Class_3'); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - MSH3: '1', - PIEZO1: '1', - }); + it('filters tables when checking only Class 3 checkbox', async () => { + await selectTier('Class_3'); + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + MSH3: '1', + PIEZO1: '1', + } + ); assert.deepStrictEqual( - geneTableCounts('structural variants-table'), + await geneTableCounts('structural variants-table'), { NCOA4: '1', RET: '1' } ); assert.strictEqual( Object.keys( - geneTableCounts('copy number alterations-table') + await geneTableCounts('copy number alterations-table') ).length, 0 ); }); - it('filters tables when checking only Class 4 checkbox', () => { - selectTier('Class_4'); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - ADAMTS20: '1', - }); + it('filters tables when checking only Class 4 checkbox', async () => { + await selectTier('Class_4'); + await waitForStudyView(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + ADAMTS20: '1', + } + ); assert.deepStrictEqual( - geneTableCounts('structural variants-table'), + await geneTableCounts('structural variants-table'), { KIAA1549: '1', BRAF: '1', @@ -415,29 +459,32 @@ describe('alteration filter menu', function() { assert.strictEqual( Object.keys( - geneTableCounts('copy number alterations-table') + await geneTableCounts('copy number alterations-table') ).length, 0 ); }); - it('filters tables when checking only unknown tier checkbox', () => { - selectTier('ShowUnknownTier'); - waitForStudyView(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '12', - ACP3: '5', - ATM: '2', - BRCA1: '2', - TP53: '2', - MYB: '1', - OR11H1: '1', - }); - - sortPaneByCount('structural variants-table'); + it('filters tables when checking only unknown tier checkbox', async () => { + await selectTier('ShowUnknownTier'); + await waitForStudyView(); assert.deepStrictEqual( - sortDescLimit( - geneTableCounts('structural variants-table'), + await geneTableCounts('mutations-table'), + { + BRCA2: '12', + ACP3: '5', + ATM: '2', + BRCA1: '2', + TP53: '2', + MYB: '1', + OR11H1: '1', + } + ); + + await sortPaneByCount('structural variants-table'); + assert.deepStrictEqual( + await sortDescLimit( + await geneTableCounts('structural variants-table'), 8 ), { @@ -452,7 +499,7 @@ describe('alteration filter menu', function() { } ); assert.deepStrictEqual( - geneTableCounts('copy number alterations-table'), + await geneTableCounts('copy number alterations-table'), { ERCC5_AMP: '7', AURKAIP1_AMP: '7', @@ -474,101 +521,122 @@ describe('alteration filter menu', function() { }); describe('filtering of study view samples', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(studyViewUrl, true); - waitForStudyView(); - turnOffCancerGenesFilters(); - openAlterationFilterMenu(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(studyViewUrl, true); + await waitForStudyView(); + await turnOffCancerGenesFilters(); + await openAlterationFilterMenu(); }); - it('adds breadcrumb text for mutations', () => { - clickCheckBoxStudyView('Somatic'); - clickCheckBoxStudyView('Putative passengers'); - $('[data-test=ToggleAllDriverTiers]').click(); - $('[data-test=ShowUnknownTier]').click(); - waitForStudyView(); - $('//*[@data-test="mutations-table"]') - .$('input') - .click(); - $('//*[@data-test="mutations-table"]') - .$('button=Select Samples') - .click(); - var sections = $('[data-test=groupedGeneFilterIcons]').$$( - 'div' - ); + it('adds breadcrumb text for mutations', async () => { + await clickCheckBoxStudyView('Somatic'); + await clickCheckBoxStudyView('Putative passengers'); + await clickElement('[data-test=ToggleAllDriverTiers]'); + await clickElement('[data-test=ShowUnknownTier]'); + await waitForStudyView(); + const element = await getNestedElement([ + '//*[@data-test="mutations-table"]', + 'input', + ]); + await element.click(); + await ( + await getNestedElement([ + '//*[@data-test="mutations-table"]', + 'button=Select Samples', + ]) + ).click(); + const sections = await ( + await getElement('[data-test=groupedGeneFilterIcons]') + ).$$('div'); assert.strictEqual( - sections[0].$$('span')[1].getText(), + await (await sections[0].$$('span'))[1].getText(), 'driver or unknown' ); assert.strictEqual( - sections[1].$$('span')[1].getText(), + await (await sections[1].$$('span'))[1].getText(), 'germline or unknown' ); assert.strictEqual( - sections[2].$$('span')[1].getText(), + await (await sections[2].$$('span'))[1].getText(), 'unknown' ); }); - it('adds breadcrumb text for cnas', () => { + it('adds breadcrumb text for cnas', async () => { // does not include the mutation status settings - clickCheckBoxStudyView('Somatic'); - clickCheckBoxStudyView('Putative drivers'); - $('//*[@data-test="copy number alterations-table"]') - .$('input') - .click(); - $('//*[@data-test="copy number alterations-table"]') - .$('button=Select Samples') - .click(); - var sections = $('[data-test=groupedGeneFilterIcons]').$$( - 'div' - ); + await clickCheckBoxStudyView('Somatic'); + await clickCheckBoxStudyView('Putative drivers'); + await ( + await getNestedElement([ + '//*[@data-test="copy number alterations-table"]', + 'input', + ]) + ).click(); + await ( + await getNestedElement([ + '//*[@data-test="copy number alterations-table"]', + 'button=Select Samples', + ]) + ).click(); + const sections = await ( + await getElement('[data-test=groupedGeneFilterIcons]') + ).$$('div'); assert.strictEqual(sections.length, 1); assert.strictEqual( - sections[0].$$('span')[1].getText(), + await (await sections[0].$$('span'))[1].getText(), 'passenger or unknown' ); }); - it('reduced samples in genes table', () => { - clickCheckBoxStudyView('Somatic'); - clickCheckBoxStudyView('Putative passengers'); - $('//*[@data-test="mutations-table"]') - .$$('input')[1] - .click(); // click ATM gene - $('//*[@data-test="mutations-table"]') - .$('button=Select Samples') - .click(); - assert.deepStrictEqual(geneTableCounts('mutations-table'), { - BRCA2: '1', - BRCA1: '1', - ATM: '1', - TP53: '1', - }); + it('reduced samples in genes table', async () => { + await clickCheckBoxStudyView('Somatic'); + await clickCheckBoxStudyView('Putative passengers'); + + await ( + await ( + await getElement('//*[@data-test="mutations-table"]') + ).$$('input') + )[1].click(); // click ATM gene + + await ( + await getNestedElement([ + '//*[@data-test="mutations-table"]', + 'button=Select Samples', + ]) + ).click(); + assert.deepStrictEqual( + await geneTableCounts('mutations-table'), + { + BRCA2: '1', + BRCA1: '1', + ATM: '1', + TP53: '1', + } + ); }); }); }); describe('group comparison - results view ', () => { - before(() => { - goToUrlAndSetLocalStorage(comparisonResultsViewUrl, true); - waitForComparisonTab(); + before(async () => { + await goToUrlAndSetLocalStorage(comparisonResultsViewUrl, true); + await waitForComparisonTab(); // turn off fusion and cna types - openAlterationTypeSelectionMenu(); - clickCheckBoxResultsView('Structural Variants / Fusions'); - clickCheckBoxResultsView('Copy Number Alterations'); - $('[data-test=buttonSelectAlterations]').click(); - waitForUpdateResultsView(); + await openAlterationTypeSelectionMenu(); + await clickCheckBoxResultsView('Structural Variants / Fusions'); + await clickCheckBoxResultsView('Copy Number Alterations'); + await clickElement('[data-test=buttonSelectAlterations]'); + await waitForUpdateResultsView(); - openAlterationFilterMenuGroupComparison(); + await openAlterationFilterMenuGroupComparison(); }); // -+=+ MUTATION STATUS +=+- - it('filters enrichment table when unchecking germline checkbox', () => { - waitForStudyView(); - clickCheckBoxResultsView('Germline'); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking germline checkbox', async () => { + await waitForStudyView(); + await clickCheckBoxResultsView('Germline'); + assert.deepStrictEqual(await enrichmentTableCounts(), { DTNB: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ADAMTS20: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, @@ -578,23 +646,23 @@ describe('alteration filter menu', function() { BRCA2: { alt: '0 (0.00%)', unalt: '6 (30.00%)' }, ACP3: { alt: '0 (0.00%)', unalt: '5 (22.73%)' }, }); - clickCheckBoxResultsView('Germline'); + await clickCheckBoxResultsView('Germline'); }); - it('filters enrichment table when unchecking somatic checkbox', () => { - clickCheckBoxResultsView('Somatic'); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking somatic checkbox', async () => { + await clickCheckBoxResultsView('Somatic'); + assert.deepStrictEqual(await enrichmentTableCounts(), { ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, BRCA1: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, BRCA2: { alt: '1 (100.00%)', unalt: '5 (25.00%)' }, }); - clickCheckBoxResultsView('Somatic'); + await clickCheckBoxResultsView('Somatic'); }); - it('filters enrichment table when unchecking unknown status checkbox', () => { - $('[data-test=ShowUnknown]').click(); - waitForUpdateResultsView(); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking unknown status checkbox', async () => { + await clickElement('[data-test=ShowUnknown]'); + await waitForUpdateResultsView(); + assert.deepStrictEqual(await enrichmentTableCounts(), { DTNB: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ADAMTS20: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, @@ -604,13 +672,13 @@ describe('alteration filter menu', function() { BRCA2: { alt: '1 (100.00%)', unalt: '11 (55.00%)' }, ACP3: { alt: '0 (0.00%)', unalt: '5 (22.73%)' }, }); - $('[data-test=ShowUnknown]').click(); + await clickElement('[data-test=ShowUnknown]'); }); // -+=+ DRIVER ANNOTATIONS +=+- - it('filters enrichment table when unchecking driver checkbox', () => { - clickCheckBoxResultsView('Putative drivers'); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking driver checkbox', async () => { + await clickCheckBoxResultsView('Putative drivers'); + assert.deepStrictEqual(await enrichmentTableCounts(), { DTNB: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ADAMTS20: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, @@ -619,12 +687,12 @@ describe('alteration filter menu', function() { BRCA2: { alt: '1 (100.00%)', unalt: '11 (55.00%)' }, ACP3: { alt: '0 (0.00%)', unalt: '5 (22.73%)' }, }); - clickCheckBoxResultsView('Putative drivers'); + await clickCheckBoxResultsView('Putative drivers'); }); - it('filters enrichment table when unchecking passenger checkbox', () => { - clickCheckBoxResultsView('Putative passengers'); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking passenger checkbox', async () => { + await clickCheckBoxResultsView('Putative passengers'); + assert.deepStrictEqual(await enrichmentTableCounts(), { ADAMTS20: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, BRCA1: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, @@ -632,23 +700,23 @@ describe('alteration filter menu', function() { BRCA2: { alt: '1 (100.00%)', unalt: '11 (55.00%)' }, ACP3: { alt: '0 (0.00%)', unalt: '5 (22.73%)' }, }); - clickCheckBoxResultsView('Putative passengers'); + await clickCheckBoxResultsView('Putative passengers'); }); - it('filters enrichment table when unchecking unknown oncogenicity checkbox', () => { - $('[data-test=ShowUnknownOncogenicity]').click(); - waitForUpdateResultsView(); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters enrichment table when unchecking unknown oncogenicity checkbox', async () => { + await clickElement('[data-test=ShowUnknownOncogenicity]'); + await waitForUpdateResultsView(); + assert.deepStrictEqual(await enrichmentTableCounts(), { DTNB: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, OR11H1: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, TMEM247: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, }); - $('[data-test=ShowUnknownOncogenicity]').click(); + await clickElement('[data-test=ShowUnknownOncogenicity]'); }); // -+=+ TIER ANNOTATIONS +=+- - it('does not filter tables when checking all tier checkboxes', () => { - assert.deepStrictEqual(enrichmentTableCounts(), { + it('does not filter tables when checking all tier checkboxes', async () => { + assert.deepStrictEqual(await enrichmentTableCounts(), { DTNB: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ADAMTS20: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, @@ -660,60 +728,62 @@ describe('alteration filter menu', function() { }); }); - it('filters tables when checking Class 2 checkbox', () => { + it('filters tables when checking Class 2 checkbox', async () => { // browser.pause(1000_000_000) - selectTier('Class_2'); - waitForUpdateResultsView(); - assert.deepStrictEqual(enrichmentTableCounts(), { + await selectTier('Class_2'); + await waitForUpdateResultsView(); + assert.deepStrictEqual(await enrichmentTableCounts(), { TMEM247: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, }); - $('[data-test=Class_2]').click(); + await clickElement('[data-test=Class_2]'); }); - it('filters tables when checking unknown tier checkbox', () => { - $('[data-test=ShowUnknownTier]').click(); - waitForUpdateResultsView(); - assert.deepStrictEqual(enrichmentTableCounts(), { + it('filters tables when checking unknown tier checkbox', async () => { + await clickElement('[data-test=ShowUnknownTier]'); + await waitForUpdateResultsView(); + assert.deepStrictEqual(await enrichmentTableCounts(), { ATM: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, BRCA1: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, OR11H1: { alt: '1 (100.00%)', unalt: '0 (0.00%)' }, BRCA2: { alt: '1 (100.00%)', unalt: '11 (55.00%)' }, ACP3: { alt: '0 (0.00%)', unalt: '5 (22.73%)' }, }); - $('[data-test=ShowUnknownTier]').click(); + clickElement('[data-test=ShowUnknownTier]'); }); }); }); -function selectTier(tier) { - const $toggleAllTiers = $('[data-test=ToggleAllDriverTiers]'); - $toggleAllTiers.waitForExist(); - $toggleAllTiers.waitForClickable(); - $toggleAllTiers.click(); - const $tier = $(`[data-test=${tier}]`); - $tier.waitForExist(); - $tier.waitForDisplayed(); - $tier.waitForClickable(); - $tier.click(); +async function selectTier(tier) { + const $toggleAllTiers = await getElement( + '[data-test=ToggleAllDriverTiers]' + ); + await $toggleAllTiers.waitForExist(); + await $toggleAllTiers.waitForClickable(); + await $toggleAllTiers.click(); + const $tier = await getElement(`[data-test=${tier}]`); + await $tier.waitForExist(); + await $tier.waitForDisplayed(); + await $tier.waitForClickable(); + await $tier.click(); } -function sortPaneByCount(pane) { - $('//*[@data-test="' + pane + '"]') - .$('span=#') - .click(); - waitForStudyView(); +async function sortPaneByCount(pane) { + await ( + await (await getElement('//*[@data-test="' + pane + '"]')).$('span=#') + ).click(); + await waitForStudyView(); } -var clickCheckBoxStudyView = name => { - const checkboxContainer = $('label=' + name); - checkboxContainer.waitForDisplayed(); - const checkboxField = checkboxContainer.$('input'); - checkboxField.waitForDisplayed(); - checkboxField.click(); - waitForStudyView(); +const clickCheckBoxStudyView = async name => { + const checkboxContainer = await getElement('label=' + name); + await checkboxContainer.waitForDisplayed(); + const checkboxField = await checkboxContainer.$('input'); + await checkboxField.waitForDisplayed(); + await checkboxField.click(); + await waitForStudyView(); }; -var sortDescLimit = (entryCounts, limit = 10) => { +const sortDescLimit = (entryCounts, limit = 10) => { return Object.fromEntries( Object.entries(entryCounts) .sort((e1, e2) => e1[1] < e2[1]) @@ -721,53 +791,64 @@ var sortDescLimit = (entryCounts, limit = 10) => { ); }; -var clickCheckBoxResultsView = name => { - const $el = $('label=' + name).$('input'); - $el.waitForExist(); - $el.waitForDisplayed(); - $el.waitForClickable(); - $el.click(); - waitForUpdateResultsView(); +const clickCheckBoxResultsView = async name => { + const $el = await getNestedElement(['label=' + name, 'input']); + await $el.waitForExist(); + await $el.waitForDisplayed(); + await $el.waitForClickable(); + await $el.click(); + await waitForUpdateResultsView(); }; -var geneTableCounts = dataTest => { - var fieldName = +const geneTableCounts = async dataTest => { + const fieldName = dataTest === 'copy number alterations-table' ? 'numberOfAlteredCasesText' : 'numberOfAlterations'; - var geneCells = $('//*[@data-test="' + dataTest + '"]').$$( - '[data-test=geneNameCell]' + const geneCells = await ( + await getElement('//*[@data-test="' + dataTest + '"]') + ).$$('[data-test=geneNameCell]'); + const geneNames = await Promise.all( + geneCells.map(async c => (await c.$('div')).getText()) ); - var geneNames = geneCells.map(c => c.$('div').getText()); - var countCells = $('//*[@data-test="' + dataTest + '"]').$$( + const countCells = await (await $('//*[@data-test="' + dataTest + '"]')).$$( '[data-test=' + fieldName + ']' ); - var geneCounts = countCells.map(c => c.getText()); - var cnaCells = $('//*[@data-test="' + dataTest + '"]').$$( - '[data-test=cnaCell]' - ); - var cnas = cnaCells.map(c => c.getText()); + const geneCounts = await Promise.all(countCells.map(c => c.getText())); + const cnaCells = await ( + await getElement('//*[@data-test="' + dataTest + '"]') + ).$$('[data-test=cnaCell]'); + const cnas = await Promise.all(cnaCells.map(async c => await c.getText())); return geneNames.reduce((obj, geneName, index) => { - var suffix = ''; + let suffix = ''; if (cnas.length > 0) suffix = '_' + cnas[index]; - var key = geneName + suffix; + const key = geneName + suffix; return { ...obj, [key]: geneCounts[index] }; }, {}); }; -var enrichmentTableCounts = () => { - var rows = $('[data-test=LazyMobXTable]') - .$('tbody') - .$$('tr'); - var geneNames = rows.map(r => - r.$('span[data-test=geneNameCell]').getText() +const enrichmentTableCounts = async () => { + const tbody = await getNestedElement([ + '[data-test=LazyMobXTable]', + 'tbody', + ]); + const rows = await tbody.$$('tr'); + const geneNames = await Promise.all( + rows.map( + async r => + await (await r.$('span[data-test=geneNameCell]')).getText() + ) ); - var alteredCounts = $$('//*[@data-test="Altered group-CountCell"]').map(r => - r.getText() + const alteredCounts = await Promise.all( + (await $$('//*[@data-test="Altered group-CountCell"]')).map( + async r => await r.getText() + ) + ); + const unalteredCounts = await Promise.all( + (await $$('//*[@data-test="Unaltered group-CountCell"]')).map( + async r => await r.getText() + ) ); - var unalteredCounts = $$( - '//*[@data-test="Unaltered group-CountCell"]' - ).map(r => r.getText()); return geneNames.reduce((obj, geneName, index) => { return { ...obj, @@ -779,27 +860,35 @@ var enrichmentTableCounts = () => { }, {}); }; -var waitForUpdateResultsView = () => { - $('[data-test=LazyMobXTable]').waitForDisplayed(); +const waitForUpdateResultsView = async () => { + await waitForElementDisplayed('[data-test=LazyMobXTable]'); }; -var turnOffCancerGenesFilters = () => { - const activeFilterIcons = $$( +const turnOffCancerGenesFilters = async () => { + const activeFilterIcons = await $$( '[data-test=gene-column-header] [data-test=header-filter-icon]' - ).filter(e => e.getCSSProperty('color').value === 'rgba(0,0,0,1)'); - activeFilterIcons.forEach(i => i.click()); + ); + for (const icon of activeFilterIcons) { + if ((await icon.getCSSProperty('color').value) === 'rgba(0,0,0,1)') { + await icon.click(); + } + } }; -var openAlterationFilterMenu = () => { - $('[data-test=AlterationFilterButton]').waitForDisplayed(); - $('[data-test=AlterationFilterButton]').click(); - $('[data-test=GlobalSettingsDropdown] input').waitForDisplayed(); +const openAlterationFilterMenu = async () => { + await (await $('[data-test=AlterationFilterButton]')).waitForDisplayed(); + await (await $('[data-test=AlterationFilterButton]')).click(); + await ( + await $('[data-test=GlobalSettingsDropdown] input') + ).waitForDisplayed(); }; -var openAlterationFilterMenuGroupComparison = () => { - $( +const openAlterationFilterMenuGroupComparison = async () => { + await waitForElementDisplayed( '[data-test=AlterationEnrichmentAnnotationsSelectorButton]' - ).waitForDisplayed(); - $('[data-test=AlterationEnrichmentAnnotationsSelectorButton]').click(); - $('[data-test=GlobalSettingsDropdown] input').waitForDisplayed(); + ); + await clickElement( + '[data-test=AlterationEnrichmentAnnotationsSelectorButton]' + ); + await waitForElementDisplayed('[data-test=GlobalSettingsDropdown] input'); }; diff --git a/end-to-end-test/local/specs/core/comparison-alterations-tab.spec.js b/end-to-end-test/local/specs/core/comparison-alterations-tab.spec.js index d7198d31ad0..06e42183321 100644 --- a/end-to-end-test/local/specs/core/comparison-alterations-tab.spec.js +++ b/end-to-end-test/local/specs/core/comparison-alterations-tab.spec.js @@ -1,116 +1,112 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../../shared/specUtils') - .useExternalFrontend; -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; -var selectReactSelectOption = require('../../../shared/specUtils') - .selectReactSelectOption; -var waitForNetworkQuiet = require('../../../shared/specUtils') - .waitForNetworkQuiet; -var openAlterationTypeSelectionMenu = require('../../../shared/specUtils') - .openAlterationTypeSelectionMenu; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + selectReactSelectOption, + waitForNetworkQuiet, + useExternalFrontend, + openAlterationTypeSelectionMenu, + getNestedElement, + clickElement, + getElement, + isDisplayed, + waitForElementDisplayed, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const resultsViewComparisonTab = `${CBIOPORTAL_URL}/results/comparison?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=BRCA1%2520BRCA2&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize&comparison_subtab=alterations`; -describe('comparison alterations tab', function() { - beforeEach(() => { - loadAlterationsTab(); - openAlterationTypeSelectionMenu(); +describe('comparison alterations tab', () => { + beforeEach(async () => { + await loadAlterationsTab(); + await openAlterationTypeSelectionMenu(); }); - it('shows basic counts', function() { - var alteredCount = selectAlteredCount('ABLIM1'); + it('shows basic counts', async () => { + const alteredCount = await selectAlteredCount('ABLIM1'); assert.strictEqual(selectAlteredCount('ABLIM1'), '1 (8.33%)'); }); - it('shows banner when no results retrieved', function() { - clickAlterationTypeCheckBox('Mutations'); - clickAlterationTypeCheckBox('Structural Variants / Fusions'); - clickAlterationTypeCheckBox('Copy Number Alterations'); - $('[data-test=buttonSelectAlterations]').click(); - $('div=No data/result available').waitForExist(); - assert($('div=No data/result available').isDisplayed()); + it('shows banner when no results retrieved', async () => { + await clickAlterationTypeCheckBox('Mutations'); + await clickAlterationTypeCheckBox('Structural Variants / Fusions'); + await clickAlterationTypeCheckBox('Copy Number Alterations'); + await clickElement('[data-test=buttonSelectAlterations]'); + await getElement('div=No data/result available', { + waitForExist: true, + }); + assert(await isDisplayed('div=No data/result available')); }); - it('filters mutation types', function() { - clickAlterationTypeCheckBox('Copy Number Alterations'); - clickAlterationTypeCheckBox('Structural Variants / Fusions'); - submitEnrichmentRequest(); - $('[data-test=LazyMobXTable]').waitForDisplayed(); - var rows = $$('[data-test=LazyMobXTable] tbody tr'); + it('filters mutation types', async () => { + await clickAlterationTypeCheckBox('Copy Number Alterations'); + await clickAlterationTypeCheckBox('Structural Variants / Fusions'); + await submitEnrichmentRequest(); + await waitForElementDisplayed('[data-test=LazyMobXTable]'); + const rows = await $$('[data-test=LazyMobXTable] tbody tr'); assert.strictEqual(rows.length, 8, 'table has 8 rows'); - clickAlterationTypeCheckBox('Mutations'); - clickAlterationTypeCheckBox('Frameshift Deletion'); - submitEnrichmentRequest(); - $('[data-test=LazyMobXTable]').waitForDisplayed(); - rows = $$('[data-test=LazyMobXTable] tbody tr'); + await clickAlterationTypeCheckBox('Mutations'); + await clickAlterationTypeCheckBox('Frameshift Deletion'); + await submitEnrichmentRequest(); + await waitForElementDisplayed('[data-test=LazyMobXTable]'); + rows = await $$('[data-test=LazyMobXTable] tbody tr'); assert.strictEqual(rows.length, 2, 'table has 2 rows'); }); - it('filters CNA types', function() { - clickAlterationTypeCheckBox('Mutations'); - clickAlterationTypeCheckBox('Structural Variants / Fusions'); + it('filters CNA types', async () => { + await clickAlterationTypeCheckBox('Mutations'); + await clickAlterationTypeCheckBox('Structural Variants / Fusions'); - submitEnrichmentRequest(); - $('[data-test=LazyMobXTable]').waitForDisplayed(); - assert.strictEqual(selectUnalteredCount('ACAP3'), '9 (1.16%)'); + await submitEnrichmentRequest(); + await waitForElementDisplayed('[data-test=LazyMobXTable]'); + assert.strictEqual(await selectUnalteredCount('ACAP3'), '9 (1.16%)'); - clickAlterationTypeCheckBox('Deletion'); - submitEnrichmentRequest(); - $('[data-test=LazyMobXTable]').waitForDisplayed(); - assert.strictEqual(selectUnalteredCount('ACAP3'), '7 (0.90%)'); + await clickAlterationTypeCheckBox('Deletion'); + await submitEnrichmentRequest(); + await waitForElementDisplayed('[data-test=LazyMobXTable]'); + assert.strictEqual(await selectUnalteredCount('ACAP3'), '7 (0.90%)'); }); }); // The loading of the tabs in comparison view is extremely fragile. // Multiple loading attempts are needed in some cases to show the // enrichment panels and make the tests pass reliably. -var loadAlterationsTab = () => { - var timeIntervals = [3000, 4000, 5000, 5000, 10000, 30000, 100000]; +const loadAlterationsTab = async () => { + const timeIntervals = [3000, 4000, 5000, 5000, 10000, 30000, 100000]; for (const timeInterval of timeIntervals) { - goToUrlAndSetLocalStorage(resultsViewComparisonTab, true); - browser.pause(timeInterval); - if ($('[data-test=GroupComparisonAlterationEnrichments]').isDisplayed()) + await goToUrlAndSetLocalStorage(resultsViewComparisonTab, true); + await browser.pause(timeInterval); + if ( + await isDisplayed( + '[data-test=GroupComparisonAlterationEnrichments]' + ) + ) break; } }; -var selectAlteredCount = genename => { - var row = $(`span=${genename}`) - .$('..') - .$('..') - .$('..'); - var alteredCount = row - .$$('td')[2] - .$('span') - .getText(); +const selectAlteredCount = async genename => { + const row = await getNestedElement([`span=${genename}`, '..', '..', '..']); + const alteredCount = await ( + await await (await row.$$('td')[2]).$('span') + ).getText(); return alteredCount; }; -var selectUnalteredCount = genename => { - var row = $(`span=${genename}`) - .$('..') - .$('..') - .$('..'); - var alteredCount = row - .$$('td')[3] - .$('span') - .getText(); +const selectUnalteredCount = async genename => { + const row = await getNestedElement([`span=${genename}`, '..', '..', '..']); + const alteredCount = await ( + await await (await row.$$('td')[3]).$('span') + ).getText(); return alteredCount; }; -var clickAlterationTypeCheckBox = name => { - $('label=' + name) - .$('input') - .click(); +const clickAlterationTypeCheckBox = async name => { + await (await getNestedElement(['label=' + name, 'input'])).click(); }; -var submitEnrichmentRequest = () => { - $('[data-test=buttonSelectAlterations]').click(); - $('[data-test=GroupComparisonAlterationEnrichments]').waitForExist({ - timeout: 10000, +const submitEnrichmentRequest = async () => { + await clickElement('[data-test=buttonSelectAlterations]'); + await getElement('[data-test=GroupComparisonAlterationEnrichments]', { + waitForExist: true, }); }; diff --git a/end-to-end-test/local/specs/core/comparisonTab.screenshot.spec.js b/end-to-end-test/local/specs/core/comparisonTab.screenshot.spec.js index 12969eaba87..d7617f78d17 100644 --- a/end-to-end-test/local/specs/core/comparisonTab.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/comparisonTab.screenshot.spec.js @@ -1,30 +1,33 @@ -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForNetworkQuiet = require('../../../shared/specUtils') - .waitForNetworkQuiet; -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; -var setInputText = require('../../../shared/specUtils').setInputText; - -var { setDropdownOpen } = require('../../../shared/specUtils'); +const { + goToUrlAndSetLocalStorage, + waitForNetworkQuiet, + assertScreenShotMatch, + setInputText, + setDropdownOpen, + getElement, + clickElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('results view comparison tab screenshot tests', function() { describe('general screenshot tests', function() { - before(function() { - goToUrlAndSetLocalStorage( + before(async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TOPAZ1%2520ANK1%2520ACAN%2520INTS4&geneset_list=%20&tab_index=tab_visualize&Action=Submit&comparison_subtab=alterations&comparison_selectedGroups=%5B"TOPAZ1"%2C"ANK1"%2C"ACAN"%2C"INTS4"%5D`, true ); - $('[data-test=GroupComparisonAlterationEnrichments]').waitForExist({ - timeout: 20000, - }); + await getElement( + '[data-test=GroupComparisonAlterationEnrichments]', + { + timeout: 20000, + } + ); }); - it('results view comparison tab alteration enrichments several groups', function() { - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + it('results view comparison tab alteration enrichments several groups', async function() { + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -34,15 +37,18 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments patient mode', function() { - browser.execute(function() { + it('results view comparison tab alteration enrichments patient mode', async function() { + await browser.execute(function() { comparisonTab.store.setUsePatientLevelEnrichments(true); }); - $('[data-test=GroupComparisonAlterationEnrichments]').waitForExist({ - timeout: 20000, - }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await getElement( + '[data-test=GroupComparisonAlterationEnrichments]', + { + timeout: 20000, + } + ); + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -52,21 +58,23 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments 2 genes with highest frequency in any group', function() { - browser.execute(function() { + it('results view comparison tab alteration enrichments 2 genes with highest frequency in any group', async function() { + await browser.execute(function() { comparisonTab.store.setUsePatientLevelEnrichments(false); }); - openGeneSelectorMenu(); - $('input[data-test=numberOfGenes]').setValue('2\n'); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await openGeneSelectorMenu(); + await setInputText('input[data-test=numberOfGenes]', '2\n'); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 30000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForExist({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await getElement('div[data-test="GeneBarPlotDiv"]', { timeout: 30000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -76,23 +84,25 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments gene box highest average frequency', function() { - openGeneSelectorMenu(); - browser.execute(function() { + it('results view comparison tab alteration enrichments gene box highest average frequency', async function() { + await openGeneSelectorMenu(); + await browser.execute(function() { genesSelection.onGeneListOptionChange({ label: 'Genes with highest average frequency', }); }); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await waitForNetworkQuiet(); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 30000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForExist({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await getElement('div[data-test="GeneBarPlotDiv"]', { timeout: 30000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -102,23 +112,23 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments gene box most significant pValues', function() { - openGeneSelectorMenu(); - browser.execute(function() { + it('results view comparison tab alteration enrichments gene box most significant pValues', async function() { + await openGeneSelectorMenu(); + await browser.execute(function() { genesSelection.onGeneListOptionChange({ label: 'Genes with most significant p-value', }); }); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await waitForNetworkQuiet(); + await getElement('[data-test="addGenestoBarPlot"]').waitForEnabled({ timeout: 30000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForExist({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await getElement('div[data-test="GeneBarPlotDiv"]', { timeout: 30000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -128,19 +138,21 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments gene box user-defined genes', function() { - openGeneSelectorMenu(); - setInputText('textarea[data-test="geneSet"]', 'TP53'); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + it('results view comparison tab alteration enrichments gene box user-defined genes', async function() { + await openGeneSelectorMenu(); + await setInputText('textarea[data-test="geneSet"]', 'TP53'); + await waitForNetworkQuiet(); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 30000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForExist({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await getElement('div[data-test="GeneBarPlotDiv"]', { timeout: 30000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -150,16 +162,19 @@ describe('results view comparison tab screenshot tests', function() { assertScreenShotMatch(res); }); - it('results view comparison tab alteration enrichments two groups', function() { - goToUrlAndSetLocalStorage( + it('results view comparison tab alteration enrichments two groups', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TOPAZ1%2520ANK1%2520ACAN%2520INTS4&geneset_list=%20&tab_index=tab_visualize&Action=Submit&comparison_subtab=alterations&comparison_selectedGroups=%5B"ACAN"%2C"INTS4"%5D`, true ); - $('[data-test=GroupComparisonAlterationEnrichments]').waitForExist({ - timeout: 20000, - }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await getElement( + '[data-test=GroupComparisonAlterationEnrichments]', + { + timeout: 20000, + } + ); + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -171,8 +186,8 @@ describe('results view comparison tab screenshot tests', function() { }); }); -function openGeneSelectorMenu() { - setDropdownOpen( +async function openGeneSelectorMenu() { + await setDropdownOpen( true, '[data-test="selectGenes"]', 'input[data-test=numberOfGenes]' diff --git a/end-to-end-test/local/specs/core/groupComparison.screenshot.spec.js b/end-to-end-test/local/specs/core/groupComparison.screenshot.spec.js index 65186d04515..2d8b1792efc 100644 --- a/end-to-end-test/local/specs/core/groupComparison.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/groupComparison.screenshot.spec.js @@ -1,13 +1,15 @@ -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') +const goToUrlAndSetLocalStorage = require('../../../shared/specUtils_Async') .goToUrlAndSetLocalStorage; -var waitForNetworkQuiet = require('../../../shared/specUtils') - .waitForNetworkQuiet; -var openGroupComparison = require('../../../shared/specUtils') - .openGroupComparison; -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; -var setInputText = require('../../../shared/specUtils').setInputText; -var { +const { + openGroupComparison, + assertScreenShotMatch, + setInputText, + waitForNetworkQuiet, + clickElement, + getElement, + waitForElementDisplayed, +} = require('../../../shared/specUtils_Async'); +const { setDropdownOpen, selectClinicalTabPlotType, getElementByTestHandle, @@ -20,21 +22,22 @@ describe('group comparison page screenshot tests', function() { describe('Alteration enrichments tab', function() { this.retries(0); - before(function() { - openGroupComparison( + before(async function() { + await openGroupComparison( `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`, 'chart-container-ONCOTREE_CODE', 10000 ); - $('.tabAnchor_alterations').click(); - $( - '[data-test="GroupComparisonAlterationEnrichments"]' - ).waitForExist({ timeout: 20000 }); + await clickElement('.tabAnchor_alterations'); + await getElement( + '[data-test="GroupComparisonAlterationEnrichments"]', + { timeout: 20000 } + ); }); - it('group comparison page alteration enrichments tab several groups', function() { - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + it('group comparison page alteration enrichments tab several groups', async function() { + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -44,15 +47,16 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison page alteration enrichments tab patient mode', function() { - browser.execute(function() { + it('group comparison page alteration enrichments tab patient mode', async function() { + await browser.execute(function() { groupComparisonStore.setUsePatientLevelEnrichments(true); }); - $( - '[data-test="GroupComparisonAlterationEnrichments"]' - ).waitForExist({ timeout: 20000 }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await getElement( + '[data-test="GroupComparisonAlterationEnrichments"]', + { timeout: 20000 } + ); + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -62,21 +66,25 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison page alteration enrichments tab 2 genes with highest frequency in any group', function() { - browser.execute(function() { + it('group comparison page alteration enrichments tab 2 genes with highest frequency in any group', async function() { + await browser.execute(function() { groupComparisonStore.setUsePatientLevelEnrichments(false); }); - openGeneSelectorMenu(); - $('input[data-test=numberOfGenes]').setValue('2\n'); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await openGeneSelectorMenu(); + await (await getElement('input[data-test=numberOfGenes]')).setValue( + '2\n' + ); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 10000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForDisplayed({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await waitForElementDisplayed('div[data-test="GeneBarPlotDiv"]', { timeout: 10000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -86,23 +94,25 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison page alteration enrichments tab gene box highest average frequency', function() { - openGeneSelectorMenu(); - browser.execute(function() { + it('group comparison page alteration enrichments tab gene box highest average frequency', async function() { + await openGeneSelectorMenu(); + await browser.execute(function() { genesSelection.onGeneListOptionChange({ label: 'Genes with highest average frequency', }); }); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await waitForNetworkQuiet(); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 10000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForDisplayed({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await waitForElementDisplayed('div[data-test="GeneBarPlotDiv"]', { timeout: 10000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -112,23 +122,27 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison page alteration enrichments tab gene box most significant pValues', function() { - openGeneSelectorMenu(); - browser.execute(function() { + it('group comparison page alteration enrichments tab gene box most significant pValues', async function() { + await openGeneSelectorMenu(); + await browser.execute(function() { genesSelection.onGeneListOptionChange({ label: 'Genes with most significant p-value', }); }); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + await waitForNetworkQuiet(); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 10000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForDisplayed({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await ( + await getElement('div[data-test="GeneBarPlotDiv"]') + ).waitForDisplayed({ timeout: 10000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = await browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -138,19 +152,23 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison page alteration enrichments tab gene box user-defined genes', function() { - openGeneSelectorMenu(); - setInputText('textarea[data-test="geneSet"]', 'TP53'); - waitForNetworkQuiet(); - $('[data-test="addGenestoBarPlot"]').waitForEnabled({ + it('group comparison page alteration enrichments tab gene box user-defined genes', async function() { + await openGeneSelectorMenu(); + await setInputText('textarea[data-test="geneSet"]', 'TP53'); + await waitForNetworkQuiet(); + await ( + await getElement('[data-test="addGenestoBarPlot"]') + ).waitForEnabled({ timeout: 10000, }); - $('[data-test="addGenestoBarPlot"]').click(); - $('div[data-test="GeneBarPlotDiv"]').waitForDisplayed({ + await clickElement('[data-test="addGenestoBarPlot"]'); + await ( + await getElement('div[data-test="GeneBarPlotDiv"]') + ).waitForDisplayed({ timeout: 10000, }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( 'div[data-test="GeneBarPlotDiv"]', '', { @@ -160,19 +178,26 @@ describe('group comparison page screenshot tests', function() { assertScreenShotMatch(res); }); - it('group comparison alteration enrichments two groups', function() { + it('group comparison alteration enrichments two groups', async function() { // this test will not work on retry because groups will be toggled back on this.retries(0); - getElementByTestHandle('groupSelectorButtonGB').click(); - getElementByTestHandle('groupSelectorButtonOAST').click(); - getElementByTestHandle('groupSelectorButtonODG').click(); + await ( + await getElementByTestHandle('groupSelectorButtonGB') + ).click(); + await ( + await getElementByTestHandle('groupSelectorButtonOAST') + ).click(); + await ( + await getElementByTestHandle('groupSelectorButtonODG') + ).click(); - $( - '[data-test="GroupComparisonAlterationEnrichments"]' - ).waitForExist({ timeout: 20000 }); - $('body').moveTo({ xOffset: 0, yOffset: 0 }); - var res = browser.checkElement( + await getElement( + '[data-test="GroupComparisonAlterationEnrichments"]', + { timeout: 20000 } + ); + await (await getElement('body')).moveTo({ xOffset: 0, yOffset: 0 }); + const res = browser.checkElement( '.msk-tab:not(.hiddenByPosition)', '', { @@ -184,74 +209,74 @@ describe('group comparison page screenshot tests', function() { }); describe('Clinical tab', () => { - before(function() { - openGroupComparison( + before(async function() { + await openGroupComparison( `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`, 'chart-container-ONCOTREE_CODE', 10000 ); - $('.tabAnchor_clinical').click(); - $('[data-test="ComparisonPageClinicalTabDiv"]').waitForExist({ + await clickElement('.tabAnchor_clinical'); + await getElement('[data-test="ComparisonPageClinicalTabDiv"]', { timeout: 20000, }); }); - it('shows box plot for numerical data', () => { - $('[data-test="Mutation Count"]').click(); + it('shows box plot for numerical data', async () => { + await clickElement('[data-test="Mutation Count"]'); const res = checkClinicalTabPlot(); assertScreenShotMatch(res); }); - it('shows table when selecting table visualisation', () => { - $('[data-test="Mutation Count"]').click(); - selectClinicalTabNumericalDisplayType('Table'); - const res = checkClinicalTabPlot(); + it('shows table when selecting table visualisation', async () => { + await clickElement('[data-test="Mutation Count"]'); + await selectClinicalTabNumericalDisplayType('Table'); + const res = await checkClinicalTabPlot(); assertScreenShotMatch(res); }); - it('displays 100 percent stacked bar chart for categorical data', () => { - $('[data-test="Oncotree Code"]').click(); - var res = checkClinicalTabPlot(); + it('displays 100 percent stacked bar chart for categorical data', async () => { + await clickElement('[data-test="Oncotree Code"]'); + const res = await checkClinicalTabPlot(); assertScreenShotMatch(res); }); - it('displays heatmap when picked from categorical plot type dropdown', () => { - $('[data-test="Oncotree Code"]').click(); - selectClinicalTabPlotType('Heatmap'); + it('displays heatmap when picked from categorical plot type dropdown', async () => { + await clickElement('[data-test="Oncotree Code"]'); + await selectClinicalTabPlotType('Heatmap'); - var res = checkClinicalTabPlot(); + const res = await checkClinicalTabPlot(); assertScreenShotMatch(res); }); }); }); -function openGeneSelectorMenu() { - setDropdownOpen( +async function openGeneSelectorMenu() { + await setDropdownOpen( true, '[data-test="selectGenes"]', 'input[data-test=numberOfGenes]' ); } -function checkClinicalTabPlot() { +async function checkClinicalTabPlot() { return browser.checkElement('div[data-test="ClinicalTabPlotDiv"]', '', { hide: ['.qtip'], }); } -function selectClinicalTabNumericalDisplayType(type) { - setDropdownOpen( +async function selectClinicalTabNumericalDisplayType(type) { + await setDropdownOpen( true, '[data-test="numericalVisualisationTypeSelector"] .Select-arrow-zone', '[data-test="numericalVisualisationTypeSelector"] .Select-menu', "Couldn't open clinical tab chart type dropdown" ); - $( + await clickElement( `[data-test="numericalVisualisationTypeSelector"] .Select-option[aria-label="${type}"]` - ).click(); + ); } -function checkClinicalTabPlot() { +async function checkClinicalTabPlot() { return browser.checkElement('div[data-test="ClinicalTabPlotDiv"]', '', { hide: ['.qtip'], }); diff --git a/end-to-end-test/local/specs/core/oncoprint.screenshot.spec.js b/end-to-end-test/local/specs/core/oncoprint.screenshot.spec.js index 58ecefc5a41..2f610ad65f9 100644 --- a/end-to-end-test/local/specs/core/oncoprint.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/oncoprint.screenshot.spec.js @@ -1,16 +1,17 @@ -var { +const { goToUrlAndSetLocalStorage, waitForOncoprint, checkOncoprintElement, goToUrlAndSetLocalStorageWithProperty, -} = require('../../../shared/specUtils'); -var { getNthOncoprintTrackOptionsElements, -} = require('../../../shared/specUtils'); -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; + clickElement, + waitForElementDisplayed, + getElement, +} = require('../../../shared/specUtils_Async'); -var _ = require('lodash'); +const { assertScreenShotMatch } = require('../../../shared/lib/testUtils'); + +const _ = require('lodash'); const { parse } = require('query-string'); const USER_SETTINGS_QUERY_PARAM = 'userSettingsJson'; @@ -76,17 +77,17 @@ const ONCOPRINT_TIMEOUT = 100000; describe('oncoprint', function() { this.retries(0); describe('generic assay categorical tracks', () => { - it('shows binary and multiple category tracks', () => { - goToUrlAndSetLocalStorage(genericArrayUrl, true); - waitForOncoprint(); - const res = checkOncoprintElement(); + it('shows binary and multiple category tracks', async () => { + await goToUrlAndSetLocalStorage(genericArrayUrl, true); + await waitForOncoprint(); + const res = await checkOncoprintElement(); assertScreenShotMatch(res); }); }); describe('clinical tracks', () => { - beforeEach(() => { - goToUrlAndSetLocalStorageWithProperty( + beforeEach(async () => { + await goToUrlAndSetLocalStorageWithProperty( studyes0_oncoprintTabUrl, true, { @@ -95,17 +96,17 @@ describe('oncoprint', function() { ), } ); - waitForOncoprint(); + await waitForOncoprint(); }); - it('initializes as configured by default', () => { - const res = checkOncoprintElement(); + it('initializes as configured by default', async () => { + const res = await checkOncoprintElement(); assertScreenShotMatch(res); }); - it('updates url when changing gaps', () => { - changeNthTrack(1, "Don't show gaps"); - const clinicalTracksUrlParam = getTracksFromBookmark(browser); + it('updates url when changing gaps', async () => { + await changeNthTrack(1, "Don't show gaps"); + const clinicalTracksUrlParam = await getTracksFromBookmark(browser); const expectedConfig = JSON.parse( JSON.stringify(SERVER_CLINICAL_TRACK_CONFIG) @@ -115,10 +116,10 @@ describe('oncoprint', function() { expect(clinicalTracksUrlParam).toEqual(expectedConfig); }); - it('updates url when sorting', () => { - changeNthTrack(1, 'Sort Z-a'); + it('updates url when sorting', async () => { + await changeNthTrack(1, 'Sort Z-a'); - const clinicallist = getTracksFromBookmark(browser); + const clinicallist = await getTracksFromBookmark(browser); expect(SERVER_CLINICAL_TRACK_CONFIG[0].sortOrder === 'ASC'); const updatedTrackConfig = JSON.parse( @@ -128,29 +129,29 @@ describe('oncoprint', function() { expect(clinicallist).toEqual(updatedTrackConfig); }); - it('initializes correctly when clinicallist config present in url', () => { + it('initializes correctly when clinicallist config present in url', async () => { const urlWithUserConfig = createUrlWithSettingsQueryParam( MANUAL_TRACK_CONFIG ); - goToUrlAndSetLocalStorage(urlWithUserConfig, false); - waitForOncoprint(); + await goToUrlAndSetLocalStorage(urlWithUserConfig, false); + await waitForOncoprint(); - const res = checkOncoprintElement(); + const res = await checkOncoprintElement(); assertScreenShotMatch(res); - const clinicallist = getTracksFromBookmark(browser); + const clinicallist = await getTracksFromBookmark(browser); expect(clinicallist).toEqual(MANUAL_TRACK_CONFIG); }); - it('still supports legacy clinicallist format', () => { - const legacyFormatUrlParam = createOncoprintFromLegacyFormat(); + it('still supports legacy clinicallist format', async () => { + const legacyFormatUrlParam = await createOncoprintFromLegacyFormat(); - changeNthTrack(1, 'Sort a-Z'); + await changeNthTrack(1, 'Sort a-Z'); - const res = checkOncoprintElement(); + const res = await checkOncoprintElement(); assertScreenShotMatch(res); - const clinicallist = getTracksFromBookmark(browser); + const clinicallist = await getTracksFromBookmark(browser); const stableIds = clinicallist.map(tracks => tracks.stableId); expect(stableIds.join(',')).toEqual(legacyFormatUrlParam); @@ -160,32 +161,36 @@ describe('oncoprint', function() { /** * Note: to rerun test locally, first clean user session */ - it('stores config in user session when save button clicked', () => { + it('stores config in user session when save button clicked', async () => { // Load page with a default config that differs from SERVER_CLINICAL_TRACK_CONFIG const customConfig = JSON.parse( JSON.stringify(SERVER_CLINICAL_TRACK_CONFIG) ); // Remove track to create diff customConfig.pop(); - const urlWithUserConfig = createUrlWithSettingsQueryParam( + const urlWithUserConfig = await createUrlWithSettingsQueryParam( customConfig ); - goToUrlAndSetLocalStorage(urlWithUserConfig, false); + await goToUrlAndSetLocalStorage(urlWithUserConfig, false); - waitForOncoprint(); + await waitForOncoprint(); // Check save button enabled - openTracksMenu(); - const $saveSessionBtn = $('#save-oncoprint-config-to-session'); - let classes = $saveSessionBtn.getAttribute('class').split(' '); + await openTracksMenu(); + const $saveSessionBtn = await getElement( + '#save-oncoprint-config-to-session' + ); + let classes = (await $saveSessionBtn.getAttribute('class')).split( + ' ' + ); const saveBtnIsEnabled = !classes.includes('disabled'); expect(saveBtnIsEnabled).toBe(true); // Click save button - $saveSessionBtn.click(); - waitForOncoprint(); + await $saveSessionBtn.click(); + await waitForOncoprint(); // Check save button disabled - classes = $saveSessionBtn.getAttribute('class').split(' '); + classes = (await $saveSessionBtn.getAttribute('class')).split(' '); const saveBtnIsDisabled = classes.includes('disabled'); expect(saveBtnIsDisabled).toBe(true); }); @@ -194,19 +199,19 @@ describe('oncoprint', function() { * Uses session from previous test * to differentiate between default and custom config */ - it('uses configuration stored in session when available', () => { + it('uses configuration stored in session when available', async () => { // Expected should match custom config of previous test const expected = JSON.parse( JSON.stringify(SERVER_CLINICAL_TRACK_CONFIG) ); expected.pop(); // <-- remove track - const clinicallist = getTracksFromBookmark(browser); + const clinicallist = await getTracksFromBookmark(browser); expect(clinicallist).toEqual(expected); }); }); - describe('oql structural variant tracks', () => { - beforeEach(() => { + describe('oql structural variant tracks', async () => { + beforeEach(async () => { // Build Struct Var OQL and place in the URL. const oql = // Downstream KIAA1549 has 1 struct var event (0.1%): @@ -240,7 +245,7 @@ describe('oncoprint', function() { // Define a set of clinical tracks in the props so that changes here // do not cause unnecessary differences in the screenshot test. - goToUrlAndSetLocalStorageWithProperty(stuctVarUrl, true, { + await goToUrlAndSetLocalStorageWithProperty(stuctVarUrl, true, { oncoprint_clinical_tracks_config_json: JSON.stringify( SERVER_CLINICAL_TRACK_CONFIG ), @@ -248,8 +253,8 @@ describe('oncoprint', function() { waitForOncoprint(); }); - it('shows oql structural variant variations', function() { - const res = checkOncoprintElement(); + it('shows oql structural variant variations', async function() { + const res = await checkOncoprintElement(); assertScreenShotMatch(res); }); }); @@ -262,39 +267,45 @@ function createUrlWithSettingsQueryParam(config) { return `${studyes0_oncoprintTabUrl}#${USER_SETTINGS_QUERY_PARAM}=${jsonConfig}`; } -function openTracksMenu() { - const $tracksDropdown = $('#addTracksDropdown'); - $tracksDropdown.click(); - waitForOncoprint(); +async function openTracksMenu() { + const $tracksDropdown = await getElement('#addTracksDropdown'); + await $tracksDropdown.click(); + await waitForOncoprint(); } -function changeNthTrack(track, menuOptionButtonText) { - const firstTrack = getNthOncoprintTrackOptionsElements(1); - $(firstTrack.button_selector).click(); - $(firstTrack.dropdown_selector).waitForDisplayed({ +async function changeNthTrack(track, menuOptionButtonText) { + const firstTrack = await getNthOncoprintTrackOptionsElements(1); + await clickElement(firstTrack.button_selector); + await waitForElementDisplayed(firstTrack.dropdown_selector, { timeout: 1000, }); - $(`li=${menuOptionButtonText}`).click(); - waitForOncoprint(); + await clickElement(`li=${menuOptionButtonText}`); + await waitForOncoprint(); } -function getBookmarkUrl(browser) { +async function getBookmarkUrl(browser) { const showBookmarkButtonSelector = '[data-test=bookmark-link]'; - browser.waitUntil(() => $(showBookmarkButtonSelector).isExisting()); - $(showBookmarkButtonSelector).click(); + await browser.waitUntil( + async () => + await (await getElement(showBookmarkButtonSelector)).isExisting() + ); + await clickElement(showBookmarkButtonSelector); const bookmarkUrlInputFieldSelector = '[data-test=bookmark-url]'; - browser.waitUntil(() => $(bookmarkUrlInputFieldSelector).isExisting()); - const $bookMarkUrl = $('[data-test=bookmark-url]'); + await browser.waitUntil( + async () => + await (await getElement(bookmarkUrlInputFieldSelector)).isExisting() + ); + const $bookMarkUrl = await getElement('[data-test=bookmark-url]'); return $bookMarkUrl.getValue(); } -function getTracksFromBookmark(browser) { - const bookmarkUrl = getBookmarkUrl(browser); - const userSettings = getUserSettingsFrom(bookmarkUrl); +async function getTracksFromBookmark(browser) { + const bookmarkUrl = await getBookmarkUrl(browser); + const userSettings = await getUserSettingsFrom(bookmarkUrl); return userSettings.clinicallist; } -function getUserSettingsFrom(bookmarkUrl) { +async function getUserSettingsFrom(bookmarkUrl) { let params = parse(new URL(bookmarkUrl).hash); return JSON.parse(params[USER_SETTINGS_QUERY_PARAM]); } @@ -302,12 +313,12 @@ function getUserSettingsFrom(bookmarkUrl) { /** * @returns {string} legacy format */ -function createOncoprintFromLegacyFormat() { +async function createOncoprintFromLegacyFormat() { const legacyFormatQueryParam = MANUAL_TRACK_CONFIG.map( track => track.stableId ).join(','); const legacyUrl = `${studyes0_oncoprintTabUrl}&clinicallist=${legacyFormatQueryParam}`; - goToUrlAndSetLocalStorage(legacyUrl, false); - waitForOncoprint(); + await goToUrlAndSetLocalStorage(legacyUrl, false); + await waitForOncoprint(); return legacyFormatQueryParam; } diff --git a/end-to-end-test/local/specs/core/patientview.screenshot.spec.js b/end-to-end-test/local/specs/core/patientview.screenshot.spec.js index f9253376c34..2953c0ecec1 100644 --- a/end-to-end-test/local/specs/core/patientview.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/patientview.screenshot.spec.js @@ -1,11 +1,13 @@ -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForPatientView = require('../../../shared/specUtils') - .waitForPatientView; -var { setDropdownOpen } = require('../../../shared/specUtils'); -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; -const { getElementByTestHandle } = require('../../../shared/specUtils'); +const { + goToUrlAndSetLocalStorage, + waitForPatientView, + setDropdownOpen, + getElementByTestHandle, + getNestedElement, + waitForElementDisplayed, + clickElement, +} = require('../../../shared/specUtils_Async'); +const { assertScreenShotMatch } = require('../../../shared/lib/testUtils'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const patientViewUrl = CBIOPORTAL_URL + '/patient?studyId=teststudy_genepanels&caseId=patientA'; @@ -17,13 +19,13 @@ const genericAssayPatientViewUrl = describe('patient view page', function() { describe('mutation table for study with ASCN data', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(ascnPatientViewUrl, true); - waitForPatientView(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(ascnPatientViewUrl, true); + await waitForPatientView(); }); - it('displays ASCN columns', () => { - var res = browser.checkElement( + it('displays ASCN columns', async () => { + const res = await browser.checkElement( 'div[data-test=patientview-mutation-table] table' ); assertScreenShotMatch(res); @@ -31,13 +33,13 @@ describe('patient view page', function() { }); describe('mutation table for study with no ASCN data', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(patientViewUrl, true); - waitForPatientView(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(patientViewUrl, true); + await waitForPatientView(); }); - it('does not display ASCN columns for studies with no ASCN data', () => { - var res = browser.checkElement( + it('does not display ASCN columns for studies with no ASCN data', async () => { + const res = await browser.checkElement( 'div[data-test=patientview-mutation-table] table' ); assertScreenShotMatch(res); @@ -48,13 +50,13 @@ describe('patient view page', function() { const iconIndexGenePanelSample = 2; const iconIndexWholeGenomeSample = 3; - beforeEach(() => { - goToUrlAndSetLocalStorage(patientViewUrl, true); - waitForPatientView(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(patientViewUrl, true); + await waitForPatientView(); }); - it('shows gene panel icons behind mutation and CNA genomic tracks', () => { - var res = browser.checkElement( + it('shows gene panel icons behind mutation and CNA genomic tracks', async () => { + const res = await browser.checkElement( 'div.genomicOverviewTracksContainer' ); assertScreenShotMatch(res); @@ -201,16 +203,17 @@ describe('patient view page', function() { }); }); -const switchGeneFilter = selectedOption => { +const switchGeneFilter = async selectedOption => { const selectMenu = '.rc-tooltip'; const filterIcon = 'div[data-test=patientview-mutation-table] i[data-test=gene-filter-icon]'; - setDropdownOpen(true, filterIcon, selectMenu); - const allGenesRadio = $(selectMenu).$( - 'input[value=' + selectedOption + ']' - ); - allGenesRadio.click(); - setDropdownOpen(false, filterIcon, selectMenu); + await setDropdownOpen(true, filterIcon, selectMenu); + const allGenesRadio = await getNestedElement([ + selectMenu, + 'input[value=' + selectedOption + ']', + ]); + await allGenesRadio.click(); + await setDropdownOpen(false, filterIcon, selectMenu); }; const doVafPlotScreenshotTest = () => { @@ -252,11 +255,14 @@ const selectPercentageYAxis = () => { getElementByTestHandle('AxisScaleSwitch%').click(); }; -const selectSampleMutationalSignature = () => { - $('div.mutationalSignatureSampleSelector__indicators').waitForDisplayed({ - timeout: 10000, - }); - $('div.mutationalSignatureSampleSelector__indicators').click(); - $('div=P01_Rec').waitForDisplayed({ timeout: 10000 }); - $('div=P01_Rec').click(); +const selectSampleMutationalSignature = async () => { + await waitForElementDisplayed( + 'div.mutationalSignatureSampleSelector__indicators', + { + timeout: 10000, + } + ); + await clickElement('div.mutationalSignatureSampleSelector__indicators'); + await waitForElementDisplayed('div=P01_Rec', { timeout: 10000 }); + await clickElement('div=P01_Rec'); }; diff --git a/end-to-end-test/local/specs/core/patientview.spec.js b/end-to-end-test/local/specs/core/patientview.spec.js index b99a77142f4..af0a46afb49 100644 --- a/end-to-end-test/local/specs/core/patientview.spec.js +++ b/end-to-end-test/local/specs/core/patientview.spec.js @@ -1,17 +1,15 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../../shared/specUtils') - .useExternalFrontend; -var waitForPatientView = require('../../../shared/specUtils') - .waitForPatientView; -var { +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, jsApiHover, setDropdownOpen, strIsNumeric, -} = require('../../../shared/specUtils'); + waitForPatientView, + getNestedElement, + getElement, +} = require('../../../shared/specUtils_Async'); -var _ = require('lodash'); +const _ = require('lodash'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const genePanelPatientViewUrl = @@ -25,15 +23,15 @@ const ALLELE_FREQ_SAMPLE_VIEW_URL = `${CBIOPORTAL_URL}/patient?studyId=ascn_test describe('patient view page', function() { describe('gene panel information', () => { - before(() => { - goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); - waitForPatientView(); + before(async () => { + await goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); + await waitForPatientView(); }); const p = 'sample-icon'; const n = 'not-profiled-icon'; - it('mutation table shows correct sample icons, non-profiled icons and invisible icons', () => { + it('mutation table shows correct sample icons, non-profiled icons and invisible icons', async () => { const sampleIcon = { ERBB2: [n, n, n, p, p], ABLIM1: [p, p, n, p, p], @@ -49,17 +47,17 @@ describe('patient view page', function() { }; const genes = _.keys(sampleIcon); - genes.forEach(gene => { - testSampleIcon( + for (const gene of genes) { + await testSampleIcon( gene, 'patientview-mutation-table', sampleIcon[gene], sampleVisibility[gene] ); - }); + } }); - it('CNA table shows correct sample icons, non-profiled icons and invisible icons', () => { + it('CNA table shows correct sample icons, non-profiled icons and invisible icons', async () => { const sampleIcon = { ERBB2: [n, n, p, p, n], CADM2: [p, p, p, p, p], @@ -74,14 +72,14 @@ describe('patient view page', function() { const genes = _.keys(sampleIcon); - genes.forEach(gene => { - testSampleIcon( + for (const gene of genes) { + await testSampleIcon( gene, 'patientview-copynumber-table', sampleIcon[gene], sampleVisibility[gene] ); - }); + } }); }); @@ -89,58 +87,64 @@ describe('patient view page', function() { let selectMenu; let filterIcon; - before(() => { - goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); - waitForPatientView(); + before(async () => { + await goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); + await waitForPatientView(); }); - it('filter menu icon is shown when gene panels are used', () => { - filterIcon = $('div[data-test=patientview-mutation-table]').$( - 'i[data-test=gene-filter-icon]' - ); - assert(filterIcon.isDisplayed()); + it('filter menu icon is shown when gene panels are used', async () => { + filterIcon = await getNestedElement([ + 'div[data-test=patientview-mutation-table]', + 'i[data-test=gene-filter-icon]', + ]); + assert(await filterIcon.isDisplayed()); }); - it('opens selection menu when filter icon clicked', () => { - setDropdownOpen(true, filterIcon, '.rc-tooltip'); - selectMenu = $('.rc-tooltip'); - assert(selectMenu.isDisplayed()); + it('opens selection menu when filter icon clicked', async () => { + await setDropdownOpen(true, filterIcon, '.rc-tooltip'); + selectMenu = await getElement('.rc-tooltip'); + assert(await selectMenu.isDisplayed()); }); - it('removes genes profiles profiled in some samples then `all genes` option selected', () => { - setDropdownOpen(true, filterIcon, selectMenu); - const allGenesRadio = selectMenu.$('input[value=allSamples]'); - allGenesRadio.click(); - const geneEntries = $$('[data-test=mutation-table-gene-column]'); + it('removes genes profiles profiled in some samples then `all genes` option selected', async () => { + await setDropdownOpen(true, filterIcon, selectMenu); + const allGenesRadio = await selectMenu.$('input[value=allSamples]'); + await allGenesRadio.click(); + const geneEntries = await $$( + '[data-test=mutation-table-gene-column]' + ); assert.equal(geneEntries.length, 1); - const geneName = geneEntries[0].getText(); + const geneName = await geneEntries[0].getText(); assert.equal(geneName, 'CADM2'); }); - it('re-adds genes when `any genes` option selected', () => { - const anyGenesRadio = selectMenu.$('input[value=anySample]'); - anyGenesRadio.click(); - const geneEntries = $$('[data-test=mutation-table-gene-column]'); + it('re-adds genes when `any genes` option selected', async () => { + const anyGenesRadio = await selectMenu.$('input[value=anySample]'); + await anyGenesRadio.click(); + const geneEntries = await $$( + '[data-test=mutation-table-gene-column]' + ); assert.equal(geneEntries.length, 4); }); - it('closes selection menu when filter icon clicked again', () => { - setDropdownOpen(false, filterIcon, '.rc-tooltip'); - selectMenu = $('.rc-tooltip'); - assert(!selectMenu.isDisplayed()); + it('closes selection menu when filter icon clicked again', async () => { + await setDropdownOpen(false, filterIcon, '.rc-tooltip'); + selectMenu = await $('.rc-tooltip'); + assert(!(await selectMenu.isDisplayed())); }); - it('filter menu icon is not shown when gene panels are not used', () => { - goToUrlAndSetLocalStorage( + it('filter menu icon is not shown when gene panels are not used', async () => { + await goToUrlAndSetLocalStorage( CBIOPORTAL_URL + '/patient?studyId=study_es_0&caseId=TCGA-A1-A0SK', true ); - waitForPatientView(); - var filterIcon = $('div[data-test=patientview-mutation-table]').$( - 'i[data-test=gene-filter-icon]' - ); - assert(!filterIcon.isDisplayed()); + await waitForPatientView(); + const filterIcon = getNestedElement([ + 'div[data-test=patientview-mutation-table]', + 'i[data-test=gene-filter-icon]', + ]); + assert(!(await filterIcon.isDisplayed())); }); }); @@ -148,83 +152,95 @@ describe('patient view page', function() { let selectMenu; let filterIcon; - before(() => { - goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); - waitForPatientView(); + before(async () => { + await goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); + await waitForPatientView(); }); - it('filter menu icon is shown when gene panels are used', () => { - filterIcon = $('div[data-test=patientview-copynumber-table]').$( - 'i[data-test=gene-filter-icon]' - ); - assert(filterIcon.isDisplayed()); + it('filter menu icon is shown when gene panels are used', async () => { + filterIcon = await getNestedElement([ + 'div[data-test=patientview-copynumber-table]', + 'i[data-test=gene-filter-icon]', + ]); + assert(await filterIcon.isDisplayed()); }); - it('opens selection menu when filter icon clicked', () => { - setDropdownOpen(true, filterIcon, '.rc-tooltip'); - selectMenu = $('.rc-tooltip'); - assert(selectMenu.isDisplayed()); + it('opens selection menu when filter icon clicked', async () => { + await setDropdownOpen(true, filterIcon, '.rc-tooltip'); + selectMenu = await getElement('.rc-tooltip'); + assert(await selectMenu.isDisplayed()); }); - it('removes genes profiles profiled in some samples then `all genes` option selected', () => { - setDropdownOpen(true, filterIcon, '.rc-tooltip'); - const allGenesRadio = selectMenu.$('input[value=allSamples]'); - allGenesRadio.click(); - const geneEntries = $$('[data-test=cna-table-gene-column]'); + it('removes genes profiles profiled in some samples then `all genes` option selected', async () => { + await setDropdownOpen(true, filterIcon, '.rc-tooltip'); + const allGenesRadio = await selectMenu.$('input[value=allSamples]'); + await allGenesRadio.click(); + const geneEntries = await $$('[data-test=cna-table-gene-column]'); assert.equal(geneEntries.length, 1); - const geneName = geneEntries[0].getText(); + const geneName = await geneEntries[0].getText(); assert.equal(geneName, 'CADM2'); }); - it('re-adds genes when `any genes` option selected', () => { - setDropdownOpen(true, filterIcon, '.rc-tooltip'); - const anyGenesRadio = selectMenu.$('input[value=anySample]'); - anyGenesRadio.click(); - const geneEntries = $$('[data-test=cna-table-gene-column]'); + it('re-adds genes when `any genes` option selected', async () => { + await setDropdownOpen(true, filterIcon, '.rc-tooltip'); + const anyGenesRadio = await selectMenu.$('input[value=anySample]'); + await anyGenesRadio.click(); + const geneEntries = await $$('[data-test=cna-table-gene-column]'); assert.equal(geneEntries.length, 3); }); - it('closes selection menu when filter icon clicked again', () => { - setDropdownOpen(false, filterIcon, '.rc-tooltip'); - assert(!selectMenu.isDisplayed()); + it('closes selection menu when filter icon clicked again', async () => { + await setDropdownOpen(false, filterIcon, '.rc-tooltip'); + assert(!(await selectMenu.isDisplayed())); }); - it('filter menu icon is not shown when gene panels are not used', () => { - goToUrlAndSetLocalStorage( + it('filter menu icon is not shown when gene panels are not used', async () => { + await goToUrlAndSetLocalStorage( CBIOPORTAL_URL + '/patient?studyId=study_es_0&caseId=TCGA-A2-A04U', true ); - waitForPatientView(); - var filterIcon = $('div[data-test=patientview-copynumber-table]').$( - 'i[data-test=gene-filter-icon]' - ); + await waitForPatientView(); + const filterIcon = await getNestedElement([ + 'div[data-test=patientview-copynumber-table]', + 'i[data-test=gene-filter-icon]', + ]); assert(!filterIcon.isDisplayed()); }); }); describe('genomic tracks', () => { - before(() => { - goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); - waitForPatientView(); + before(async () => { + await goToUrlAndSetLocalStorage(genePanelPatientViewUrl, true); + await waitForPatientView(); }); - it.skip('shows gene panel icon when gene panels are used for patient samples', () => { - assert($('[data-test=cna-track-genepanel-icon-0]').isExisting()); - assert($('[data-test=mut-track-genepanel-icon-5]').isExisting()); + it.skip('shows gene panel icon when gene panels are used for patient samples', async () => { + assert( + await ( + await getElement('[data-test=cna-track-genepanel-icon-0]') + ).isExisting() + ); + assert( + await await '[data-test=mut-track-genepanel-icon-5]'.isExisting() + ); }); - it.skip('shows mouse-over tooltip for gene panel icons with gene panel id', () => { + it.skip('shows mouse-over tooltip for gene panel icons with gene panel id', async () => { // Tooltip elements are created when hovering the gene panel icon. // Control logic below is needed to access the last one after it // was created. - $('[data-test=cna-track-genepanel-icon-1]').waitForDisplayed(); + await waitForElementDisplayed( + '[data-test=cna-track-genepanel-icon-1]' + ); - $('[data-test=cna-track-genepanel-icon-1]').moveTo(); + await ( + await getElement('[data-test=cna-track-genepanel-icon-1]') + ).moveTo(); - $('.genover-tooltip').waitForDisplayed(); - var text = $('div.qtip-content').getText(); + await waitForElementDisplayed('.genover-tooltip'); + const text = (await getElement('div.qtip-content')).getText(); assert.equal(text, 'Gene panel: TESTPANEL1'); }); @@ -458,25 +474,25 @@ describe('patient view page', function() { }); }); -function testSampleIcon( +async function testSampleIcon( geneSymbol, tableTag, sampleIconTypes, sampleVisibilities ) { - const geneCell = $('div[data-test=' + tableTag + '] table').$( - 'span=' + geneSymbol + const geneCell = getNestedElement([ + 'div[data-test=' + tableTag + '] table', + 'span=' + geneSymbol, + ]); + const samplesCell = await (await (await geneCell.$('..')).$('..')).$( + 'div[data-test=samples-cell] ul' ); - const samplesCell = geneCell - .$('..') - .$('..') - .$('div[data-test=samples-cell] ul'); - const icons = samplesCell.$$('li'); - - sampleIconTypes.forEach((desiredDataType, i) => { - const isExpectedIcon = icons[i] - .$('svg[data-test=' + desiredDataType + ']') - .isExisting(); + const icons = await samplesCell.$$('li'); + + sampleIconTypes.forEach(async (desiredDataType, i) => { + const isExpectedIcon = await ( + await icons[i].$('svg[data-test=' + desiredDataType + ']') + ).isExisting(); assert.equal( isExpectedIcon, true, @@ -490,8 +506,8 @@ function testSampleIcon( ); }); - sampleVisibilities.forEach((desiredVisibility, i) => { - const actualVisibility = icons[i].isDisplayed(); + sampleVisibilities.forEach(async (desiredVisibility, i) => { + const actualVisibility = await icons[i].isDisplayed(); assert.equal( actualVisibility, desiredVisibility, @@ -508,27 +524,27 @@ function testSampleIcon( }); } -function testClonalIcon( +async function testClonalIcon( geneSymbol, tableTag, clonalIconTypes, sampleVisibilities ) { - const geneCell = $('div[data-test=' + tableTag + '] table').$( - 'span=' + geneSymbol + const geneCell = await getNestedElement([ + 'div[data-test=' + tableTag + '] table', + 'span=' + geneSymbol, + ]); + const clonalCell = await (await (await geneCell.$('..')).$('..')).$( + 'span[data-test=clonal-cell]' ); - const clonalCell = geneCell - .$('..') - .$('..') - .$('span[data-test=clonal-cell]'); //if span span - getting a whole list where each index is a list //if span span span - each index seems to be one item - const icons = clonalCell.$$('span span span'); - clonalIconTypes.forEach((desiredDataType, i) => { - const svg = icons[i].$('svg'); + const icons = await clonalCell.$$('span span span'); + clonalIconTypes.forEach(async (desiredDataType, i) => { + const svg = await icons[i].$('svg'); - const actualDataType = svg.getAttribute('data-test'); + const actualDataType = await svg.getAttribute('data-test'); assert.equal( actualDataType, desiredDataType, @@ -543,7 +559,8 @@ function testClonalIcon( '`' ); - const actualVisibility = svg.$('circle').getAttribute('opacity') > 0; + const actualVisibility = + (await (await svg.$('circle')).getAttribute('opacity')) > 0; assert.equal( actualVisibility, sampleVisibilities[i], diff --git a/end-to-end-test/local/specs/core/plotstab.screenshot.spec.js b/end-to-end-test/local/specs/core/plotstab.screenshot.spec.js index 2db312e9889..9dd1d7d9917 100644 --- a/end-to-end-test/local/specs/core/plotstab.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/plotstab.screenshot.spec.js @@ -1,33 +1,33 @@ -var { +const { goToUrlAndSetLocalStorage, waitForAndCheckPlotsTab, -} = require('../../../shared/specUtils'); +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('plots tab', function() { describe('generic assay categorical plots', () => { - it('show category vs os status plot', () => { - var url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B%22selectedGenericAssayOption%22%3A%22mutational_signature_category_1%22%2C%22dataType%22%3A%22MUTATIONAL_SIGNATURE_TEST%22%2C%22selectedDataSourceOption%22%3A%22mutational_signature_category_v2%22%7D&plots_vert_selection=%7B%22dataType%22%3A%22clinical_attribute%22%2C%22selectedDataSourceOption%22%3A%22OS_STATUS%22%7D&plots_coloring_selection=%7B%7D`; - goToUrlAndSetLocalStorage(url, true); - waitForAndCheckPlotsTab(); + it('show category vs os status plot', async () => { + const url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B%22selectedGenericAssayOption%22%3A%22mutational_signature_category_1%22%2C%22dataType%22%3A%22MUTATIONAL_SIGNATURE_TEST%22%2C%22selectedDataSourceOption%22%3A%22mutational_signature_category_v2%22%7D&plots_vert_selection=%7B%22dataType%22%3A%22clinical_attribute%22%2C%22selectedDataSourceOption%22%3A%22OS_STATUS%22%7D&plots_coloring_selection=%7B%7D`; + await goToUrlAndSetLocalStorage(url, true); + await waitForAndCheckPlotsTab(); }); - it('show category vs mutation count plot', () => { - var url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B%22selectedGenericAssayOption%22%3A%22mutational_signature_category_1%22%2C%22dataType%22%3A%22MUTATIONAL_SIGNATURE_TEST%22%2C%22selectedDataSourceOption%22%3A%22mutational_signature_category_v2%22%7D&plots_vert_selection=%7B%22dataType%22%3A%22clinical_attribute%22%2C%22selectedDataSourceOption%22%3A%22MUTATION_COUNT%22%7D&plots_coloring_selection=%7B%7D`; - goToUrlAndSetLocalStorage(url, true); - waitForAndCheckPlotsTab(); + it('show category vs mutation count plot', async () => { + const url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B%22selectedGenericAssayOption%22%3A%22mutational_signature_category_1%22%2C%22dataType%22%3A%22MUTATIONAL_SIGNATURE_TEST%22%2C%22selectedDataSourceOption%22%3A%22mutational_signature_category_v2%22%7D&plots_vert_selection=%7B%22dataType%22%3A%22clinical_attribute%22%2C%22selectedDataSourceOption%22%3A%22MUTATION_COUNT%22%7D&plots_coloring_selection=%7B%7D`; + await goToUrlAndSetLocalStorage(url, true); + await waitForAndCheckPlotsTab(); }); }); describe('generic assay binary plots', () => { - it('show binary vs os status plot', () => { - var url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B"dataType"%3A"MUTATIONAL_SIGNATURE_TEST"%2C"selectedDataSourceOption"%3A"mutational_signature_binary_v2"%7D&plots_vert_selection=%7B"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"OS_STATUS"%7D&plots_coloring_selection=%7B%7D`; - goToUrlAndSetLocalStorage(url, true); - waitForAndCheckPlotsTab(); + it('show binary vs os status plot', async () => { + const url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B"dataType"%3A"MUTATIONAL_SIGNATURE_TEST"%2C"selectedDataSourceOption"%3A"mutational_signature_binary_v2"%7D&plots_vert_selection=%7B"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"OS_STATUS"%7D&plots_coloring_selection=%7B%7D`; + await goToUrlAndSetLocalStorage(url, true); + await waitForAndCheckPlotsTab(); }); - it('show binary vs mutation count plot', () => { - var url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B"dataType"%3A"MUTATIONAL_SIGNATURE_TEST"%2C"selectedDataSourceOption"%3A"mutational_signature_binary_v2"%7D&plots_vert_selection=%7B"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"MUTATION_COUNT"%7D&plots_coloring_selection=%7B%7D`; - goToUrlAndSetLocalStorage(url, true); - waitForAndCheckPlotsTab(); + it('show binary vs mutation count plot', async () => { + const url = `${CBIOPORTAL_URL}/results/plots?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=lgg_ucsf_2014_test_generic_assay_mutations&cancer_study_list=lgg_ucsf_2014_test_generic_assay&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=lgg_ucsf_2014_test_generic_assay_sequenced&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&plots_horz_selection=%7B"dataType"%3A"MUTATIONAL_SIGNATURE_TEST"%2C"selectedDataSourceOption"%3A"mutational_signature_binary_v2"%7D&plots_vert_selection=%7B"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"MUTATION_COUNT"%7D&plots_coloring_selection=%7B%7D`; + await goToUrlAndSetLocalStorage(url, true); + await waitForAndCheckPlotsTab(); }); }); }); diff --git a/end-to-end-test/local/specs/core/plotstab.spec.js b/end-to-end-test/local/specs/core/plotstab.spec.js index 5e1cf5502ac..8cc7f194999 100644 --- a/end-to-end-test/local/specs/core/plotstab.spec.js +++ b/end-to-end-test/local/specs/core/plotstab.spec.js @@ -1,26 +1,25 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../../shared/specUtils') - .useExternalFrontend; -var waitForPlotsTab = require('../../../shared/specUtils').waitForPlotsTab; -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; -var selectReactSelectOption = require('../../../shared/specUtils') - .selectReactSelectOption; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + assertScreenShotMatch, + selectReactSelectOption, + waitForElementDisplayed, + getNestedElement, + clickElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('plots tab', function() { describe('utilities menu', function() { - it('is shown when plot data available', function() { - loadPlotsTab( + it('is shown when plot data available', async function() { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&show_samples=false&tab_index=tab_visualize` ); assert($('div.color-samples-toolbar-elt').isExisting()); }); - it('is hidden when plot data unavailable', function() { + it('is hidden when plot data unavailable', async function() { goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=AR%2520RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&show_samples=false&tab_index=tab_visualize`, true @@ -29,73 +28,78 @@ describe('plots tab', function() { assert(true); }); - it('shows gene selection box and radio buttons in clinical attribute vs treatment plot', () => { - loadPlotsTab( + it('shows gene selection box and radio buttons in clinical attribute vs treatment plot', async () => { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&heatmap_track_groups=study_es_0_treatment_ic50%2CErlotinib&show_samples=false&tab_index=tab_visualize&treatment_list=Erlotinib` ); - selectTreatmentProfile(); + await selectTreatmentProfile(); assert($('div.coloring-menu').isExisting()); assert( $('div.coloring-menu').$$('input[type="checkbox"]').length === 3 ); }); - it('shows mutation and copy number by default', () => { - loadPlotsTab( + it('shows mutation and copy number by default', async () => { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&heatmap_track_groups=study_es_0_treatment_ic50%2CErlotinib&show_samples=false&tab_index=tab_visualize&treatment_list=Erlotinib&plots_horz_selection=%7B"dataType"%3A"clinical_attribute"%7D&plots_vert_selection=%7B"selectedGeneOption"%3A6205%2C"dataType"%3A"TREATMENT_RESPONSE"%7D&plots_coloring_selection=%7B%7D&profileFilter=0` ); - selectTreatmentProfile(); - const res = browser.checkElement('[id=plots-tab-plot-svg]'); + await selectTreatmentProfile(); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('shows only mutation types when copy number is de-selected', () => { - loadPlotsTab( + it('shows only mutation types when copy number is de-selected', async () => { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&heatmap_track_groups=study_es_0_treatment_ic50%2CErlotinib&show_samples=false&tab_index=tab_visualize&treatment_list=Erlotinib&plots_horz_selection=%7B"dataType"%3A"clinical_attribute"%7D&plots_vert_selection=%7B"selectedGeneOption"%3A6205%2C"dataType"%3A"TREATMENT_RESPONSE"%7D&plots_coloring_selection=%7B"colorByCopyNumber"%3A"false"%2C"colorBySv"%3A"false"%7D&profileFilter=0` ); - selectTreatmentProfile(); - $('input[data-test="ViewCopyNumber"]').click(); - const res = browser.checkElement('[id=plots-tab-plot-svg]'); + await selectTreatmentProfile(); + clickElement('input[data-test="ViewCopyNumber"]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('shows only CNA types when mutation checkbox is deselected', () => { - loadPlotsTab( + it('shows only CNA types when mutation checkbox is deselected', async () => { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&heatmap_track_groups=study_es_0_treatment_ic50%2CErlotinib&show_samples=false&tab_index=tab_visualize&treatment_list=Erlotinib&plots_horz_selection=%7B"dataType"%3A"clinical_attribute"%7D&plots_vert_selection=%7B"selectedGeneOption"%3A6205%2C"dataType"%3A"TREATMENT_RESPONSE"%7D&plots_coloring_selection=%7B"colorByMutationType"%3A"false"%2C"colorBySv"%3A"false"%7D&profileFilter=0` ); - selectTreatmentProfile(); - $('input[data-test="ViewMutationType"]').click(); - const res = browser.checkElement('[id=plots-tab-plot-svg]'); + await selectTreatmentProfile(); + await clickElement('input[data-test="ViewMutationType"]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('removes sample stylings when selecting None in gene selection box', () => { - loadPlotsTab( + it('removes sample stylings when selecting None in gene selection box', async () => { + await loadPlotsTab( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&clinicallist=NUM_SAMPLES_PER_PATIENT%2CPROFILED_IN_study_es_0_mutations%2CPROFILED_IN_study_es_0_gistic%2CPROFILED_IN_study_es_0_mrna_median_Zscores&data_priority=0&gene_list=RPS11&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=study_es_0_mrna_median_Zscores&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&heatmap_track_groups=study_es_0_treatment_ic50%2CErlotinib&show_samples=false&tab_index=tab_visualize&treatment_list=Erlotinib&plots_horz_selection=%7B"dataType"%3A"clinical_attribute"%7D&plots_vert_selection=%7B"dataType"%3A"TREATMENT_RESPONSE"%7D&plots_coloring_selection=%7B"selectedOption"%3A"6205_undefined"%7D&profileFilter=0` ); - selectTreatmentProfile(); - $('.gene-select').click(); + await selectTreatmentProfile(); + await clickElement('.gene-select'); // select gene menu entries - var geneMenuEntries = $('[data-test=GeneColoringMenu]') - .$('div=Genes') - .$('..') - .$$('div')[1] - .$$('div'); - geneMenuEntries[0].click(); - $('[data-test=PlotsTabPlotDiv]').waitForDisplayed(); - const res = browser.checkElement('[id=plots-tab-plot-svg]'); + const geneMenuEntries = await await ( + await getNestedElement([ + '[data-test=GeneColoringMenu]', + 'div=Genes', + '..', + ]).$$('div')[1] + ).$$('div'); + await geneMenuEntries[0].click(); + await waitForElementDisplayed('[data-test=PlotsTabPlotDiv]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); }); }); -var loadPlotsTab = url => { - goToUrlAndSetLocalStorage(url, true); - $('div[data-test="PlotsTabPlotDiv"]').waitForDisplayed(); +const loadPlotsTab = async url => { + await goToUrlAndSetLocalStorage(url, true); + await waitForElementDisplayed('div[data-test="PlotsTabPlotDiv"]'); }; -var selectTreatmentProfile = () => { - const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - selectReactSelectOption(vertDataSelect, 'Treatment Response'); - $('div[data-test="PlotsTabPlotDiv"]').waitForDisplayed(); +const selectTreatmentProfile = async () => { + const vertDataSelect = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(vertDataSelect, 'Treatment Response'); + await waitForElementDisplayed('div[data-test="PlotsTabPlotDiv"]'); }; diff --git a/end-to-end-test/local/specs/core/postedquery.spec.js b/end-to-end-test/local/specs/core/postedquery.spec.js index 53f209bc5ae..a399dddf757 100644 --- a/end-to-end-test/local/specs/core/postedquery.spec.js +++ b/end-to-end-test/local/specs/core/postedquery.spec.js @@ -1,21 +1,18 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var postDataToUrl = require('../../../shared/specUtils').postDataToUrl; -var _ = require('lodash'); - -var { - useExternalFrontend, +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + postDataToUrl, waitForOncoprint, getElementByTestHandle, -} = require('../../../shared/specUtils'); +} = require('../../../shared/specUtils_Async'); +const _ = require('lodash'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('posting query parameters (instead of GET) to query page', function() { - it('reads posted data (written by backend) and successfully passes params into URL, resulting in oncoprint display', function() { + it('reads posted data (written by backend) and successfully passes params into URL, resulting in oncoprint display', async function() { const url = `${CBIOPORTAL_URL}`; - goToUrlAndSetLocalStorage(url, true); + await goToUrlAndSetLocalStorage(url, true); let query = { gene_list: 'CDKN2A MDM2 MDM4 TP53', @@ -30,11 +27,11 @@ describe('posting query parameters (instead of GET) to query page', function() { 'study_es_0_gistic', }; - postDataToUrl(`${url}/results`, query); + await postDataToUrl(`${url}/results`, query); // the following could only occur if code passes data written above into url - browser.waitUntil(() => { - var url = browser.getUrl(); + await browser.waitUntil(async () => { + const url = await browser.getUrl(); // make sure param in query is passed to url and encoded return _.every(query, (item, key) => { @@ -48,18 +45,18 @@ describe('posting query parameters (instead of GET) to query page', function() { }); }); - const postData = browser.execute(() => { + const postData = await browser.execute(() => { return window.postData; }); assert(postData === null, 'postData has been set to null after read'); - waitForOncoprint(); + await waitForOncoprint(); }); }); describe('Post Data for StudyView Filtering with filterJson via HTTP Post', () => { - it('Verify PatientIdentifier Filter via postData', () => { + it('Verify PatientIdentifier Filter via postData', async () => { const filterJsonQuery = { filterJson: '{"patientIdentifiers":[{"studyId":"lgg_ucsf_2014_test_generic_assay","patientId":"P01"}]}', @@ -67,19 +64,19 @@ describe('Post Data for StudyView Filtering with filterJson via HTTP Post', () = const NUMBER_OF_PATIENTS_AFTER_FILTER = 1; - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`, true); + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`, true); - postDataToUrl( + await postDataToUrl( `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`, filterJsonQuery ); - getElementByTestHandle('selected-patients').waitForExist({ + await (await getElementByTestHandle('selected-patients')).waitForExist({ timeout: 20000, }); assert.equal( - getElementByTestHandle('selected-patients').getText(), + await (await getElementByTestHandle('selected-patients')).getText(), NUMBER_OF_PATIENTS_AFTER_FILTER ); }); diff --git a/end-to-end-test/local/specs/core/querypage.spec.js b/end-to-end-test/local/specs/core/querypage.spec.js index a7ba8aac638..4d9d7cb453c 100644 --- a/end-to-end-test/local/specs/core/querypage.spec.js +++ b/end-to-end-test/local/specs/core/querypage.spec.js @@ -1,8 +1,13 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../../shared/specUtils') - .useExternalFrontend; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + getElement, + getNestedElement, + clickElement, + isDisplayed, + isSelected, + setInputText, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -11,33 +16,44 @@ describe('study select page', function() { // FIXME: on authenticated portals the alert does not show because the backend throws 403 because // the user does not have permission to access a non-existing study. // Possibly, run localdb against an unauthenticated portal or as a remote tests against public cbioportal - it('show error alert and query form for single invalid study id', function() { - var url = `${CBIOPORTAL_URL}/results/oncoprint?Z_SCORE_THRESHOLD=2.0&cancer_study_id=coadread_tcga_pub&cancer_study_list=coadread_tcga_pub&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&gene_set_choice=user-defined-list&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations`; - goToUrlAndSetLocalStorage(url, true); - $('[data-test="StudySelect"]').waitForExist(); + it('show error alert and query form for single invalid study id', async function() { + const url = `${CBIOPORTAL_URL}/results/oncoprint?Z_SCORE_THRESHOLD=2.0&cancer_study_id=coadread_tcga_pub&cancer_study_list=coadread_tcga_pub&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&gene_set_choice=user-defined-list&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations`; + await goToUrlAndSetLocalStorage(url, true); + await getElement('[data-test="StudySelect"]', { + waitForExist: true, + }); assert( - $('[data-test="unkown-study-warning"]').$( - 'li=coadread_tcga_pubb' - ) + await getNestedElement([ + '[data-test="unkown-study-warning"]', + 'li=coadread_tcga_pubb', + ]) ); }); // FIXME: on authenticated portals the alert does not show because the backend throws 403 because // the user does not have permission to access a non-existing study. // Possibly, run localdb against an unauthenticated portal or as a remote tests against public cbioportal - it('show error alert and query form for two studies, one invalid', function() { - var url = `${CBIOPORTAL_URL}/results/cancerTypesSummary?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=acc_tcgaa%2Cstudy_es_0&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - $('[data-test="StudySelect"]').waitForExist(); + it('show error alert and query form for two studies, one invalid', async function() { + const url = `${CBIOPORTAL_URL}/results/cancerTypesSummary?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=acc_tcgaa%2Cstudy_es_0&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await getElement('[data-test="StudySelect"]', { + waitForExist: true, + }); assert( - $('[data-test="unkown-study-warning"]') - .$('li=acc_tcgaa') - .isExisting() + await ( + await getNestedElement([ + '[data-test="unkown-study-warning"]', + 'li=acc_tcgaa', + ]) + ).isExisting() ); assert( - !$('[data-test="unkown-study-warning"]') - .$('li=study_es_0') - .isExisting() + !(await ( + await getNestedElement([ + '[data-test="unkown-study-warning"]', + 'li=study_es_0', + ]) + ).isExisting()) ); }); }); @@ -51,48 +67,58 @@ describe('study select page', function() { const placeSomeWhereOutsideSearchElement = 'a.tabAnchor_advanced'; const hg38Checkbox = '#input-hg38'; - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - $('[data-test=cancerTypeListContainer]').waitForExist(); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await getElement('[data-test=cancerTypeListContainer]', { + waitForExist: true, + }); // NOTE Somehow, we need to reload to load the external frontend. - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - $('[data-test=cancerTypeListContainer]').waitForExist(); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await getElement('[data-test=cancerTypeListContainer]', { + waitForExist: true, + }); }); - it('shows menu when focussing the text input', () => { - assert(!$(searchControlsMenu).isDisplayed()); - $(searchTextInput).click(); - assert($(searchControlsMenu).isDisplayed()); + it('shows menu when focussing the text input', async () => { + assert(!(await isDisplayed(searchControlsMenu))); + await clickElement(searchTextInput); + assert(await isDisplayed(searchControlsMenu)); }); - it('keeps showing menu after un-focussing the text input', () => { - assert($(searchControlsMenu).isDisplayed()); - $(placeSomeWhereOutsideSearchElement).click(); - assert($(searchControlsMenu).isDisplayed()); + it('keeps showing menu after un-focussing the text input', async () => { + assert(await isDisplayed(searchControlsMenu)); + await clickElement(placeSomeWhereOutsideSearchElement); + assert(await isDisplayed(searchControlsMenu)); }); describe('reference genome', () => { - it('shows reference genome form elements when studies on different reference genomes are present', () => { - assert($(searchControlsMenu).isDisplayed()); - assert($(referenceGenomeFormSection).isDisplayed()); + it('shows reference genome form elements when studies on different reference genomes are present', async () => { + assert(await isDisplayed(searchControlsMenu)); + assert(await isDisplayed(referenceGenomeFormSection)); }); - it('fills text input with search shorthand and filters studies when filtering studies via reference genome form element', () => { - assert($(referenceGenomeFormSection).isDisplayed()); - assert($(hg38StudyEntry).isDisplayed()); - $(hg38Checkbox).click(); - const textInSeachTextInput = $(searchTextInput).getValue(); - assert.equal(textInSeachTextInput, 'reference-genome:hg19'); - assert(!$(hg38StudyEntry).isDisplayed()); + it('fills text input with search shorthand and filters studies when filtering studies via reference genome form element', async () => { + assert(await isDisplayed(referenceGenomeFormSection)); + assert(await isDisplayed(hg38StudyEntry)); + await clickElement(hg38Checkbox); + const textInSearchTextInput = await ( + await getElement(searchTextInput) + ).getValue(); + assert.equal(textInSearchTextInput, 'reference-genome:hg19'); + assert(!(await isDisplayed(hg38StudyEntry))); }); - it('updates reference genome form elements and study filter when entering search shorthand in text input', () => { - $(searchTextInput).click(); - $(referenceGenomeFormSection).waitForExist(); - assert($(referenceGenomeFormSection).isDisplayed()); - assert(!$(hg38StudyEntry).isDisplayed()); - assert(!$(hg38Checkbox).isSelected()); - $(searchTextInput).setValue('Study'); // empty string does not trigger refresh - $(hg38StudyEntry).waitForExist(); - assert($(hg38Checkbox).isSelected()); + it('updates reference genome form elements and study filter when entering search shorthand in text input', async () => { + await clickElement(searchTextInput); + await getElement(referenceGenomeFormSection, { + waitForExist: true, + }); + assert(await isDisplayed(referenceGenomeFormSection)); + assert(!(await isDisplayed(hg38StudyEntry))); + assert(!(await isSelected(hg38Checkbox))); + await setInputText(searchTextInput, 'Study'); // empty string does not trigger refresh + await getElement(hg38StudyEntry, { + waitForExist: true, + }); + assert(await isSelected(hg38Checkbox)); }); }); }); diff --git a/end-to-end-test/local/specs/core/resultsview.screenshot.spec.js b/end-to-end-test/local/specs/core/resultsview.screenshot.spec.js index f0905151264..a2b98e0ce75 100644 --- a/end-to-end-test/local/specs/core/resultsview.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/resultsview.screenshot.spec.js @@ -2,49 +2,60 @@ const { goToUrlAndSetLocalStorage, COEXPRESSION_TIMEOUT, checkElementWithMouseDisabled, -} = require('../../../shared/specUtils'); -var assertScreenShotMatch = require('../../../shared/lib/testUtils') + getElement, + waitForElementDisplayed, +} = require('../../../shared/specUtils_Async'); +const assertScreenShotMatch = require('../../../shared/lib/testUtils') .assertScreenShotMatch; const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('results view mutation table', function() { - it('shows ASCN columns for study with ASCN data', () => { - var url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ascn_test_study&case_set_id=ascn_test_study_cnaseq&data_priority=0&gene_list=PIK3R1&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ascn_test_study_cna&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ascn_test_study_mutations&profileFilter=0&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - $( - 'table[class="simple-table table table-striped table-border-top"]' - ).waitForExist(); - res = browser.checkElement( + it('shows ASCN columns for study with ASCN data', async () => { + const url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ascn_test_study&case_set_id=ascn_test_study_cnaseq&data_priority=0&gene_list=PIK3R1&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ascn_test_study_cna&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ascn_test_study_mutations&profileFilter=0&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await getElement( + 'table[class="simple-table table table-striped table-border-top"]', + { + waitForExist: true, + } + ); + const res = await browser.checkElement( 'table[class="simple-table table table-striped table-border-top"]' ); assertScreenShotMatch(res); }); - it('shows ASCN columns for study where some samples have ASCN data and some do not', () => { - var url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ascn_test_study%2Cstudy_es_0&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&profileFilter=0&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - $( - 'table[class="simple-table table table-striped table-border-top"]' - ).waitForExist(); + it('shows ASCN columns for study where some samples have ASCN data and some do not', async () => { + const url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ascn_test_study%2Cstudy_es_0&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&profileFilter=0&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await getElement( + 'table[class="simple-table table table-striped table-border-top"]', + { + waitForExist: true, + } + ); - browser.execute(function() { + await browser.execute(function() { $('th').css({ color: 'red' }); }); - res = browser.checkElement( + const res = await browser.checkElement( 'table[class="simple-table table table-striped table-border-top"]' ); assertScreenShotMatch(res); }); - it('does not show ASCN columns study with no ASCN data', () => { - var url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - $( - 'table[class="simple-table table table-striped table-border-top"]' - ).waitForExist(); - res = browser.checkElement( + it('does not show ASCN columns study with no ASCN data', async () => { + const url = `${CBIOPORTAL_URL}/results/mutations?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await getElement( + 'table[class="simple-table table table-striped table-border-top"]', + { + waitForExist: true, + } + ); + const res = await browser.checkElement( 'table[class="simple-table table table-striped table-border-top"]' ); assertScreenShotMatch(res); @@ -52,26 +63,32 @@ describe('results view mutation table', function() { }); describe('cnsegments tab', () => { - it('renders cnsegments tab', () => { - var url = `${CBIOPORTAL_URL}/results/cnSegments?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - $('.igv-viewport-content').waitForDisplayed({ timeout: 60000 }); - var res = checkElementWithMouseDisabled('.cnSegmentsMSKTab', 0, { - hide: ['.qtip'], + it('renders cnsegments tab', async () => { + const url = `${CBIOPORTAL_URL}/results/cnSegments?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await waitForElementDisplayed('.igv-viewport-content', { + timeout: 60000, }); + const res = await checkElementWithMouseDisabled( + '.cnSegmentsMSKTab', + 0, + { + hide: ['.qtip'], + } + ); assertScreenShotMatch(res); }); }); describe('coexpression tab', () => { - it('renders coexpression tab', () => { - var url = `${CBIOPORTAL_URL}/results/coexpression?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=ERCC5&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url, true); - browser.setWindowSize(1600, 2000); - $('div[data-test="CoExpressionPlot"]').waitForDisplayed({ + it('renders coexpression tab', async () => { + const url = `${CBIOPORTAL_URL}/results/coexpression?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_cnaseq&data_priority=0&gene_list=ERCC5&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url, true); + await browser.setWindowSize(1600, 2000); + await waitForElementDisplayed('div[data-test="CoExpressionPlot"]', { timeout: COEXPRESSION_TIMEOUT, }); - var res = checkElementWithMouseDisabled( + const res = await checkElementWithMouseDisabled( '[data-test="coExpressionTabDiv"]', 0, { diff --git a/end-to-end-test/local/specs/core/resultsviewDisabledTabs.spec.js b/end-to-end-test/local/specs/core/resultsviewDisabledTabs.spec.js index 4e70e238a8c..6913f76b26c 100644 --- a/end-to-end-test/local/specs/core/resultsviewDisabledTabs.spec.js +++ b/end-to-end-test/local/specs/core/resultsviewDisabledTabs.spec.js @@ -1,52 +1,58 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorageWithProperty = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; -var { waitForOncoprint } = require('../../../shared/specUtils'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; +const assert = require('assert'); +const { + getElement, + waitForOncoprint, + goToUrlAndSetLocalStorage, + goToUrlAndSetLocalStorageWithProperty, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const url = `${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=study_es_0&case_set_id=study_es_0_all&data_priority=0&gene_list=ABLIM1%250ATMEM247&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&profileFilter=0&tab_index=tab_visualize`; describe('results view check possibility to disable tabs', function() { - it('check that all tabs can be disabled', () => { - goToUrlAndSetLocalStorage(url, true); - waitForOncoprint(); - const tabsContainer = $('.mainTabs'); - tabsContainer.waitForDisplayed(); - const tabs = getResultsViewTabNames(); + it('check that all tabs can be disabled', async () => { + await goToUrlAndSetLocalStorage(url, true); + await waitForOncoprint(); + const tabsContainer = await getElement('.mainTabs'); + await tabsContainer.waitForDisplayed(); + const tabs = await getResultsViewTabNames(); // test that each tab can be disabled - message = ''; - allTabsCanBeDisabled = true; - tabs.forEach(tab => { - goToUrlAndSetLocalStorageWithProperty(url, true, { + let message = ''; + let allTabsCanBeDisabled = true; + + for (const tab of tabs) { + await goToUrlAndSetLocalStorageWithProperty(url, true, { disabled_tabs: tab, }); - tabsContainer.waitForDisplayed(); - const tabAnchor = $('.tabAnchor.tabAnchor_' + tab); - if (tabAnchor.isDisplayed()) { - message = message + 'Tab ' + tab + ' could not be disabled; '; + await tabsContainer.waitForDisplayed(); + const tabAnchor = await getElement('.tabAnchor.tabAnchor_' + tab); + if (await tabAnchor.isDisplayed()) { + message += 'Tab ' + tab + ' could not be disabled; '; allTabsCanBeDisabled = false; } - }); + } assert(allTabsCanBeDisabled, message); }); }); -function getResultsViewTabNames() { +async function getResultsViewTabNames() { // getting all visible tabs, excluding the first one, oncoprint - const tabs = $('.nav-tabs') - .$$('.tabAnchor') - .filter(tab => tab.isDisplayed()) - .filter( - tab => tab.getAttribute('class') !== 'tabAnchor tabAnchor_oncoprint' - ) - .map(tab => - tab - .getAttribute('class') - .split('_') - .pop() - ); + const tabsElement = await (await getElement('.nav-tabs')).$$('.tabAnchor'); + + const tabs = []; + for (const tab of tabsElement) { + if (await tab.isDisplayed()) { + const classes = await tab.getAttribute('class'); + if (!classes.includes('tabAnchor_oncoprint')) { + const tabAnchorClass = classes + .split(' ') + .find(cls => cls.startsWith('tabAnchor_')); + if (tabAnchorClass) { + tabs.push(tabAnchorClass.split('_')[1]); + } + } + } + } return tabs; } diff --git a/end-to-end-test/local/specs/core/settings-menu.spec.js b/end-to-end-test/local/specs/core/settings-menu.spec.js index 6c9a5a44a2e..c6cfabc18fe 100644 --- a/end-to-end-test/local/specs/core/settings-menu.spec.js +++ b/end-to-end-test/local/specs/core/settings-menu.spec.js @@ -1,10 +1,10 @@ -var assert = require('assert'); +const assert = require('assert'); const { waitForOncoprint, setSettingsMenuOpen, -} = require('../../../shared/specUtils'); -var goToUrlAndSetLocalStorageWithProperty = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; + goToUrlAndSetLocalStorageWithProperty, + isSelected, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const oncoprintTabUrl = @@ -18,68 +18,68 @@ describe('results view settings/annotation menu', function() { const excludeVusCheckbox = '[data-test=HideVUS]'; describe('configuration by portal.properties', () => { - it('does not select oncokb, hotspots, custom drivers by default when property set', () => { - openOncoprint(oncoprintTabUrl, { + it('does not select oncokb, hotspots, custom drivers by default when property set', async () => { + await openOncoprint(oncoprintTabUrl, { oncoprint_oncokb_default: false, oncoprint_hotspots_default: false, oncoprint_custom_driver_annotation_binary_default: false, }); - assert(!$(oncoprintCheckbox).isSelected()); - assert(!$(hotspotsCheckbox).isSelected()); - assert(!$(customAnnotationCheckbox).isSelected()); + assert(!(await isSelected(oncoprintCheckbox))); + assert(!(await isSelected(hotspotsCheckbox))); + assert(!(await isSelected(customAnnotationCheckbox))); }); - it('does select oncokb by default when property set', () => { - openOncoprint(oncoprintTabUrl, { + it('does select oncokb by default when property set', async () => { + await openOncoprint(oncoprintTabUrl, { oncoprint_oncokb_default: true, oncoprint_hotspots_default: false, oncoprint_custom_driver_annotation_binary_default: false, }); - assert($(oncoprintCheckbox).isSelected()); - assert(!$(hotspotsCheckbox).isSelected()); - assert(!$(customAnnotationCheckbox).isSelected()); + assert(await isSelected(oncoprintCheckbox)); + assert(!(await isSelected(hotspotsCheckbox))); + assert(!(await isSelected(customAnnotationCheckbox))); }); - it('does select hotspots by default when property set', () => { - openOncoprint(oncoprintTabUrl, { + it('does select hotspots by default when property set', async () => { + await openOncoprint(oncoprintTabUrl, { oncoprint_oncokb_default: false, oncoprint_hotspots_default: true, oncoprint_custom_driver_annotation_binary_default: false, }); - assert(!$(oncoprintCheckbox).isSelected()); - assert($(hotspotsCheckbox).isSelected()); - assert(!$(customAnnotationCheckbox).isSelected()); + assert(!(await isSelected(oncoprintCheckbox))); + assert(await isSelected(hotspotsCheckbox)); + assert(!(await isSelected(customAnnotationCheckbox))); }); - it('does select custom driver annotations by default when property set', () => { + it('does select custom driver annotations by default when property set', async () => { openOncoprint(oncoprintTabUrl, { oncoprint_oncokb_default: false, oncoprint_hotspots_default: false, oncoprint_custom_driver_annotation_binary_default: true, }); - assert(!$(oncoprintCheckbox).isSelected()); - assert(!$(hotspotsCheckbox).isSelected()); - assert($(customAnnotationCheckbox).isSelected()); + assert(!(await isSelected(oncoprintCheckbox))); + assert(!(await isSelected(hotspotsCheckbox))); + assert(await isSelected(customAnnotationCheckbox)); }); - it('does not select VUS exclusion by default when property set', () => { - openOncoprint(oncoprintTabUrl, { + it('does not select VUS exclusion by default when property set', async () => { + await openOncoprint(oncoprintTabUrl, { oncoprint_hide_vus_default: false, }); - assert(!$(excludeVusCheckbox).isSelected()); + assert(!(await isSelected(excludeVusCheckbox))); }); - it('does select VUS exclusion by default when property set', () => { - openOncoprint(oncoprintTabUrl, { + it('does select VUS exclusion by default when property set', async () => { + await openOncoprint(oncoprintTabUrl, { oncoprint_hide_vus_default: true, }); - assert($(excludeVusCheckbox).isSelected()); + assert(await isSelected(excludeVusCheckbox)); }); }); }); -const openOncoprint = (url, property) => { - goToUrlAndSetLocalStorageWithProperty(url, true, property); - waitForOncoprint(); - setSettingsMenuOpen(true, 'GlobalSettingsButton'); +const openOncoprint = async (url, property) => { + await goToUrlAndSetLocalStorageWithProperty(url, true, property); + await waitForOncoprint(); + await setSettingsMenuOpen(true, 'GlobalSettingsButton'); }; diff --git a/end-to-end-test/local/specs/core/studyview.screenshot.spec.js b/end-to-end-test/local/specs/core/studyview.screenshot.spec.js index 2fb2887ef54..73366bf5462 100644 --- a/end-to-end-test/local/specs/core/studyview.screenshot.spec.js +++ b/end-to-end-test/local/specs/core/studyview.screenshot.spec.js @@ -1,15 +1,17 @@ const assert = require('assert'); -const assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; +const { assertScreenShotMatch } = require('../../../shared/lib/testUtils'); const { checkElementWithMouseDisabled, goToUrlAndSetLocalStorage, waitForNetworkQuiet, setDropdownOpen, jsApiHover, - getElementByTestHandle, - jq, -} = require('../../../shared/specUtils'); + waitForElementDisplayed, + clickElement, + getElement, + getNestedElement, + getCSSProperty, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const ADD_CHART_BUTTON = "[data-test='add-charts-button']"; @@ -99,42 +101,42 @@ describe('study view generic assay categorical/binary features', function() { }); describe('Test the Custom data tab', function() { - it('Add custom data tab should have numerical and categorical selector', () => { + it('Add custom data tab should have numerical and categorical selector', async () => { const url = `${CBIOPORTAL_URL}/study?id=lgg_ucsf_2014_test_generic_assay`; - goToUrlAndSetLocalStorage(url, true); - waitForNetworkQuiet(); + await goToUrlAndSetLocalStorage(url, true); + await waitForNetworkQuiet(); - $(ADD_CHART_BUTTON).waitForDisplayed({ + await waitForElementDisplayed(ADD_CHART_BUTTON, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CHART_BUTTON).click(); + await clickElement(ADD_CHART_BUTTON); - waitForNetworkQuiet(); + await waitForNetworkQuiet(); // Change to custom tab - $(ADD_CUSTOM_CHART_TAB).waitForDisplayed({ + await waitForElementDisplayed(ADD_CUSTOM_CHART_TAB, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CUSTOM_CHART_TAB).click(); - const res = browser.checkElement('div.msk-tab.custom'); + await clickElement(ADD_CUSTOM_CHART_TAB); + const res = await browser.checkElement('div.msk-tab.custom'); assertScreenShotMatch(res); }); - it('Selecting numerical for custom data should return a bar chart', () => { + it('Selecting numerical for custom data should return a bar chart', async () => { const url = `${CBIOPORTAL_URL}/study?id=lgg_ucsf_2014_test_generic_assay`; - goToUrlAndSetLocalStorage(url, true); - waitForNetworkQuiet(); + await goToUrlAndSetLocalStorage(url, true); + await waitForNetworkQuiet(); - $(ADD_CHART_BUTTON).waitForDisplayed({ + await waitForElementDisplayed(ADD_CHART_BUTTON, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CHART_BUTTON).click(); + await clickElement(ADD_CHART_BUTTON); - waitForNetworkQuiet(); + await waitForNetworkQuiet(); // Change to custom tab - $(ADD_CUSTOM_CHART_TAB).waitForDisplayed({ + await waitForElementDisplayed(ADD_CUSTOM_CHART_TAB, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CUSTOM_CHART_TAB).click(); - CUSTOM_CHART_TAB = $('div.msk-tab.custom'); + await clickElement(ADD_CUSTOM_CHART_TAB); + CUSTOM_CHART_TAB = await getElement('div.msk-tab.custom'); // Add values to the input form }); }); @@ -144,153 +146,171 @@ describe('study view x vs y charts', function() { const X_VS_Y_CHART = `div[data-test="chart-container-X-VS-Y-AGE-MUTATION_COUNT"]`; const X_VS_Y_HAMBURGER_ICON = `${X_VS_Y_CHART} [data-test="chart-header-hamburger-icon"]`; const X_VS_Y_MENU = `${X_VS_Y_CHART} [data-test="chart-header-hamburger-icon-menu"]`; - before(() => { + before(async () => { const url = `${CBIOPORTAL_URL}/study?id=lgg_ucsf_2014_test_generic_assay`; - goToUrlAndSetLocalStorage(url, true); + await goToUrlAndSetLocalStorage(url, true); // remove mutation count vs diagnosis age chart if it exists - if ($(X_VS_Y_CHART).isExisting()) { - jsApiHover(X_VS_Y_CHART); - $(X_VS_Y_CHART) - .$('[data-test="deleteChart"]') - .waitForDisplayed(); - $(X_VS_Y_CHART) - .$('[data-test="deleteChart"]') - .click(); - browser.waitUntil(() => { - return !$(X_VS_Y_CHART).isExisting(); + if (await (await getElement(X_VS_Y_CHART)).isExisting()) { + await jsApiHover(X_VS_Y_CHART); + await await getNestedElement([ + X_VS_Y_CHART, + '[data-test="deleteChart"]', + ]).waitForDisplayed(); + await ( + await getElement([X_VS_Y_CHART, '[data-test="deleteChart"]']) + ).click(); + await browser.waitUntil(async () => { + return !(await (await getElement(X_VS_Y_CHART)).isExisting()); }); } }); - it('adds mutation count vs diagnosis age chart', () => { - $(ADD_CHART_BUTTON).waitForDisplayed({ + it('adds mutation count vs diagnosis age chart', async () => { + await waitForElementDisplayed(ADD_CHART_BUTTON, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CHART_BUTTON).click(); + await clickElement(ADD_CHART_BUTTON); // Change to X vs Y tab - $(ADD_CHART_X_VS_Y_TAB).waitForDisplayed({ + await waitForElementDisplayed(ADD_CHART_X_VS_Y_TAB, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - $(ADD_CHART_X_VS_Y_TAB).click(); + await clickElement(ADD_CHART_X_VS_Y_TAB); // Add Mutation Count vs Diagnosis Age chart // X-axis: diagnosis age - $('.xvsy-x-axis-selector').waitForDisplayed(); - $('.xvsy-x-axis-selector').click(); - $('.xvsy-x-axis-selector') - .$('div=Diagnosis Age') - .waitForDisplayed(); - $('.xvsy-x-axis-selector') - .$('div=Diagnosis Age') - .click(); + await waitForElementDisplayed('.xvsy-x-axis-selector'); + await clickElement('.xvsy-x-axis-selector'); + await ( + await getNestedElement([ + '.xvsy-x-axis-selector', + 'div=Diagnosis Age', + ]) + ).waitForDisplayed(); + await ( + await getNestedElement([ + '.xvsy-x-axis-selector', + 'div=Diagnosis Age', + ]) + ).click(); // Y-axis: mutation count - $('.xvsy-y-axis-selector').waitForDisplayed(); - $('.xvsy-y-axis-selector').click(); - $('.xvsy-y-axis-selector') - .$('div=Mutation Count') - .waitForDisplayed(); - $('.xvsy-y-axis-selector') - .$('div=Mutation Count') - .click(); + await waitForElementDisplayed('.xvsy-y-axis-selector'); + await clickElement('.xvsy-y-axis-selector'); + await ( + await getNestedElement([ + '.xvsy-y-axis-selector', + 'div=Mutation Count', + ]) + ).waitForDisplayed(); + await ( + await getNestedElement([ + '.xvsy-y-axis-selector', + 'div=Mutation Count', + ]) + ).click(); // temporarily allow button to not be enabled // TODO: issue # 9226 try { // submit - $('button[data-test="x-vs-y-submit-btn"]').waitForEnabled(); - $('button[data-test="x-vs-y-submit-btn"]').click(); + await ( + await getElement('button[data-test="x-vs-y-submit-btn"]') + ).waitForEnabled(); + await clickElement('button[data-test="x-vs-y-submit-btn"]'); } catch (e) { // this should only fail because the submit button isnt enabled because the chart already still exists } - $(X_VS_Y_CHART).waitForExist(); + await getElement(X_VS_Y_CHART, { waitForExist: true }); - const res = checkElementWithMouseDisabled(X_VS_Y_CHART); + const res = await checkElementWithMouseDisabled(X_VS_Y_CHART); assertScreenShotMatch(res); }); - it('turns on log scale from dropdown menu', () => { - jsApiHover(X_VS_Y_CHART); - $(X_VS_Y_HAMBURGER_ICON).waitForDisplayed(); - jsApiHover(X_VS_Y_HAMBURGER_ICON); - $(X_VS_Y_MENU).waitForDisplayed(); - $(X_VS_Y_MENU) - .$('a.logScaleCheckbox') - .click(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(X_VS_Y_CHART); + it('turns on log scale from dropdown menu', async () => { + await jsApiHover(X_VS_Y_CHART); + await waitForElementDisplayed(X_VS_Y_HAMBURGER_ICON); + await jsApiHover(X_VS_Y_HAMBURGER_ICON); + await waitForElementDisplayed(X_VS_Y_MENU); + await ( + await getNestedElement([X_VS_Y_MENU, 'a.logScaleCheckbox']) + ).click(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(X_VS_Y_CHART); assertScreenShotMatch(res); }); - it('swaps axis from dropdown menu', () => { - jsApiHover(X_VS_Y_CHART); - $(X_VS_Y_HAMBURGER_ICON).waitForDisplayed(); - jsApiHover(X_VS_Y_HAMBURGER_ICON); - $(X_VS_Y_MENU).waitForDisplayed(); - $(X_VS_Y_MENU) - .$('[data-test="swapAxes"]') - .click(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(X_VS_Y_CHART); + it('swaps axis from dropdown menu', async () => { + await jsApiHover(X_VS_Y_CHART); + await waitForElementDisplayed(X_VS_Y_HAMBURGER_ICON); + await jsApiHover(X_VS_Y_HAMBURGER_ICON); + await waitForElementDisplayed(X_VS_Y_MENU); + await ( + await getNestedElement([X_VS_Y_MENU, '[data-test="swapAxes"]']) + ).click(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(X_VS_Y_CHART); assertScreenShotMatch(res); }); }); describe('study view editable breadcrumbs', () => { - it('breadcrumbs are editable for mutation count chart', () => { + it('breadcrumbs are editable for mutation count chart', async () => { const url = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`; // set up the page without filters - goToUrlAndSetLocalStorage(url, true); - waitForNetworkQuiet(); + await goToUrlAndSetLocalStorage(url, true); + await waitForNetworkQuiet(); // add filters (this is necessary to do separately because goToUrlAndSetLocalStorage doesn't play nice with hash params - browser.url( + await browser.url( `${url}#filterJson={"clinicalDataFilters":[{"attributeId":"MUTATION_COUNT","values":[{"start":15,"end":20},{"start":20,"end":25},{"start":25,"end":30},{"start":30,"end":35},{"start":35,"end":40},{"start":40,"end":45}]}],"studyIds":["lgg_ucsf_2014_test_generic_assay"],"alterationFilter":{"copyNumberAlterationEventTypes":{"AMP":true,"HOMDEL":true},"mutationEventTypes":{"any":true},"structuralVariants":null,"includeDriver":true,"includeVUS":true,"includeUnknownOncogenicity":true,"includeUnknownTier":true,"includeGermline":true,"includeSomatic":true,"includeUnknownStatus":true,"tiersBooleanMap":{}}}` ); - waitForNetworkQuiet(); - $('.userSelections').waitForDisplayed(); + await waitForNetworkQuiet(); + await waitForElementDisplayed('.userSelections'); - const element = $('.userSelections').$('span=15'); + const element = await getNestedElement(['.userSelections', 'span=15']); element.click(); element.keys(['ArrowRight', 'ArrowRight', 'Backspace', 'Backspace']); element.setValue(13); element.keys(['Enter']); // Wait for everything to settle - waitForNetworkQuiet(); - browser.pause(1000); + await waitForNetworkQuiet(); + await browser.pause(1000); - const res = checkElementWithMouseDisabled('#mainColumn'); + const res = await checkElementWithMouseDisabled('#mainColumn'); assertScreenShotMatch(res); }); - after(() => { + after(async () => { // reset charts to reset custom bin - setDropdownOpen(true, ADD_CHART_BUTTON, 'button=Reset charts'); - $('button=Reset charts').click(); - $('.modal-content') - .$('button=Confirm') - .waitForDisplayed(); - $('.modal-content') - .$('button=Confirm') - .click(); + await setDropdownOpen(true, ADD_CHART_BUTTON, 'button=Reset charts'); + await clickElement('button=Reset charts'); + await ( + await getNestedElement(['.modal-content', 'button=Confirm']) + ).waitForDisplayed(); + await ( + await getNestedElement(['.modal-content', 'button=Confirm']) + ).click(); // wait for session to save - browser.pause(4000); - waitForNetworkQuiet(); + await browser.pause(4000); + await waitForNetworkQuiet(); }); }); describe('cancer gene filter', function() { this.retries(0); - it('cancer gene filter should by default be disabled', () => { + it('cancer gene filter should by default be disabled', async () => { const url = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`; // set up the page without filters - goToUrlAndSetLocalStorage(url, true); - $( - `${MUTATIONS_GENES_TABLE} [data-test='gene-column-header']` - ).waitForDisplayed({ timeout: WAIT_FOR_VISIBLE_TIMEOUT }); + await goToUrlAndSetLocalStorage(url, true); + await waitForElementDisplayed( + `${MUTATIONS_GENES_TABLE} [data-test='gene-column-header']`, + { timeout: WAIT_FOR_VISIBLE_TIMEOUT } + ); assert.equal( - $( - `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}` + await ( + await getElement( + `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}` + ) ).isExisting(), true ); @@ -302,12 +322,15 @@ describe('cancer gene filter', function() { ); }); - it('cancer gene filter should remove non cancer genes', () => { - $(`${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}`).click(); + it('cancer gene filter should remove non cancer genes', async () => { + await clickElement( + `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}` + ); assert.equal( - $( - `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}` - ).getCSSProperty('color').parsed.hex, + await getCSSProperty( + `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}`, + 'color' + ).parsed.hex, '#000000' ); assertScreenShotMatch( @@ -315,20 +338,24 @@ describe('cancer gene filter', function() { ); }); - it('reset charts button should revert and disable cancer gene filter', () => { - $(ADD_CHART_BUTTON).waitForDisplayed({ + it('reset charts button should revert and disable cancer gene filter', async () => { + await waitForElementDisplayed(ADD_CHART_BUTTON, { timeout: WAIT_FOR_VISIBLE_TIMEOUT, }); - browser.waitUntil( - () => { - const isOpen = $('button=Reset charts').isExisting() - ? $('button=Reset charts').isDisplayedInViewport() + await browser.waitUntil( + async () => { + const isOpen = (await ( + await getElement('button=Reset charts') + ).isExisting()) + ? await ( + await getElement('button=Reset charts') + ).isDisplayedInViewport() : false; if (isOpen) { return true; } else { - $(ADD_CHART_BUTTON).click(); + await clickElement(ADD_CHART_BUTTON); } }, { @@ -337,21 +364,23 @@ describe('cancer gene filter', function() { } ); - $('button=Reset charts').click(); - $('.modal-content') - .$('button=Confirm') - .waitForDisplayed(); - $('.modal-content') - .$('button=Confirm') - .click(); + await clickElement('button=Reset charts'); + await await getNestedElement([ + '.modal-content', + 'button=Confirm', + ]).waitForDisplayed(); + await ( + await getNestedElement(['.modal-content', 'button=Confirm']) + ).click(); assert.equal( - $( - `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}` - ).getCSSProperty('color').parsed.hex, + await getCSSProperty( + `${MUTATIONS_GENES_TABLE} ${CANCER_GENE_FILTER_ICON}`, + 'color' + ).parsed.hex, '#bebebe' ); assertScreenShotMatch( - checkElementWithMouseDisabled(MUTATIONS_GENES_TABLE) + await checkElementWithMouseDisabled(MUTATIONS_GENES_TABLE) ); }); }); diff --git a/end-to-end-test/local/specs/core/version.spec.js b/end-to-end-test/local/specs/core/version.spec.js index 385b480ae27..e96647f0f05 100644 --- a/end-to-end-test/local/specs/core/version.spec.js +++ b/end-to-end-test/local/specs/core/version.spec.js @@ -1,20 +1,18 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var useExternalFrontend = require('../../../shared/specUtils') - .useExternalFrontend; +const { + goToUrlAndSetLocalStorage, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); // this consoles the backend version to make sure // we are running correct backend describe('Backend version', function() { - it('Retrieves backend info', () => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - browser.setTimeout({ script: 5000 }); - const d = browser.executeAsync(function(done) { + it('Retrieves backend info', async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await browser.setTimeout({ script: 5000 }); + const d = await browser.executeAsync(async done => { // browser context - you may not access client or console - fetch('/api/info').then(d => { + await fetch('/api/info').then(d => { d.json().then(t => { done(JSON.stringify(t)); }); diff --git a/end-to-end-test/local/specs/custom-driver-annotations-in-result-view.spec.js b/end-to-end-test/local/specs/custom-driver-annotations-in-result-view.spec.js index 8589618b33c..17afdbc3296 100644 --- a/end-to-end-test/local/specs/custom-driver-annotations-in-result-view.spec.js +++ b/end-to-end-test/local/specs/custom-driver-annotations-in-result-view.spec.js @@ -1,9 +1,13 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; -var setSettingsMenuOpen = require('../../shared/specUtils').setSettingsMenuOpen; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + waitForOncoprint, + setSettingsMenuOpen, + getElement, + isSelected, + getNestedElement, + clickElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const oncoprintTabUrl = @@ -18,164 +22,184 @@ const oncoprintTabUrlStructVar = CBIOPORTAL_URL + '/results/oncoprint?Action=Submit&cancer_study_list=study_es_0&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cstructural_variants%2Cgistic&case_set_id=study_es_0_cnaseq&gene_list=TMPRSS2&geneset_list=%20&tab_index=tab_visualize'; -describe('custom driver annotations feature in result view', function() { - describe('oncoprint tab - mutations', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); - setSettingsMenuOpen(true, 'GlobalSettingsButton'); +describe('custom driver annotations feature in result view', () => { + describe.only('oncoprint tab - mutations', async () => { + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); + await setSettingsMenuOpen(true, 'GlobalSettingsButton'); }); - it('shows custom driver annotation elements in config menu', () => { - var topCheckBox = $('input[data-test=annotateCustomBinary]'); - assert(topCheckBox.isSelected()); - - var tiersCheckboxes = $('span[data-test=annotateCustomTiers]').$$( - 'input' - ); - assert(tiersCheckboxes[0].isSelected()); - assert(tiersCheckboxes[1].isSelected()); + it('shows custom driver annotation elements in config menu', async () => { + assert(await isSelected('input[data-test=annotateCustomBinary]')); + const tiersCheckboxes = await ( + await getElement('span[data-test=annotateCustomTiers]') + ).$$('input'); + assert(await tiersCheckboxes[0].isSelected()); + assert(await tiersCheckboxes[1].isSelected()); }); - it('allows deselection of Tiers checkboxes', () => { - var class1Checkbox = $('label*=Class 1').$('input'); - class1Checkbox.click(); - waitForOncoprint(); - assert(!class1Checkbox.isSelected()); - - var class2Checkbox = $('label*=Class 2').$('input'); - class2Checkbox.click(); - waitForOncoprint(); - assert(!class2Checkbox.isSelected()); + it('allows deselection of Tiers checkboxes', async () => { + const class1Checkbox = await getNestedElement([ + 'label*=Class 1', + 'input', + ]); + await class1Checkbox.click(); + await waitForOncoprint(); + assert(await !class1Checkbox.isSelected()); + + const class2Checkbox = getNestedElement([ + 'label*=Class 2', + 'input', + ]); + await class2Checkbox.click(); + await waitForOncoprint(); + assert(await !class2Checkbox.isSelected()); }); - it('updates selected samples when VUS alterations are excluded', () => { + it('updates selected samples when VUS alterations are excluded', async () => { // deselected all checkboxes except Custom driver annotation - $('input[data-test=annotateHotspots]').click(); - $('label*=Class 1') - .$('input') - .click(); - $('label*=Class 2') - .$('input') - .click(); - - $('input[data-test=HideVUS]').click(); - waitForOncoprint(); - assert($('div.alert-info*=1 mutation').isExisting()); - $('label*=Class 1') - .$('input') - .click(); - waitForOncoprint(); - assert($('div.alert-info*=1 mutation').isExisting()); - - $('label*=Class 2') - .$('input') - .click(); - waitForOncoprint(); - assert(!$('div.alert-info').isExisting()); + await clickElement('input[data-test=annotateHotspots]'); + await (await getNestedElement(['label*=Class 1', 'input'])).click(); + await (await getNestedElement(['label*=Class 2', 'input'])).click(); + + await clickElement('input[data-test=HideVUS]'); + await waitForOncoprint(); + assert( + await ( + await getElement('div.alert-info*=1 mutation') + ).isExisting() + ); + await (await getNestedElement(['label*=Class 1', 'input'])).click(); + await waitForOncoprint(); + assert( + await ( + await getElement('div.alert-info*=1 mutation') + ).isExisting() + ); + + await (await getNestedElement(['label*=Class 2', 'input'])).click(); + await waitForOncoprint(); + assert(!(await (await getElement('div.alert-info')).isExisting())); }); }); describe('oncoprint tab - discrete CNA', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrlCna, true); - waitForOncoprint(); - setSettingsMenuOpen(true, 'GlobalSettingsButton'); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrlCna, true); + await waitForOncoprint(); + await setSettingsMenuOpen(true, 'GlobalSettingsButton'); }); - it('shows custom driver annotation elements in config menu', () => { - var topCheckBox = $('input[data-test=annotateCustomBinary]'); - assert(topCheckBox.isSelected()); - - var tiersCheckboxes = $('span[data-test=annotateCustomTiers]').$$( - 'input' - ); - assert(tiersCheckboxes[0].isSelected()); - assert(tiersCheckboxes[1].isSelected()); + it('shows custom driver annotation elements in config menu', async () => { + assert(await isSelected('input[data-test=annotateCustomBinary]')); + const tiersCheckboxes = await ( + await getElement('span[data-test=annotateCustomTiers]') + ).$$('input'); + assert(await tiersCheckboxes[0].isSelected()); + assert(await tiersCheckboxes[1].isSelected()); }); - it('allows deselection of Tiers checkboxes', () => { - var class1Checkbox = $('label*=Class 1').$('input'); - class1Checkbox.click(); - waitForOncoprint(); - assert(!class1Checkbox.isSelected()); - - var class2Checkbox = $('label*=Class 2').$('input'); - class2Checkbox.click(); - waitForOncoprint(); - assert(!class2Checkbox.isSelected()); + it('allows deselection of Tiers checkboxes', async () => { + const class1Checkbox = await getNestedElement([ + 'label*=Class 1', + 'input', + ]); + await class1Checkbox.click(); + await waitForOncoprint(); + assert(!(await class1Checkbox.isSelected())); + + const class2Checkbox = await getNestedElement([ + 'label*=Class 2', + 'input', + ]); + await class2Checkbox.click(); + await waitForOncoprint(); + assert(!(await class2Checkbox.isSelected())); }); - it('updates selected samples when VUS alterations are excluded', () => { + it('updates selected samples when VUS alterations are excluded', async () => { // deselected all checkboxes except Custom driver annotation - $('input[data-test=annotateHotspots]').click(); - $('label*=Class 1') - .$('input') - .click(); - $('label*=Class 2') - .$('input') - .click(); - - $('input[data-test=HideVUS]').click(); - waitForOncoprint(); + await clickElement('input[data-test=annotateHotspots]'); + await (await getNestedElement(['label*=Class 1', 'input'])).click(); + await (await getNestedElement(['label*=Class 2', 'input'])).click(); + + await clickElement('input[data-test=HideVUS]'); + await waitForOncoprint(); assert( - $('div.alert-info*=17 copy number alterations').isExisting() + await ( + await getElement( + 'div.alert-info*=17 copy number alterations' + ) + ).isExisting() ); - $('label*=Class 1') - .$('input') - .click(); - waitForOncoprint(); + await (await getNestedElement(['label*=Class 1', 'input'])).click(); + await waitForOncoprint(); assert( - $('div.alert-info*=17 copy number alterations').isExisting() + await ( + await getElement( + 'div.alert-info*=17 copy number alterations' + ) + ).isExisting() ); - $('label*=Class 2') - .$('input') - .click(); - waitForOncoprint(); + await (await getNestedElement(['label*=Class 2', 'input'])).click(); + + await waitForOncoprint(); assert( - $('div.alert-info*=16 copy number alterations').isExisting() + await ( + await getElement( + 'div.alert-info*=16 copy number alterations' + ) + ).isExisting() ); }); }); describe('oncoprint tab - structural variants', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrlStructVar, true); - waitForOncoprint(); - setSettingsMenuOpen(true, 'GlobalSettingsButton'); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrlStructVar, true); + await waitForOncoprint(); + await setSettingsMenuOpen(true, 'GlobalSettingsButton'); }); - it('shows custom driver annotation elements in config menu', () => { - var topCheckBox = $('input[data-test=annotateCustomBinary]'); - assert(topCheckBox.isSelected()); - - var tiersCheckboxes = $('span[data-test=annotateCustomTiers]').$$( - 'input' - ); - assert(tiersCheckboxes[0].isSelected()); + it('shows custom driver annotation elements in config menu', async () => { + assert(await isSelected('input[data-test=annotateCustomBinary]')); + const tiersCheckboxes = await ( + await getElement('span[data-test=annotateCustomTiers]') + ).$$('input'); + assert(await tiersCheckboxes[0].isSelected()); }); - it('allows deselection of Tiers checkboxes', () => { - var class1Checkbox = $('label*=Class 1').$('input'); - class1Checkbox.click(); - waitForOncoprint(); - assert(!class1Checkbox.isSelected()); + it('allows deselection of Tiers checkboxes', async () => { + const class1Checkbox = await getNestedElement([ + 'label*=Class 1', + 'input', + ]); + await class1Checkbox.click(); + await waitForOncoprint(); + assert(!(await class1Checkbox.isSelected())); }); - it('updates selected samples when VUS alterations are excluded', () => { - $('input[data-test=annotateHotspots]').click(); - $('input[data-test=annotateOncoKb]').click(); - $('input[data-test=HideVUS]').click(); - waitForOncoprint(); - assert($('div.alert-info*=1 structural variant').isExisting()); - - $('label*=Class 1') - .$('input') - .click(); - waitForOncoprint(); - assert($('div.alert-info*=2 structural variants').isExisting()); + it('updates selected samples when VUS alterations are excluded', async () => { + await clickElement('input[data-test=annotateHotspots]'); + await clickElement('input[data-test=annotateOncoKb]'); + await clickElement('input[data-test=HideVUS]'); + await waitForOncoprint(); + assert( + await ( + await getElement('div.alert-info*=1 structural variant') + ).isExisting() + ); + + await getNestedElement(['label*=Class 1', 'input']).click(); + await waitForOncoprint(); + assert( + await ( + await getElement('div.alert-info*=2 structural variants') + ).isExisting() + ); }); }); }); diff --git a/end-to-end-test/local/specs/custom-driver-annotations-in-study-view.spec.js b/end-to-end-test/local/specs/custom-driver-annotations-in-study-view.spec.js index cc1989e61ce..64cac861668 100644 --- a/end-to-end-test/local/specs/custom-driver-annotations-in-study-view.spec.js +++ b/end-to-end-test/local/specs/custom-driver-annotations-in-study-view.spec.js @@ -1,10 +1,13 @@ const assert = require('assert'); const { waitForNetworkQuiet, - waitForStudyView, -} = require('../../shared/specUtils'); -const goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; + goToUrlAndSetLocalStorage, + getNestedElement, + getElement, + clickElement, + waitForElementDisplayed, + isSelected, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const STUDY_VIEW_URL = `${CBIOPORTAL_URL}/study/summary?id=study_es_0`; @@ -23,97 +26,107 @@ const SHOW_UNKNOWN_ONCOGENICITY = `input[data-test="ShowUnknownOncogenicity"]`; describe('custom driver annotations feature in study view', function() { describe('structural variants', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(STUDY_VIEW_URL, true); - waitForNetworkQuiet(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(STUDY_VIEW_URL, true); + await waitForNetworkQuiet(); }); - it('shows all structural variants', () => { - $(SV_TABLE) - .$(BRAF_ROW) - .waitForDisplayed(); - expect($(SV_TABLE).$$(ANY_ROW).length).toBe(21); - let geneName = $(SV_TABLE) - .$(BRAF_ROW) - .$(GENE_NAME) - .getText(); + it('shows all structural variants', async () => { + const elements = await getNestedElement([SV_TABLE, BRAF_ROW]); + await elements.waitForDisplayed(); + + expect( + (await (await getElement(SV_TABLE)).$$(ANY_ROW)).length + ).toBe(21); + let geneName = await ( + await getNestedElement([SV_TABLE, BRAF_ROW, GENE_NAME]) + ).getText(); + expect(geneName).toBe('BRAF'); - const alterations = $(SV_TABLE) - .$(BRAF_ROW) - .$(ALTERATIONS_TOTAL); - expect(alterations.getText()).toBe('37'); - const alterationCases = $(SV_TABLE) - .$(BRAF_ROW) - .$(ALTERATION_CASES) - .getText(); + const alterations = await getNestedElement([ + SV_TABLE, + BRAF_ROW, + ALTERATIONS_TOTAL, + ]); + expect(await alterations.getText()).toBe('37'); + + const alterationCases = await ( + await getNestedElement([SV_TABLE, BRAF_ROW, ALTERATION_CASES]) + ).getText(); expect(alterationCases).toBe('35'); }); - it('can exclude unknown (and NULL) driver tiers', () => { - $(ALTERATION_MENU_BTN).click(); - $(SHOW_UNKNOWN_TIER).waitForDisplayed(5000); - assert($(SHOW_UNKNOWN_TIER).isSelected()); - $(SHOW_UNKNOWN_TIER).click(); - $(SV_TABLE) - .$(BRAF_ROW) - .waitForDisplayed(); - expect($(SV_TABLE).$$(ANY_ROW).length).toBe(10); - const alterations = $(SV_TABLE) - .$(BRAF_ROW) - .$(ALTERATIONS_TOTAL) - .getText(); + it('can exclude unknown (and NULL) driver tiers', async () => { + await clickElement(ALTERATION_MENU_BTN); + await waitForElementDisplayed(SHOW_UNKNOWN_TIER, { timeout: 5000 }); + assert(await isSelected(SHOW_UNKNOWN_TIER)); + await clickElement(SHOW_UNKNOWN_TIER); + + await ( + await getNestedElement([SV_TABLE, BRAF_ROW]) + ).waitForDisplayed(); + + expect( + (await (await getElement(SV_TABLE)).$$(ANY_ROW)).length + ).toBe(10); + const alterations = await ( + await getNestedElement([SV_TABLE, BRAF_ROW, ALTERATIONS_TOTAL]) + ).getText(); expect(alterations).toBe('1'); - const brafCases = $(SV_TABLE) - .$(BRAF_ROW) - .$(ALTERATION_CASES) - .getText(); + const brafCases = await ( + await getNestedElement([SV_TABLE, BRAF_ROW, ALTERATION_CASES]) + ).getText(); expect(brafCases).toBe('1'); }); - it('can exclude custom driver tiers', () => { - $(ALTERATION_MENU_BTN).click(); - $(SHOW_UNKNOWN_TIER).waitForDisplayed(5000); - assert($(SHOW_UNKNOWN_TIER).isSelected()); - $(SHOW_UNKNOWN_TIER).click(); + it('can exclude custom driver tiers', async () => { + await clickElement(ALTERATION_MENU_BTN); + await waitForElementDisplayed(SHOW_UNKNOWN_TIER, { timeout: 5000 }); + assert(await isSelected(SHOW_UNKNOWN_TIER)); + await clickElement(SHOW_UNKNOWN_TIER); - assert($(SHOW_CLASS_3).isSelected()); - $(SHOW_CLASS_3).click(); + assert(await isSelected(SHOW_CLASS_3)); + await clickElement(SHOW_CLASS_3); - assert($(SHOW_CLASS_4).isSelected()); - $(SHOW_CLASS_4).click(); + assert(await isSelected(SHOW_CLASS_4)); + await clickElement(SHOW_CLASS_4); - $(SV_TABLE) - .$(ANY_ROW) - .waitForDisplayed(); + await ( + await getNestedElement([SV_TABLE, ANY_ROW]) + ).waitForDisplayed(); - expect($(SV_TABLE).$$(ANY_ROW).length).toBe(5); - assert(getAllGeneNames() === 'ALK,EGFR,EML4,ERG,TMPRSS2'); + expect( + (await (await getElement(SV_TABLE)).$$(ANY_ROW)).length + ).toBe(5); + assert((await getAllGeneNames()) === 'ALK,EGFR,EML4,ERG,TMPRSS2'); }); - it('can exclude custom drivers', () => { - $(ALTERATION_MENU_BTN).click(); - $(SHOW_UNKNOWN_TIER).waitForDisplayed(5000); + it('can exclude custom drivers', async () => { + await clickElement(ALTERATION_MENU_BTN); + await waitForElementDisplayed(SHOW_UNKNOWN_TIER, { timeout: 5000 }); - assert($(SHOW_PUTATIVE_DRIVERS).isSelected()); - $(SHOW_PUTATIVE_DRIVERS).click(); + assert(await isSelected(SHOW_PUTATIVE_DRIVERS)); + await clickElement(SHOW_PUTATIVE_DRIVERS); - assert($(SHOW_UNKNOWN_ONCOGENICITY).isSelected()); - $(SHOW_UNKNOWN_ONCOGENICITY).click(); + assert(await isSelected(SHOW_UNKNOWN_ONCOGENICITY)); + await clickElement(SHOW_UNKNOWN_ONCOGENICITY); - $(SV_TABLE) - .$(ANY_ROW) - .waitForDisplayed(); + await ( + await getNestedElement([SV_TABLE, ANY_ROW]) + ).waitForDisplayed(); - expect($(SV_TABLE).$$(ANY_ROW).length).toBe(2); - expect(getAllGeneNames()).toBe('NCOA4,RET'); + expect( + (await (await getElement(SV_TABLE)).$$(ANY_ROW)).length + ).toBe(2); + expect(await getAllGeneNames()).toBe('NCOA4,RET'); }); }); }); -function getAllGeneNames() { - return $(SV_TABLE) - .$$(ANY_ROW) - .map(e => e.$(GENE_NAME).getText()) - .sort() - .join(); +async function getAllGeneNames() { + const geneNames = await (await $(SV_TABLE)).$$(ANY_ROW); + const words = await Promise.all( + geneNames.map(async e => await (await e.$(GENE_NAME)).getText()) + ); + return words.sort().join(); } diff --git a/end-to-end-test/local/specs/group-color-chooser.spec.js b/end-to-end-test/local/specs/group-color-chooser.spec.js index 42ad58ddb88..9d0900163a3 100644 --- a/end-to-end-test/local/specs/group-color-chooser.spec.js +++ b/end-to-end-test/local/specs/group-color-chooser.spec.js @@ -1,10 +1,13 @@ -var assert = require('assert'); -const waitForStudyView = require('../../shared/specUtils').waitForStudyView; -const goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -const waitForGroupComparisonTabOpen = require('../../shared/specUtils') - .waitForGroupComparisonTabOpen; -const { setDropdownOpen } = require('../../shared/specUtils'); +const assert = require('assert'); +const { + waitForStudyView, + goToUrlAndSetLocalStorage, + waitForGroupComparisonTabOpen, + setDropdownOpen, + getNthElements, + clickElement, + getElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const studyViewUrl = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`; @@ -36,181 +39,208 @@ describe('color chooser for groups menu in study view', function() { const gbGroupColorIconEmpty = `[data-test="group-checkboxes"] [data-test="GB"] ${colorIconEmpty}`; const gbGroupColorIconBlue = `[data-test="group-checkboxes"] [data-test="GB"] ${colorIconBlue}`; - before(() => { - goToUrlAndSetLocalStorage(studyViewUrl, true); - waitForStudyView(); - deleteAllGroups(); + before(async () => { + await goToUrlAndSetLocalStorage(studyViewUrl, true); + await waitForStudyView(); + await deleteAllGroups(); }); - it('shows no icon color for new group', () => { + it('shows no icon color for new group', async () => { // select GB on the oncotree pie chart - const cancertypeGbPie = $$(oncotreePies)[1]; - cancertypeGbPie.click(); + const cancertypeGbPie = await getNthElements(oncotreePies, 1); + await cancertypeGbPie.click(); // open group menu and create group from selected samples - openGroupsMenu(); - $(createNewGroupButton).click(); - $(finalizeGroupButton).click(); + await openGroupsMenu(); + await clickElement(createNewGroupButton); + await clickElement(finalizeGroupButton); // check color - $(gbGroupColorIconRect).waitForExist(); - const GroupGbColorIcon = $(gbGroupColorIconRect); - assert.strictEqual(GroupGbColorIcon.getAttribute('fill'), '#FFFFFF'); + await (await getElement(gbGroupColorIconRect)).waitForExist(); + const GroupGbColorIcon = await getElement(gbGroupColorIconRect); + assert.strictEqual( + await GroupGbColorIcon.getAttribute('fill'), + '#FFFFFF' + ); }); - it('shows new color in icon when new color is selected', () => { + it('shows new color in icon when new color is selected', async () => { // open color picker and select blue - setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); - $(colorPickerBlue).click(); - $(gbGroupColorIconBlue).waitForExist(); + await setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); + await clickElement(colorPickerBlue); + await (await getElement(gbGroupColorIconBlue)).waitForExist(); // check the color icon - const GroupGbColorIcon = $(gbGroupColorIconRect); - assert.strictEqual(GroupGbColorIcon.getAttribute('fill'), '#2986e2'); + const GroupGbColorIcon = await getElement(gbGroupColorIconRect); + assert.strictEqual( + await GroupGbColorIcon.getAttribute('fill'), + '#2986e2' + ); }); - it('selects no color after pressing same color', () => { - setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); + it('selects no color after pressing same color', async () => { + await setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); // unselect blue and check the color icon - $(colorPickerBlue).click(); - $(gbGroupColorIconEmpty).waitForExist(); - const groupGBColorIcon = $(gbGroupColorIconRect); - assert.strictEqual(groupGBColorIcon.getAttribute('fill'), '#FFFFFF'); + await clickElement(colorPickerBlue); + await (await getElement(gbGroupColorIconEmpty)).waitForExist(); + const groupGBColorIcon = await getElement(gbGroupColorIconRect); + assert.strictEqual( + await groupGBColorIcon.getAttribute('fill'), + '#FFFFFF' + ); }); - it('warns of same color in groups selected for comparison', () => { + it('warns of same color in groups selected for comparison', async () => { // close the color picker and group menu - setDropdownOpen(false, gbGroupColorIcon, colorPickerBlue); - closeGroupsMenu(); + await setDropdownOpen(false, gbGroupColorIcon, colorPickerBlue); + await closeGroupsMenu(); // unselect previous oncotree code and select another - $$(oncotreePies)[1].click(); - $$(oncotreePies)[2].click(); + await (await getNthElements(oncotreePies, 1)).click(); + await (await getNthElements(oncotreePies, 2)).click(); // create a group for it openGroupsMenu(); - $(createNewGroupButton).click(); - $(finalizeGroupButton).click(); + await clickElement(createNewGroupButton); + await clickElement(finalizeGroupButton); // select same color for both groups - browser.waitUntil(() => $$(colorIcon).length === 2); + await browser.waitUntil(async () => (await $$(colorIcon)).length === 2); // select both groups - $$(groupCheckboxes)[0].click(); - $$(groupCheckboxes)[1].click(); + await (await getNthElements(groupCheckboxes, 0)).click(); + await (await getNthElements(groupCheckboxes, 1)).click(); - setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); - $(colorPickerBlue).click(); + await setDropdownOpen(true, gbGroupColorIcon, colorPickerBlue); + await clickElement(colorPickerBlue); // close color picker 0 before going to next one - setDropdownOpen(false, gbGroupColorIcon, colorPickerBlue); - setDropdownOpen(true, $$(colorIcon)[1], colorPickerBlue); - $(colorPickerBlue).click(); + await setDropdownOpen(false, gbGroupColorIcon, colorPickerBlue); + await setDropdownOpen( + true, + await getNthElements(colorIcon, 1), + colorPickerBlue + ); + await clickElement(colorPickerBlue); // assert that warning sign exists - $(warningSign).waitForExist(); - assert($(warningSign).isExisting()); + await (await getElement(warningSign)).waitForExist(); + assert(await (await getElement(warningSign)).isExisting()); }); - it('does not warn of same color when one of groups is not selected for comparison', () => { + it('does not warn of same color when one of groups is not selected for comparison', async () => { // unselect one group for comparison - $(groupCheckboxes).click(); + await clickElement(groupCheckboxes); // assert that there is no warning sign - assert(!$(warningSign).isExisting()); + assert(!(await (await getElement(warningSign)).isExisting())); }); - it('shows default color for male/female groups', () => { + it('shows default color for male/female groups', async () => { // create female group and check predefined color - $(groupsMenuButton).click(); - const genderTypeGbPie = $$(genderPies)[1]; - genderTypeGbPie.click(); + await clickElement(groupsMenuButton); + const genderTypeGbPie = await getNthElements(genderPies, 1); + await genderTypeGbPie.click(); - openGroupsMenu(); - $(createNewGroupButton).click(); - $(finalizeGroupButton).click(); + await openGroupsMenu(); + await clickElement(createNewGroupButton); + await clickElement(finalizeGroupButton); - browser.waitUntil(() => $$(colorIconRect).length === 3); - const GroupGbColorIcon = $$(colorIconRect)[2]; - assert.strictEqual(GroupGbColorIcon.getAttribute('fill'), '#E0699E'); + await browser.waitUntil( + async () => (await $$(colorIconRect)).length === 3 + ); + const GroupGbColorIcon = await getNthElements(colorIconRect, 2); + assert.strictEqual( + await GroupGbColorIcon.getAttribute('fill'), + '#E0699E' + ); }); - it('shows undefined color when two groups with predefined colors are selected', () => { + it('shows undefined color when two groups with predefined colors are selected', async () => { // select living on overall survival chart (female is already selected from previous test) - $(groupsMenuButton).click(); - const survivalLivingPie = $$(survivalPies)[0]; - survivalLivingPie.click(); + await clickElement(groupsMenuButton); + const survivalLivingPie = await getNthElements(survivalPies, 0); + await survivalLivingPie.click(); // create living female group and check there is no color - openGroupsMenu(); - $(createNewGroupButton).click(); - $(finalizeGroupButton).click(); + await openGroupsMenu(); + await clickElement(createNewGroupButton); + await clickElement(finalizeGroupButton); - browser.waitUntil(() => $$(colorIconRect).length === 4); - const livingFemaleColorIcon = $$(colorIconRect)[2]; + await browser.waitUntil( + async () => (await $$(colorIconRect)).length === 4 + ); + const livingFemaleColorIcon = await getNthElements(colorIconRect, 2); assert.strictEqual( - livingFemaleColorIcon.getAttribute('fill'), + await livingFemaleColorIcon.getAttribute('fill'), '#FFFFFF' ); }); - it('stores group colors in study view user session', () => { + it('stores group colors in study view user session', async () => { // refresh the page and check if color is still present - browser.refresh(); - $(groupsMenuButton).waitForExist(); - $(groupsMenuButton).click(); - $(colorIconRect).waitForExist(); - assert.strictEqual($(colorIconRect).getAttribute('fill'), '#2986e2'); + await browser.refresh(); + await (await getElement(groupsMenuButton)).waitForExist(); + await clickElement(groupsMenuButton); + await (await getElement(colorIconRect)).waitForExist(); + assert.strictEqual( + await (await getElement(colorIconRect)).getAttribute('fill'), + '#2986e2' + ); }); - it('uses custom colors in group comparison view', () => { + it('uses custom colors in group comparison view', async () => { // compare first 2 groups (GB and OAST) after changing the color of OAST // select GB and OAST groups - $$(groupCheckboxes)[0].click(); - $$(groupCheckboxes)[1].click(); + await (await getNthElements(groupCheckboxes, 0)).click(); + await (await getNthElements(groupCheckboxes, 1)).click(); // GB group remains blue; OAST becomes green - $$(colorIcon)[1].click(); - $(colorPickerGreen).click(); + await (await getNthElements(colorIcon, 1)).click(); + await clickElement(colorPickerGreen); // open comparison tab - const studyViewTabId = browser.getWindowHandles()[0]; - $(compareButton).click(); - browser.waitUntil(() => browser.getWindowHandles().length > 1); // wait until new tab opens - const groupComparisonTabId = browser - .getWindowHandles() - .find(id => id !== studyViewTabId); - browser.switchToWindow(groupComparisonTabId); - waitForGroupComparisonTabOpen(); + const studyViewTabId = (await browser.getWindowHandles())[0]; + await clickElement(compareButton); + await browser.waitUntil( + async () => (await browser.getWindowHandles()).length > 1 + ); // wait until new tab opens + const groupComparisonTabId = (await browser.getWindowHandles()).find( + id => id !== studyViewTabId + ); + await browser.switchToWindow(groupComparisonTabId); + await waitForGroupComparisonTabOpen(); // check that selected colors are used assert( - $(gbGroupButton) - .getAttribute('style') - .includes('background-color: rgb(41, 134, 226)') + ( + await (await getElement(gbGroupButton)).getAttribute('style') + ).includes('background-color: rgb(41, 134, 226)') ); assert( - $(oastGroupButton) - .getAttribute('style') - .includes('background-color: rgb(16, 150, 24);') + ( + await (await getElement(oastGroupButton)).getAttribute('style') + ).includes('background-color: rgb(16, 150, 24);') ); }); - const openGroupsMenu = () => { - setDropdownOpen(true, groupsMenuButton, createNewGroupButton); + const openGroupsMenu = async () => { + await setDropdownOpen(true, groupsMenuButton, createNewGroupButton); }; - const closeGroupsMenu = () => { - setDropdownOpen(false, groupsMenuButton, createNewGroupButton); + const closeGroupsMenu = async () => { + await setDropdownOpen(false, groupsMenuButton, createNewGroupButton); }; - const deleteAllGroups = () => { - openGroupsMenu(); + const deleteAllGroups = async () => { + await openGroupsMenu(); try { - $('[data-test="deleteGroupButton"]').waitForExist(); - for (const button of $$('[data-test="deleteGroupButton"]')) { - button.click(); + await ( + await getElement('[data-test="deleteGroupButton"]') + ).waitForExist(); + for (const button of await $$('[data-test="deleteGroupButton"]')) { + await button.click(); } } catch (e) { // no groups to delete } - closeGroupsMenu(); + await closeGroupsMenu(); }; }); diff --git a/end-to-end-test/local/specs/gsva.screenshot.spec.js b/end-to-end-test/local/specs/gsva.screenshot.spec.js index 72e29be6361..ff8ce64e356 100644 --- a/end-to-end-test/local/specs/gsva.screenshot.spec.js +++ b/end-to-end-test/local/specs/gsva.screenshot.spec.js @@ -1,119 +1,129 @@ -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var assertScreenShotMatch = require('../../shared/lib/testUtils') - .assertScreenShotMatch; -var waitForStudyQueryPage = require('../../shared/specUtils') - .waitForStudyQueryPage; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var waitForPlotsTab = require('../../shared/specUtils').waitForPlotsTab; -var waitForCoExpressionTab = require('../../shared/specUtils') - .waitForCoExpressionTab; -var checkTestStudy = require('./gsva.spec').checkTestStudy; -var checkGSVAprofile = require('./gsva.spec').checkGSVAprofile; -var queryPageUrl = require('./gsva.spec').queryPageUrl; -var plotsTabUrl = require('./gsva.spec').plotsTabUrl; -var oncoprintTabUrl = require('./gsva.spec').oncoprintTabUrl; -var coexpressionTabUrl = require('./gsva.spec').coexpressionTabUrl; -var selectReactSelectOption = require('../../shared/specUtils') - .selectReactSelectOption; -var showGsva = require('../../shared/specUtils').showGsva; -var getNthOncoprintTrackOptionsElements = require('../../shared/specUtils') - .getNthOncoprintTrackOptionsElements; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var { setDropdownOpen } = require('../../shared/specUtils.js'); -const { checkOncoprintElement } = require('../../shared/specUtils'); +const { + goToUrlAndSetLocalStorage, + waitForStudyQueryPage, + waitForOncoprint, + waitForPlotsTab, + waitForCoExpressionTab, + selectReactSelectOption, + showGsva, + getNthOncoprintTrackOptionsElements, + setDropdownOpen, + checkOncoprintElement, + clickElement, + getElement, + waitForElementDisplayed, +} = require('../../shared/specUtils_Async.js'); +const { assertScreenShotMatch } = require('../../shared/lib/testUtils'); +const { + checkTestStudy, + coexpressionTabUrl, + queryPageUrl, + plotsTabUrl, + oncoprintTabUrl, + checkGSVAprofile, +} = require('./gsva.spec'); describe('gsva feature', () => { describe('GenesetVolcanoPlotSelector', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(queryPageUrl, true); - showGsva(); - waitForStudyQueryPage(20000); - checkTestStudy(); - checkGSVAprofile(); - $('button[data-test=GENESET_VOLCANO_BUTTON]').click(); - $('div.modal-dialog').waitForExist(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(queryPageUrl, true); + await showGsva(); + await waitForStudyQueryPage(20000); + await checkTestStudy(); + await checkGSVAprofile(); + await clickElement('button[data-test=GENESET_VOLCANO_BUTTON]'); + await (await getElement('div.modal-dialog')).waitForExist(); }); - it('shows volcano plot for gene sets selection', () => { - var res = browser.checkElement('div.VictoryContainer'); + it('shows volcano plot for gene sets selection', async () => { + const res = await browser.checkElement('div.VictoryContainer'); assertScreenShotMatch(res); }); - it('updates volcano plot after change of `percentile of score calculation`', () => { - var modal = $('div.modal-body'); - modal.$('.Select-value-label').waitForExist(); - modal.$('.Select-value-label').click(); - modal.$('.Select-option=50%').waitForExist(); - modal.$('.Select-option=50%').click(); - var res = browser.checkElement('div.VictoryContainer'); + it('updates volcano plot after change of `percentile of score calculation`', async () => { + const modal = await getElement('div.modal-body'); + await (await modal.$('.Select-value-label')).waitForExist(); + await (await modal.$('.Select-value-label')).click(); + await (await modal.$('.Select-option=50%')).waitForExist(); + await (await modal.$('.Select-option=50%')).click(); + const res = await browser.checkElement('div.VictoryContainer'); assertScreenShotMatch(res); }); }); describe('oncoprint tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); }); - it('shows GSVA heatmap track', () => { - var res = browser.checkElement('div[id=oncoprintDiv]'); + it('shows GSVA heatmap track', async () => { + const res = await browser.checkElement('div[id=oncoprintDiv]'); assertScreenShotMatch(res); }); - it('expands and shows correlation genes for GO_ATP_DEPENDENT_CHROMATIN_REMODELING', () => { - var trackOptionsElts = getNthOncoprintTrackOptionsElements(12); + it('expands and shows correlation genes for GO_ATP_DEPENDENT_CHROMATIN_REMODELING', async () => { + const trackOptionsElts = await getNthOncoprintTrackOptionsElements( + 12 + ); // open menu - setDropdownOpen( + await setDropdownOpen( true, trackOptionsElts.button_selector, trackOptionsElts.dropdown_selector ); // click Show genes - $( + await waitForElementDisplayed( + trackOptionsElts.dropdown_selector + ' li:nth-child(7)' + ); + await clickElement( trackOptionsElts.dropdown_selector + ' li:nth-child(7)' - ).waitForDisplayed(); - $(trackOptionsElts.dropdown_selector + ' li:nth-child(7)').click(); + ); - waitForOncoprint(); - var res = checkOncoprintElement('.oncoprintContainer'); + await waitForOncoprint(); + const res = await checkOncoprintElement('.oncoprintContainer'); assertScreenShotMatch(res); }); }); describe('plots tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(plotsTabUrl, true); - waitForPlotsTab(20000); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(plotsTabUrl, true); + await waitForPlotsTab(20000); }); - it('shows gsva profile data on horizontal and vertical axes', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - horzDataSelect.$('.Select-arrow-zone').click(); - horzDataSelect.$('.Select-option=Gene Sets').click(); + it('shows gsva profile data on horizontal and vertical axes', async () => { + const horzDataSelect = await ( + await getElement('[name=h-profile-type-selector]') + ).$('..'); + await (await horzDataSelect.$('.Select-arrow-zone')).click(); + await (await horzDataSelect.$('.Select-option=Gene Sets')).click(); - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - vertDataSelect.$('.Select-arrow-zone').click(); - vertDataSelect.$('.Select-option=Gene Sets').click(); - var res = browser.checkElement('div[data-test="PlotsTabPlotDiv"]'); + const vertDataSelect = await ( + await getElement('[name=v-profile-type-selector]') + ).$('..'); + await (await vertDataSelect.$('.Select-arrow-zone')).click(); + await (await vertDataSelect.$('.Select-option=Gene Sets')).click(); + const res = await browser.checkElement( + 'div[data-test="PlotsTabPlotDiv"]' + ); assertScreenShotMatch(res); }); }); describe('co-expression tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(coexpressionTabUrl, true); - waitForCoExpressionTab(20000); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(coexpressionTabUrl, true); + await waitForCoExpressionTab(20000); }); - it('shows GSVA scores in scatterplot', () => { - selectReactSelectOption( - $('.coexpression-select-query-profile'), + it('shows GSVA scores in scatterplot', async () => { + await selectReactSelectOption( + await getElement('.coexpression-select-query-profile'), 'GSVA scores on oncogenic signatures gene sets (5 samples)' ); - $('#coexpressionTabGeneTabs').waitForExist(); - var res = browser.checkElement('#coexpression-plot-svg'); + await (await getElement('#coexpressionTabGeneTabs')).waitForExist(); + const res = await browser.checkElement('#coexpression-plot-svg'); assertScreenShotMatch(res); }); }); diff --git a/end-to-end-test/local/specs/gsva.spec.js b/end-to-end-test/local/specs/gsva.spec.js index 6a3eb33fcb9..31942c2a592 100644 --- a/end-to-end-test/local/specs/gsva.spec.js +++ b/end-to-end-test/local/specs/gsva.spec.js @@ -1,23 +1,24 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var goToUrlAndSetLocalStorageWithProperty = require('../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; -var waitForStudyQueryPage = require('../../shared/specUtils') - .waitForStudyQueryPage; -var waitForGeneQueryPage = require('../../shared/specUtils') - .waitForGeneQueryPage; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var waitForPlotsTab = require('../../shared/specUtils').waitForPlotsTab; -var waitForCoExpressionTab = require('../../shared/specUtils') - .waitForCoExpressionTab; -var reactSelectOption = require('../../shared/specUtils').reactSelectOption; -var getReactSelectOptions = require('../../shared/specUtils') - .getReactSelectOptions; -var selectReactSelectOption = require('../../shared/specUtils') - .selectReactSelectOption; - -var { clickQueryByGeneButton, showGsva } = require('../../shared/specUtils'); +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + goToUrlAndSetLocalStorageWithProperty, + waitForStudyQueryPage, + waitForGeneQueryPage, + waitForOncoprint, + waitForPlotsTab, + waitForCoExpressionTab, + reactSelectOption, + getReactSelectOptions, + selectReactSelectOption, + getElement, + clickElement, + clickQueryByGeneButton, + showGsva, + isDisplayed, + setInputText, + getNestedElement, + getNthElements, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const oncoprintTabUrl = @@ -35,535 +36,643 @@ describe('gsva feature', function() { //this.retries(2); describe('query page', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - showGsva(); - waitForStudyQueryPage(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await showGsva(); + await waitForStudyQueryPage(); }); - it('shows GSVA-profile option when selecting study_es_0', () => { + it('shows GSVA-profile option when selecting study_es_0', async () => { // somehow reloading the page is needed to turn on the GSVA feature for the first test - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - waitForStudyQueryPage(); - checkTestStudy(); - - var gsvaProfileCheckbox = $('[data-test=GENESET_SCORE]'); - assert(gsvaProfileCheckbox.isDisplayed()); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await waitForStudyQueryPage(); + await checkTestStudy(); + assert(await isDisplayed('[data-test=GENESET_SCORE]')); }); - it('shows gene set entry component when selecting gsva-profile data type', () => { - checkTestStudy(); - checkGSVAprofile(); + it('shows gene set entry component when selecting gsva-profile data type', async () => { + await checkTestStudy(); + await checkGSVAprofile(); - assert($('h2=Enter Gene Sets:').isDisplayed()); - assert( - browser.$('[data-test=GENESET_HIERARCHY_BUTTON]').isDisplayed() - ); - assert($('[data-test=GENESET_VOLCANO_BUTTON]').isDisplayed()); - assert($('[data-test=GENESETS_TEXT_AREA]').isDisplayed()); + assert(await isDisplayed('h2=Enter Gene Sets:')); + assert(await isDisplayed('[data-test=GENESET_HIERARCHY_BUTTON]')); + assert(await isDisplayed('[data-test=GENESET_VOLCANO_BUTTON]')); + assert(await isDisplayed('[data-test=GENESETS_TEXT_AREA]')); }); - it('adds gene set parameter to url after submit', () => { - checkTestStudy(); - checkGSVAprofile(); - - $('[data-test=GENESETS_TEXT_AREA]').setValue( + it('adds gene set parameter to url after submit', async () => { + await checkTestStudy(); + await checkGSVAprofile(); + await setInputText( + '[data-test=GENESETS_TEXT_AREA]', 'GO_ATP_DEPENDENT_CHROMATIN_REMODELING' ); - $('[data-test=geneSet]').setValue('TP53'); - var queryButton = $('[data-test=queryButton]'); - queryButton.waitForEnabled(); - queryButton.click(); - var url = browser.getUrl(); - var regex = /geneset_list=GO_ATP_DEPENDENT_CHROMATIN_REMODELING/; + await setInputText('[data-test=geneSet]', 'TP53'); + const queryButton = await getElement('[data-test=queryButton]'); + await queryButton.waitForEnabled(); + await queryButton.click(); + const url = await browser.getUrl(); + const regex = /geneset_list=GO_ATP_DEPENDENT_CHROMATIN_REMODELING/; assert(url.match(regex)); }); }); describe('GenesetsHierarchySelector', () => { - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - showGsva(); - waitForStudyQueryPage(); - checkTestStudy(); - checkGSVAprofile(); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await showGsva(); + await waitForStudyQueryPage(); + await checkTestStudy(); + await checkGSVAprofile(); }); - it('adds gene set name to entry component from hierachy selector', () => { - openGsvaHierarchyDialog(); + it('adds gene set name to entry component from hierachy selector', async () => { + await openGsvaHierarchyDialog(); - var checkBox = $('*=GO_ATP_DEPENDENT_CHROMATIN_REMODELING'); - checkBox.click(); + const checkBox = await getElement( + '*=GO_ATP_DEPENDENT_CHROMATIN_REMODELING' + ); + await checkBox.click(); // wait for jstree to process the click - browser.waitUntil(() => - checkBox.getAttribute('class').includes('jstree-clicked') + await browser.waitUntil(async () => + (await checkBox.getAttribute('class')).includes( + 'jstree-clicked' + ) ); - $('button=Select').click(); + await clickElement('button=Select'); - $('span*=All gene sets are valid').waitForExist(); + await ( + await getElement('span*=All gene sets are valid') + ).waitForExist(); assert.equal( - $('[data-test=GENESETS_TEXT_AREA]').getHTML(false), + await ( + await getElement('[data-test=GENESETS_TEXT_AREA]') + ).getHTML(false), 'GO_ATP_DEPENDENT_CHROMATIN_REMODELING' ); }); - it('filters gene sets with the GSVA score input field', () => { - openGsvaHierarchyDialog(); + it('filters gene sets with the GSVA score input field', async () => { + await openGsvaHierarchyDialog(); - $('[id=GSVAScore]').setValue('0'); - $('[id=filterButton]').click(); - waitForModalUpdate(); + await setInputText('[id=GSVAScore]', '0'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); - assert.equal($$('*=GO_').length, 5); + assert.equal((await $$('*=GO_')).length, 5); // reset state - $('[id=GSVAScore]').setValue('0.5'); - $('[id=filterButton]').click(); - waitForModalUpdate(); + await setInputText('[id=GSVAScore]', '0.5'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); }); - it('filters gene sets with the search input field', () => { - $('[id=GSVAScore]').setValue('0'); - $('[id=filterButton]').click(); - waitForModalUpdate(); + it('filters gene sets with the search input field', async () => { + await setInputText('[id=GSVAScore]', '0'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); // note: search inbox hides elements in JTree rather than reload data - const hiddenBefore = $$('.jstree-hidden').length; + const hiddenBefore = (await $$('.jstree-hidden')).length; assert( hiddenBefore == 0, 'The tree should not have hidden elements at this point' ); - $('[id=geneset-hierarchy-search]').setValue( + await setInputText( + '[id=geneset-hierarchy-search]', 'GO_ACYLGLYCEROL_HOMEOSTASIS' ); - waitForModalUpdate(); - const hiddenAfter = $$('.jstree-hidden').length; - assert.equal(hiddenAfter, 7); - assert($('*=GO_ACYLGLYCEROL_HOMEOSTASIS')); + await waitForModalUpdate(); + assert.equal((await $$('.jstree-hidden')).length, 7); + assert(await getElement('*=GO_ACYLGLYCEROL_HOMEOSTASIS')); // reset state - $('[id=geneset-hierarchy-search]').setValue(''); - $('[id=GSVAScore]').setValue('0.5'); - $('[id=filterButton]').click(); - waitForModalUpdate(); - }); - - it('filters gene sets with the gene set pvalue input field', () => { - $('[id=Pvalue]').setValue('0.0005'); - $('[id=filterButton]').click(); - waitForModalUpdate(); - var after = $$('*=GO_'); - - assert.equal($$('*=GO_').length, 0); - + await setInputText('[id=geneset-hierarchy-search]', ''); + await setInputText('[id=GSVAScore]', '0.5'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); + }); + + it('filters gene sets with the gene set pvalue input field', async () => { + await setInputText('[id=Pvalue]', '0.0005'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); + const after = await $$('*=GO_'); + assert.equal((await $$('*=GO_')).length, 0); // reset state - $('[id=Pvalue]').setValue('0.05'); - $('[id=filterButton]').click(); - waitForModalUpdate(); + await setInputText('[id=Pvalue]', '0.05'); + await clickElement('[id=filterButton]'); + await waitForModalUpdate(); }); - it('filters gene sets with the gene set percentile select box', () => { - var modal = $('div.modal-body'); - modal.$('.Select-value-label').click(); - modal.$('.Select-option=100%').click(); - modal.$('[id=filterButton]').click(); - waitForModalUpdate(); + it('filters gene sets with the gene set percentile select box', async () => { + const modal = await getElement('div.modal-body'); + await (await modal.$('.Select-value-label')).click(); + await (await modal.$('.Select-option=100%')).click(); + await (await modal.$('[id=filterButton]')).click(); + await waitForModalUpdate(); - assert.equal($$('*=GO_').length, 2); + assert.equal(await $$('*=GO_').length, 2); // reset state - modal.$('.Select-value-label').click(); - modal.$('.Select-option=75%').click(); - modal.$('[id=filterButton]').click(); - waitForModalUpdate(); + await (await modal.$('.Select-value-label')).click(); + await (await modal.$('.Select-option=75%')).click(); + await (await modal.$('[id=filterButton]')).click(); + await waitForModalUpdate(); }); describe('skin.geneset_hierarchy.collapse_by_default property', () => { - it('collapses tree on init when property set to true', () => { - goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { - skin_geneset_hierarchy_collapse_by_default: true, - }); - showGsva(); - waitForStudyQueryPage(); - checkTestStudy(); - checkGSVAprofile(); - openGsvaHierarchyDialog(); - var gsvaEntriesNotShown = $$('*=GO_').length === 0; + it('collapses tree on init when property set to true', async () => { + await goToUrlAndSetLocalStorageWithProperty( + CBIOPORTAL_URL, + true, + { + skin_geneset_hierarchy_collapse_by_default: true, + } + ); + await showGsva(); + await waitForStudyQueryPage(); + await checkTestStudy(); + await checkGSVAprofile(); + await openGsvaHierarchyDialog(); + const gsvaEntriesNotShown = (await $$('*=GO_')).length === 0; assert(gsvaEntriesNotShown); }); - it('expands tree on init when property set to false', () => { - goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { - skin_geneset_hierarchy_collapse_by_default: false, - }); - showGsva(); - waitForStudyQueryPage(); - checkTestStudy(); - checkGSVAprofile(); - openGsvaHierarchyDialog(); - var gsvaEntriesShown = $$('*=GO_').length > 0; + it('expands tree on init when property set to false', async () => { + await goToUrlAndSetLocalStorageWithProperty( + CBIOPORTAL_URL, + true, + { + skin_geneset_hierarchy_collapse_by_default: false, + } + ); + await showGsva(); + await waitForStudyQueryPage(); + await checkTestStudy(); + await checkGSVAprofile(); + await openGsvaHierarchyDialog(); + const gsvaEntriesShown = (await $$('*=GO_')).length > 0; assert(gsvaEntriesShown); }); - it('expands tree on init when property not defined', () => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - showGsva(); - waitForStudyQueryPage(); - checkTestStudy(); - checkGSVAprofile(); - openGsvaHierarchyDialog(); - var gsvaEntriesShown = $$('*=GO_').length > 0; + it('expands tree on init when property not defined', async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await showGsva(); + await waitForStudyQueryPage(); + await checkTestStudy(); + await checkGSVAprofile(); + await openGsvaHierarchyDialog(); + const gsvaEntriesShown = (await $$('*=GO_')).length > 0; assert(gsvaEntriesShown); }); }); }); describe('GenesetVolcanoPlotSelector', () => { - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - showGsva(); - waitForStudyQueryPage(); - checkTestStudy(); - checkGSVAprofile(); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await showGsva(); + await waitForStudyQueryPage(); + await checkTestStudy(); + await checkGSVAprofile(); }); - it('adds gene set name to entry component', () => { - openGsvaVolcanoDialog(); + it('adds gene set name to entry component', async () => { + await openGsvaVolcanoDialog(); // find the GO_ATP_DEPENDENT_CHROMATIN_REMODELING entry and check its checkbox - $('span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING').waitForExist(); - var checkBox = $('span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING') - .$('..') - .$('..') - .$$('td')[3] - .$('label input'); - checkBox.waitForDisplayed(); - browser.waitUntil(() => { - checkBox.click(); + await ( + await getElement('span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING') + ).waitForExist(); + const checkBoxParent = await getNestedElement([ + 'span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING', + '..', + '..', + ]); + const checkBox = await (await checkBoxParent.$$('td'))[3].$( + 'label input' + ); + await checkBox.waitForDisplayed(); + await browser.waitUntil(async () => { + await checkBox.click(); return checkBox.isSelected(); }); - $('button=Add selection to the query').waitForExist(); - $('button=Add selection to the query').click(); + await ( + await getElement('button=Add selection to the query') + ).waitForExist(); + await clickElement('button=Add selection to the query'); - $('span*=All gene sets are valid').waitForExist(); + await ( + await getElement('span*=All gene sets are valid') + ).waitForExist(); - var textArea = $('[data-test=GENESETS_TEXT_AREA]'); - textArea.waitForExist(); + const textArea = await getElement('[data-test=GENESETS_TEXT_AREA]'); assert.equal( - textArea.getHTML(false), + await textArea.getHTML(false), 'GO_ATP_DEPENDENT_CHROMATIN_REMODELING' ); }); - it('selects gene sets from query page text area', () => { - openGsvaVolcanoDialog(); + it('selects gene sets from query page text area', async () => { + await openGsvaVolcanoDialog(); - var checkBox = $('span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING') - .$('..') - .$('..') - .$$('td')[3] - .$('label input'); + const checkBoxParent = await getNestedElement([ + 'span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING', + '..', + '..', + ]); + const checkBox = await (await checkBoxParent.$$('td'))[3].$( + 'label input' + ); - assert(checkBox.isSelected()); + assert(await checkBox.isSelected()); }); - it('reset keeps gene sets from query page text area', () => { - var checkBox = $('span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING') - .$('..') - .$('..') - .$$('td')[3] - .$('label input'); - $('button=Clear selection').click(); + it('reset keeps gene sets from query page text area', async () => { + const checkBoxParent = await getNestedElement([ + 'span=GO_ATP_DEPENDENT_CHROMATIN_REMODELING', + '..', + '..', + ]); + const checkBox = await (await checkBoxParent.$$('td'))[3].$( + 'label input' + ); + + await clickElement('button=Clear selection'); - assert(checkBox.isSelected()); + assert(await checkBox.isSelected()); }); - it('searchbox filters gene set list', () => { - const lengthBefore = $$('span*=GO_').length; + it('searchbox filters gene set list', async () => { + const lengthBefore = (await $$('span*=GO_')).length; assert.equal(lengthBefore, 5); - $('input.tableSearchInput').waitForExist(); - $('input.tableSearchInput').setValue('GO_ACYL'); + await (await getElement('input.tableSearchInput')).waitForExist(); + await setInputText('input.tableSearchInput', 'GO_ACYL'); - browser.waitUntil(() => $$('span*=GO_').length < lengthBefore, { - timeout: 10000, - }); + await browser.waitUntil( + async () => (await $$('span*=GO_')).length < lengthBefore, + { + timeout: 10000, + } + ); - const lengthAfter = $$('span*=GO_').length; + const lengthAfter = (await $$('span*=GO_')).length; assert.equal(lengthAfter, 1); }); }); describe('results view page', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); }); - it('shows co-expression tab when genes with expression data selected', () => { - assert($('ul.nav-tabs li.tabAnchor_coexpression')); + it('shows co-expression tab when genes with expression data selected', async () => { + assert(await getElement('ul.nav-tabs li.tabAnchor_coexpression')); }); }); describe('oncoprint tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); }); - it('has GSVA profile option in heatmap menu', () => { - var addTracksButton = $('button[id=addTracksDropdown]'); - addTracksButton.waitForExist(); - addTracksButton.click(); + it('has GSVA profile option in heatmap menu', async () => { + await clickElement('button[id=addTracksDropdown]'); - var addTracksMenu = $(ADD_TRACKS_HEATMAP_TAB); - addTracksMenu.waitForExist(); - addTracksMenu.click(); + await clickElement(ADD_TRACKS_HEATMAP_TAB); - var heatmapDropdown = $$('.Select-control')[0]; - heatmapDropdown.waitForExist(); - heatmapDropdown.click(); + const heatmapDropdown = await getNthElements('.Select-control', 0); + await heatmapDropdown.waitForExist(); + await heatmapDropdown.click(); assert( - $( + await isDisplayed( 'div=GSVA scores on oncogenic signatures gene sets' - ).isDisplayed() + ) ); }); }); describe('plots tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(plotsTabUrl, true); - waitForPlotsTab(); - }); - - it('shows gsva option in horizontal data type selection box', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - horzDataSelect.$('.Select-arrow-zone').click(); - assert(horzDataSelect.$('.Select-option=Gene Sets')); - }); - - it('shows gsva option in vertical data type selection box', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - vertDataSelect.$('.Select-arrow-zone').click(); - assert(vertDataSelect.$('.Select-option=Gene Sets')); - }); - - it('horizontal axis menu shows gsva score and pvalue in profile menu', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - horzDataSelect.$('.Select-arrow-zone').click(); - horzDataSelect.$('.Select-option=Gene Sets').click(); - - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); - horzProfileSelect.$('.Select-arrow-zone').click(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(plotsTabUrl, true); + await waitForPlotsTab(); + }); + + it('shows gsva option in horizontal data type selection box', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await (await horzDataSelect.$('.Select-arrow-zone')).click(); + assert(await horzDataSelect.$('.Select-option=Gene Sets')); + }); + + it('shows gsva option in vertical data type selection box', async () => { + const vertDataSelect = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + '.Select-arrow-zone', + ]); + await vertDataSelect.click(); + assert(await vertDataSelect.$('.Select-option=Gene Sets')); + }); + + it('horizontal axis menu shows gsva score and pvalue in profile menu', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await (await horzDataSelect.$('.Select-arrow-zone')).click(); + await (await horzDataSelect.$('.Select-option=Gene Sets')).click(); + + const horzProfileSelect = await getNestedElement([ + '[name=h-profile-name-selector]', + '..', + ]); + await (await horzProfileSelect.$('.Select-arrow-zone')).click(); assert( - horzProfileSelect.$( + await horzProfileSelect.$( '.Select-option=GSVA scores on oncogenic signatures gene sets' ) ); assert( - horzProfileSelect.$( + await horzProfileSelect.$( '.Select-option=Pvalues of GSVA scores on oncogenic signatures gene sets' ) ); }); - it('vertical axis menu shows gsva score and pvalue in profile menu', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - vertDataSelect.$('.Select-arrow-zone').click(); - vertDataSelect.$('.Select-option=Gene Sets').click(); + it('vertical axis menu shows gsva score and pvalue in profile menu', async () => { + const vertDataSelect = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + ]); + await (await vertDataSelect.$('.Select-arrow-zone')).click(); + await (await vertDataSelect.$('.Select-option=Gene Sets')).click(); - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); - vertProfileSelect.$('.Select-arrow-zone').click(); + const vertProfileSelect = await getNestedElement([ + '[name=v-profile-name-selector]', + '..', + ]); + await (await vertProfileSelect.$('.Select-arrow-zone')).click(); assert( - vertProfileSelect.$( + await vertProfileSelect.$( '.Select-option=GSVA scores on oncogenic signatures gene sets' ) ); assert( - vertProfileSelect.$( + await vertProfileSelect.$( '.Select-option=Pvalues of GSVA scores on oncogenic signatures gene sets' ) ); }); - it('horizontal axis menu shows gene set entry in entity menu', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - horzDataSelect.$('.Select-arrow-zone').click(); - horzDataSelect.$('.Select-option=Gene Sets').click(); - - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); - horzProfileSelect.$('.Select-arrow-zone').click(); - var profileMenuEntry = + it('horizontal axis menu shows gene set entry in entity menu', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await (await horzDataSelect.$('.Select-arrow-zone')).click(); + await (await horzDataSelect.$('.Select-option=Gene Sets')).click(); + + const horzProfileSelect = await getNestedElement([ + '[name=h-profile-name-selector]', + '..', + ]); + await (await horzProfileSelect.$('.Select-arrow-zone')).click(); + const profileMenuEntry = '.Select-option=Pvalues of GSVA scores on oncogenic signatures gene sets'; - horzProfileSelect.$(profileMenuEntry).waitForExist(); - horzProfileSelect.$(profileMenuEntry).click(); - - var horzEntitySelect = $('[name=h-geneset-selector]').$('..'); - horzEntitySelect.$('.Select-arrow-zone').click(); - var entityMenuEntry = + await (await horzProfileSelect.$(profileMenuEntry)).waitForExist(); + await (await horzProfileSelect.$(profileMenuEntry)).click(); + + const horzEntitySelect = await getNestedElement([ + '[name=h-geneset-selector]', + '..', + ]); + await (await horzEntitySelect.$('.Select-arrow-zone')).click(); + const entityMenuEntry = '.Select-option=GO_ATP_DEPENDENT_CHROMATIN_REMODELING'; - horzEntitySelect.$(entityMenuEntry).waitForExist(); + await (await horzEntitySelect.$(entityMenuEntry)).waitForExist(); - assert(horzEntitySelect.$(entityMenuEntry)); + assert(await horzEntitySelect.$(entityMenuEntry)); }); - it('vertical axis menu shows gene set entry in entity menu', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - vertDataSelect.$('.Select-arrow-zone').click(); - vertDataSelect.$('.Select-option=Gene Sets').click(); + it('vertical axis menu shows gene set entry in entity menu', async () => { + const vertDataSelect = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + ]); + await (await vertDataSelect.$('.Select-arrow-zone')).click(); + await (await vertDataSelect.$('.Select-option=Gene Sets')).click(); - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); - vertProfileSelect.$('.Select-arrow-zone').click(); - var profileMenuEntry = + const vertProfileSelect = await getNestedElement([ + '[name=v-profile-name-selector]', + '..', + ]); + await (await vertProfileSelect.$('.Select-arrow-zone')).click(); + const profileMenuEntry = '.Select-option=Pvalues of GSVA scores on oncogenic signatures gene sets'; - vertProfileSelect.$(profileMenuEntry).waitForExist(); - vertProfileSelect.$(profileMenuEntry).click(); - - var vertEntitySelect = $('[name=v-geneset-selector]').$('..'); - vertEntitySelect.$('.Select-arrow-zone').click(); - var entityMenuEntry = + await (await vertProfileSelect.$(profileMenuEntry)).waitForExist(); + await (await vertProfileSelect.$(profileMenuEntry)).click(); + + const vertEntitySelect = await getNestedElement([ + '[name=v-geneset-selector]', + '..', + ]); + await (await vertEntitySelect.$('.Select-arrow-zone')).click(); + const entityMenuEntry = '.Select-option=GO_ATP_DEPENDENT_CHROMATIN_REMODELING'; - vertEntitySelect.$(entityMenuEntry).waitForExist(); + await (await vertEntitySelect.$(entityMenuEntry)).waitForExist(); - assert(vertEntitySelect.$(entityMenuEntry)); + assert(await vertEntitySelect.$(entityMenuEntry)); }); }); describe('co-expression tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(coexpressionTabUrl, true); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(coexpressionTabUrl, true); waitForCoExpressionTab(); }); - it('shows buttons for genes', () => { + it('shows buttons for genes', async () => { const genes = coexpressionTabUrl .match(/gene_list=(.*)\&/)[1] .split('%20'); - var container = $('//*[@id="coexpressionTabGeneTabs"]'); - var icons = genes.map(g => container.$('a=' + g)); + const container = await getElement( + '//*[@id="coexpressionTabGeneTabs"]' + ); + const icons = await Promise.all( + genes.map(async g => await container.$(`a=${g}`)) + ); assert.equal(genes.length, icons.length); }); - it('shows buttons for genes and gene sets', () => { + it('shows buttons for genes and gene sets', async () => { const geneSets = coexpressionTabUrl .match(/geneset_list=(.*)\&/)[1] .split('%20'); - var container = $('//*[@id="coexpressionTabGeneTabs"]'); - var icons = geneSets.map(g => container.$('a=' + g)); + const container = await getElement( + '//*[@id="coexpressionTabGeneTabs"]' + ); + const icons = await Promise.all( + geneSets.map(async g => container.$('a=' + g)) + ); assert.equal(geneSets.length, icons.length); }); - it('shows mRNA expression/GSVA scores in query profile select box when reference gene selected', () => { - var icon = $('//*[@id="coexpressionTabGeneTabs"]').$('a=RPS11'); - icon.click(); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); + it('shows mRNA expression/GSVA scores in query profile select box when reference gene selected', async () => { + const icon = await getNestedElement([ + '#coexpressionTabGeneTabs', + 'a=RPS11', + ]); + await icon.click(); + await (await getElement('#coexpressionTabGeneTabs')).waitForExist(); assert.equal( - getReactSelectOptions($('.coexpression-select-query-profile')) - .length, + ( + await getReactSelectOptions( + await getElement('.coexpression-select-query-profile') + ) + ).length, 2 ); assert( - reactSelectOption( - $('.coexpression-select-query-profile'), + await reactSelectOption( + await getElement('.coexpression-select-query-profile'), 'mRNA expression (microarray) (526 samples)' ) ); assert( - reactSelectOption( - $('.coexpression-select-query-profile'), + await reactSelectOption( + await getElement('.coexpression-select-query-profile'), 'GSVA scores on oncogenic signatures gene sets (5 samples)' ) ); }); - it('shows mRNA expression in subject profile select box when reference gene selected', () => { - var icon = $('//*[@id="coexpressionTabGeneTabs"]').$('a=RPS11'); - icon.click(); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); + it('shows mRNA expression in subject profile select box when reference gene selected', async () => { + const icon = await getNestedElement([ + '//*[@id="coexpressionTabGeneTabs"]', + 'a=RPS11', + ]); + await icon.click(); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); assert.equal( - getReactSelectOptions($('.coexpression-select-subject-profile')) - .length, + ( + await getReactSelectOptions( + await getElement('.coexpression-select-subject-profile') + ) + ).length, 1 ); assert( - reactSelectOption( - $('.coexpression-select-subject-profile'), + await reactSelectOption( + await getElement('.coexpression-select-subject-profile'), 'mRNA expression (microarray) (526 samples)' ) ); }); - it('shows name of gene in `correlated with` field when reference gene selected', () => { - var icon = $('//*[@id="coexpressionTabGeneTabs"]').$('a=RPS11'); - icon.click(); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); - var text = $('span*=that are correlated').getText(); + it('shows name of gene in `correlated with` field when reference gene selected', async () => { + const icon = await getNestedElement([ + '//*[@id="coexpressionTabGeneTabs"]', + 'a=RPS11', + ]); + await icon.click(); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); + const text = await ( + await getElement('span*=that are correlated') + ).getText(); assert(text.match('RPS11')); }); - it('shows mRNA expression/GSVA scores in subject profile box when reference gene set selected', () => { - var icon = $('//*[@id="coexpressionTabGeneTabs"]').$( - 'a=GO_ACYLGLYCEROL_HOMEOSTASIS' - ); - icon.click(); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); + it('shows mRNA expression/GSVA scores in subject profile box when reference gene set selected', async () => { + const icon = await getNestedElement([ + '//*[@id="coexpressionTabGeneTabs"]', + 'a=GO_ACYLGLYCEROL_HOMEOSTASIS', + ]); + await icon.click(); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); assert.equal( - getReactSelectOptions($('.coexpression-select-query-profile')) - .length, + ( + await getReactSelectOptions( + await getElement('.coexpression-select-query-profile') + ) + ).length, 2 ); assert( - reactSelectOption( - $('.coexpression-select-query-profile'), + await reactSelectOption( + await getElement('.coexpression-select-query-profile'), 'mRNA expression (microarray) (526 samples)' ) ); assert( - reactSelectOption( - $('.coexpression-select-query-profile'), + await reactSelectOption( + await getElement('.coexpression-select-query-profile'), 'GSVA scores on oncogenic signatures gene sets (5 samples)' ) ); }); - it('shows disabled subject query select box when reference gene set selected', () => { - var icon = $('//*[@id="coexpressionTabGeneTabs"]').$( - 'a=GO_ACYLGLYCEROL_HOMEOSTASIS' - ); - icon.click(); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); - assert($('.coexpression-select-subject-profile.is-disabled ')); + it('shows disabled subject query select box when reference gene set selected', async () => { + const icon = await getNestedElement([ + '//*[@id="coexpressionTabGeneTabs"]', + 'a=GO_ACYLGLYCEROL_HOMEOSTASIS', + ]); + await icon.click(); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); assert( - $('.coexpression-select-subject-profile').$( - '.Select-value-label*=GSVA scores on oncogenic' + await getElement( + '.coexpression-select-subject-profile.is-disabled ' ) ); + assert( + await getNestedElement([ + '.coexpression-select-subject-profile', + '.Select-value-label*=GSVA scores on oncogenic', + ]) + ); }); - it('shows gene sets in table when GSVA scores selected in subject profile select box', () => { - selectReactSelectOption( - $('.coexpression-select-query-profile'), + it('shows gene sets in table when GSVA scores selected in subject profile select box', async () => { + await selectReactSelectOption( + await getElement('.coexpression-select-query-profile'), 'GSVA scores on oncogenic signatures gene sets (5 samples)' ); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); - $('span*=GO_').waitForExist(); - assert.equal($$('span*=GO_').length, 7); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); + await (await getElement('span*=GO_')).waitForExist(); + assert.equal((await $$('span*=GO_')).length, 7); }); - it('shows `Enter gene set.` placeholder in table search box when GSVA scores selected in first select box', () => { - selectReactSelectOption( - $('.coexpression-select-query-profile'), + it('shows `Enter gene set.` placeholder in table search box when GSVA scores selected in first select box', async () => { + await selectReactSelectOption( + await getElement('.coexpression-select-query-profile'), 'GSVA scores on oncogenic signatures gene sets (5 samples)' ); - $('//*[@id="coexpressionTabGeneTabs"]').waitForExist(); + await ( + await getElement('//*[@id="coexpressionTabGeneTabs"]') + ).waitForExist(); assert( - $( + await getElement( '[data-test=CoExpressionGeneTabContent] input[placeholder="Enter gene set.."]' ) ); @@ -571,35 +680,40 @@ describe('gsva feature', function() { }); }); -const checkTestStudy = () => { - // check the'Test study es_0' checkbox - $('span=Test study es_0').waitForExist(); - var checkbox = $('span=Test study es_0') - .$('..') - .$('input[type=checkbox]'); - checkbox.click(); - clickQueryByGeneButton(); +const checkTestStudy = async () => { + await (await getElement('span=Test study es_0')).waitForExist(); + + const checkbox = await getNestedElement([ + 'span=Test study es_0', + '..', + 'input[type=checkbox]', + ]); + await checkbox.click(); + await clickQueryByGeneButton(); waitForGeneQueryPage(); }; -const checkGSVAprofile = () => { - $('[data-test=GENESET_SCORE]').waitForExist(); - var gsvaProfileCheckbox = $('[data-test=GENESET_SCORE]'); - gsvaProfileCheckbox.click(); - $('[data-test=GENESETS_TEXT_AREA]').waitForExist(); +const checkGSVAprofile = async () => { + await (await getElement('[data-test=GENESET_SCORE]')).waitForExist(); + await clickElement('[data-test=GENESET_SCORE]'); + await (await getElement('[data-test=GENESETS_TEXT_AREA]')).waitForExist(); }; -const openGsvaHierarchyDialog = () => { - $('button[data-test=GENESET_HIERARCHY_BUTTON]').click(); - $('div.modal-dialog').waitForExist(); - $('div[data-test=gsva-tree-container] ul').waitForExist(); - waitForModalUpdate(); +const openGsvaHierarchyDialog = async () => { + await clickElement('button[data-test=GENESET_HIERARCHY_BUTTON]'); + await (await getElement('div.modal-dialog')).waitForExist(); + await ( + await getElement('div[data-test=gsva-tree-container] ul') + ).waitForExist(); + await waitForModalUpdate(); }; -const openGsvaVolcanoDialog = () => { - $('button[data-test=GENESET_VOLCANO_BUTTON]').waitForExist(); - $('button[data-test=GENESET_VOLCANO_BUTTON]').click(); - $('div.modal-dialog').waitForExist(); +const openGsvaVolcanoDialog = async () => { + await ( + await getElement('button[data-test=GENESET_VOLCANO_BUTTON]') + ).waitForExist(); + await clickElement('button[data-test=GENESET_VOLCANO_BUTTON]'); + await (await getElement('div.modal-dialog')).waitForExist(); }; module.exports = { @@ -611,6 +725,9 @@ module.exports = { coexpressionTabUrl: coexpressionTabUrl, }; -function waitForModalUpdate() { - browser.waitUntil(() => $$('.sk-spinner').length === 0, { timeout: 10000 }); +async function waitForModalUpdate() { + await browser.waitUntil( + async () => (await $$('.sk-spinner')).length === 0, + { timeout: 10000 } + ); } diff --git a/end-to-end-test/local/specs/hide-download-controls.spec.js b/end-to-end-test/local/specs/hide-download-controls.spec.js index 863cf141dd8..1205058dde9 100644 --- a/end-to-end-test/local/specs/hide-download-controls.spec.js +++ b/end-to-end-test/local/specs/hide-download-controls.spec.js @@ -1,16 +1,19 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForStudyQueryPage = require('../../shared/specUtils') - .waitForStudyQueryPage; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; -var waitForPatientView = require('../../shared/specUtils').waitForPatientView; -var waitForStudyView = require('../../shared/specUtils').waitForStudyView; -var jsApiHover = require('../../shared/specUtils').jsApiHover; -var setServerConfiguration = require('../../shared/specUtils') - .setServerConfiguration; -var openGroupComparison = require('../../shared/specUtils').openGroupComparison; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + waitForStudyQueryPage, + waitForOncoprint, + useExternalFrontend, + waitForPatientView, + waitForStudyView, + jsApiHover, + setServerConfiguration, + openGroupComparison, + getElement, + waitForElementDisplayed, + clickElement, + getNthElements, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -18,50 +21,50 @@ const downloadIcon = '.fa-download'; const downloadCloudIcon = '.fa-cloud-download'; const clipboardIcon = '.fa-clipboard'; -const globalCheck = () => { +const globalCheck = async () => { assert( - !$('*=Download').isExisting(), + !(await (await getElement('*=Download')).isExisting()), 'The word "Download" occurs on the page. Make sure that it is displayed conditionally based on the skin_hide_download_controls property' ); assert( - !$('*=download').isExisting(), + !(await (await getElement('*=download')).isExisting()), 'The word "download" occurs on the page. Make sure that it is displayed conditionally based on the skin_hide_download_controls property' ); assert( - !$(downloadIcon).isExisting(), + !(await (await getElement(downloadIcon)).isExisting()), 'A download button/icon is visible on the page. Make sure that it is displayed conditionally based on the skin_hide_download_controls property' ); assert( - !$(downloadCloudIcon).isExisting(), + !(await (await getElement(downloadCloudIcon)).isExisting()), 'A cloud download button/icon is visible on the page. Make sure that it is displayed conditionally based on the skin_hide_download_controls property' ); assert( - !$(clipboardIcon).isExisting(), + !(await (await getElement(clipboardIcon)).isExisting()), 'A download button/icon is visible on the page. Make sure that it is displayed conditionally based on the skin_hide_download_controls property' ); }; -const openAndSetProperty = (url, prop) => { - goToUrlAndSetLocalStorage(url, true); - setServerConfiguration(prop); - goToUrlAndSetLocalStorage(url, true); +const openAndSetProperty = async (url, prop) => { + await goToUrlAndSetLocalStorage(url, true); + await setServerConfiguration(prop); + await goToUrlAndSetLocalStorage(url, true); }; -const waitForTabs = count => { - browser.waitUntil(() => { - return $$('.tabAnchor').length >= count; +const waitForTabs = async count => { + await browser.waitUntil(async () => { + return (await $$('.tabAnchor')).length >= count; }, 300000); }; -function studyViewChartHoverHamburgerIcon(chartDataTest, timeout) { +async function studyViewChartHoverHamburgerIcon(chartDataTest, timeout) { // move to the chart const chart = '[data-test=' + chartDataTest + ']'; - $(chart).waitForDisplayed({ timeout: timeout || 10000 }); - jsApiHover(chart); + await waitForElementDisplayed(chart, { timeout: timeout }); + await jsApiHover(chart); // move to hamburger icon const hamburgerIcon = '[data-test=chart-header-hamburger-icon]'; - jsApiHover(hamburgerIcon); + await jsApiHover(hamburgerIcon); } describe('hide download controls feature', function() { @@ -69,19 +72,26 @@ describe('hide download controls feature', function() { describe('study query page', () => { const expectedTabNames = ['Query']; - before(() => { - openAndSetProperty(CBIOPORTAL_URL, { + before(async () => { + await openAndSetProperty(CBIOPORTAL_URL, { skin_hide_download_controls: 'hide', }); // browser.debug(); - waitForStudyQueryPage(); - waitForTabs(expectedTabNames.length); + await waitForStudyQueryPage(); + await waitForTabs(expectedTabNames.length); }); - it('covers all tabs with download control tests', () => { - const observedTabNames = $$('.tabAnchor') - .filter(a => a.isDisplayed()) - .map(a => a.getText()); + it('covers all tabs with download control tests', async () => { + const tabElements = await $$('.tabAnchor'); + const displayedTabs = await Promise.all( + tabElements.map(async a => + (await a.isDisplayed()) ? a : null + ) + ); + const visibleTabs = displayedTabs.filter(a => a !== null); + const observedTabNames = await Promise.all( + visibleTabs.map(async a => await a.getText()) + ); assert.deepStrictEqual( expectedTabNames, observedTabNames, @@ -94,18 +104,27 @@ describe('hide download controls feature', function() { ); }); - it('global check for icon and occurrence of "Download" as a word', () => { - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await globalCheck(); }); - it('does not show Download tab', () => { - assert(!$('.tabAnchor_download').isExisting()); + it('does not show Download tab', async () => { + assert( + !(await ( + await getElement('.tabAnchor_download') + ).isExisting()) + ); }); - it('does not show download icons data sets in study rows', () => { - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/datasets`, true); - $('[data-test=LazyMobXTable]').waitForExist(); - assert(!$(downloadIcon).isExisting()); + it('does not show download icons data sets in study rows', async () => { + await goToUrlAndSetLocalStorage( + `${CBIOPORTAL_URL}/datasets`, + true + ); + await ( + await getElement('[data-test=LazyMobXTable]') + ).waitForExist(); + assert(!(await (await getElement(downloadIcon)).isExisting())); }); }); @@ -121,21 +140,29 @@ describe('hide download controls feature', function() { 'CN Segments', 'Pathways', ]; - before(() => { - browser.setWindowSize(3200, 1000); + before(async () => { + await browser.setWindowSize(3200, 1000); - openAndSetProperty( + await openAndSetProperty( `${CBIOPORTAL_URL}/results/oncoprint?genetic_profile_ids_PROFILE_MUTATION_EXTENDED=study_es_0_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=study_es_0_gistic&cancer_study_list=study_es_0&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=mutations%2Cgistic&case_set_id=study_es_0_cnaseq&gene_list=CREB3L1%2520RPS11%2520PNMA1%2520MMP2%2520ZHX3%2520ERCC5%2520TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit&comparison_subtab=mrna`, { skin_hide_download_controls: 'hide' } ); - waitForOncoprint(); - waitForTabs(expectedTabNames.length); + await waitForOncoprint(); + await waitForTabs(expectedTabNames.length); }); - it('covers all tabs with download control tests', () => { - const observedTabNames = $$('.tabAnchor') - .filter(a => a.isDisplayed()) - .map(a => a.getText()); + it('covers all tabs with download control tests', async () => { + const tabElements = await $$('.tabAnchor'); + const displayedTabs = await Promise.all( + tabElements.map(async a => + (await a.isDisplayed()) ? a : null + ) + ); + const visibleTabs = displayedTabs.filter(a => a !== null); + const observedTabNames = await Promise.all( + visibleTabs.map(async a => await a.getText()) + ); + assert.deepStrictEqual( expectedTabNames, observedTabNames, @@ -149,44 +176,56 @@ describe('hide download controls feature', function() { }); describe('oncoprint', () => { - it('does not show download/clipboard icons and does not contain the word "Download"', () => { - globalCheck(); + it('does not show download/clipboard icons and does not contain the word "Download"', async () => { + await globalCheck(); }); }); describe('cancer type summary', () => { - it('does not show download/clipboard icons and does not contain the word "Download"', () => { - $('.tabAnchor_cancerTypesSummary').click(); - $('[data-test=cancerTypeSummaryChart]').waitForExist(); - globalCheck(); + it('does not show download/clipboard icons and does not contain the word "Download"', async () => { + await clickElement('.tabAnchor_cancerTypesSummary'); + await ( + await getElement('[data-test=cancerTypeSummaryChart]') + ).waitForExist(); + await globalCheck(); }); }); describe('mutual exclusivity', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_mutualExclusivity').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_mutualExclusivity'); + await ( + await getElement('[data-test=LazyMobXTable]') + ).waitForExist(); + await globalCheck(); }); }); describe('plots', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_plots').click(); - $('=mRNA vs mut type').waitForExist(); - $('=mRNA vs mut type').click(); - $('[data-test=PlotsTabPlotDiv]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_plots'); + await ( + await getElement('=mRNA vs mut type') + ).waitForExist(); + await clickElement('=mRNA vs mut type'); + await ( + await getElement('[data-test=PlotsTabPlotDiv]') + ).waitForExist(); + await globalCheck(); }); }); describe('mutations', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_mutations').click(); - $('[data-test=LollipopPlot]').waitForExist(); - $('.tabAnchor_TP53').click(); - $('[data-test=LollipopPlot]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_mutations'); + await ( + await getElement('[data-test=LollipopPlot]') + ).waitForExist(); + await clickElement('.tabAnchor_TP53'); + await ( + await getElement('[data-test=LollipopPlot]') + ).waitForExist(); + await globalCheck(); // $('[data-test=view3DStructure]').click(); // $('.borderedChart canvas').waitForExist(); // globalCheck(); @@ -194,19 +233,23 @@ describe('hide download controls feature', function() { }); describe('co-expression', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_coexpression').click(); - $('#coexpression-plot-svg').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_coexpression'); + await ( + await getElement('#coexpression-plot-svg') + ).waitForExist(); + await globalCheck(); }); }); describe('comparison/survival', () => { - before(() => { - $('.tabAnchor_comparison').click(); + before(async () => { + await clickElement('.tabAnchor_comparison'); }); - it('covers all tabs with download control tests', () => { - $('.tabAnchor_overlap').waitForExist(); + it('covers all tabs with download control tests', async () => { + await ( + await getElement('.tabAnchor_overlap') + ).waitForExist(); const expectedTabNames = [ 'Overlap', 'Survival', @@ -218,11 +261,20 @@ describe('hide download controls feature', function() { 'Mutational Signature', 'Treatment Response', ]; - const observedTabNames = $$( + + const tabElements = $$( '[data-test=ComparisonTabDiv] .tabAnchor' - ) - .filter(a => a.isDisplayed()) - .map(a => a.getText()); + ); + const displayedTabs = await Promise.all( + tabElements.map(async a => + (await a.isDisplayed()) ? a : null + ) + ); + const visibleTabs = displayedTabs.filter(a => a !== null); + const observedTabNames = await Promise.all( + visibleTabs.map(async a => await a.getText()) + ); + assert.deepStrictEqual( expectedTabNames, observedTabNames, @@ -235,134 +287,188 @@ describe('hide download controls feature', function() { ); }); describe('overlap tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_overlap').click(); - $( - '[data-test=ComparisonPageOverlapTabContent]' + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_overlap'); + await ( + await getElement( + '[data-test=ComparisonPageOverlapTabContent]' + ) ).waitForExist(); - globalCheck(); + await globalCheck(); }); }); describe('survival tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_survival').click(); - $('[data-test=SurvivalChart]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_survival'); + await ( + await getElement('[data-test=SurvivalChart]') + ).waitForExist(); + await globalCheck(); }); }); describe('clinical tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_clinical').click(); - $('[data-test=ClinicalTabPlotDiv]').waitForExist(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_clinical'); + await ( + await getElement('[data-test=ClinicalTabPlotDiv]') + ).waitForExist(); + await ( + await getElement('[data-test=LazyMobXTable]') + ).waitForExist(); + await globalCheck(); }); }); describe('alterations tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_alterations').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_alterations'); + await ( + await getElement('[data-test=LazyMobXTable]') + ).waitForExist(); + await globalCheck(); }); }); describe('mrna tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_mrna').click(); - $( - '[data-test=GroupComparisonMRNAEnrichments]' + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_mrna'); + await ( + await getElement( + '[data-test=GroupComparisonMRNAEnrichments]' + ) ).waitForExist(); - $$( - '[data-test=GroupComparisonMRNAEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + await ( + await getNthElements( + '[data-test=GroupComparisonMRNAEnrichments] tbody tr b', + 0 + ) + ).click(); + await ( + await getElement('[data-test=MiniBoxPlot]') + ).waitForExist(); + await globalCheck(); }); }); describe('dna_methylation tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_dna_methylation').click(); - $( - '[data-test=GroupComparisonMethylationEnrichments]' + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_dna_methylation'); + await ( + await getElement( + '[data-test=GroupComparisonMethylationEnrichments]' + ) + ).waitForExist(); + await ( + await getNthElements( + '[data-test=GroupComparisonMethylationEnrichments] tbody tr b', + 0 + ) + ).click(); + await ( + await getElement('[data-test=MiniBoxPlot]') ).waitForExist(); - $$( - '[data-test=GroupComparisonMethylationEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + await globalCheck(); }); }); describe('treatment response tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $( + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( '.tabAnchor_generic_assay_treatment_response' + ); + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments]', + { + waitForExist: true, + } + ); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 0 + ) ).click(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('mutational signature tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $( - '.tabAnchor_generic_assay_mutational_signature' + it('global check for icon and occurrence of "Download" as a word', async () => { + await ( + await clickElement( + '.tabAnchor_generic_assay_mutational_signature' + ) ).click(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' + await ( + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' + ) ).waitForExist(); - browser.pause(1000); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[1].click(); // first row is invisible treatment response 'Name of 17-AAG' - - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + await browser.pause(1000); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 1 + ) + ).click(); // first row is invisible treatment response 'Name of 17-AAG' + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); // Activation of the 'Patient Test' tab results in a backend error. Omitting for now. // Inactivation of download tabs is also covered by other Generic Assay tabs. describe.skip('generic assay patient test tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $( + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( '.tabAnchor_generic_assay_generic_assay_patient_test' - ).click(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[5].click(); // first 5 rows is invisible treatment responses - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + ); + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments]', + { waitForExist: true } + ); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 5 + ) + ).click(); // first 5 rows is invisible treatment responses + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('CN segments', () => { - before(() => { - $('.tabAnchor_cnSegments').click(); - $('.igvContainer').waitForExist(); + before(async () => { + await clickElement('.tabAnchor_cnSegments'); + await getElement('.igvContainer', { + waitForExist: true, + }); }); - it('global check for icon and occurrence of "Download" as a word', () => { - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await globalCheck(); }); }); describe('pathways', () => { - before(() => { - $('.tabAnchor_pathways').click(); - $('.pathwayMapper').waitForExist(); + before(async () => { + await clickElement('.tabAnchor_pathways'); + await getElement('.pathwayMapper', { + waitForExist: true, + }); }); - it('global check for icon and occurrence of "Download" as a word', () => { - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await globalCheck(); }); }); - it('does not show Download tab', () => { - assert(!$('.tabAnchor_download').isExisting()); + it('does not show Download tab', async () => { + assert( + !(await ( + await getElement('.tabAnchor_download') + ).isExisting()) + ); }); }); }); @@ -377,18 +483,26 @@ describe('hide download controls feature', function() { 'Pathology Slide', 'Study Sponsors', ]; - before(() => { - openAndSetProperty( + before(async () => { + await openAndSetProperty( `${CBIOPORTAL_URL}/patient?studyId=study_es_0&caseId=TCGA-A1-A0SK`, { skin_hide_download_controls: 'hide' } ); - waitForPatientView(); - waitForTabs(expectedTabNames.length); - }); - it('covers all tabs with download control tests', () => { - const observedTabNames = $$('.tabAnchor') - .filter(a => a.isDisplayed()) - .map(a => a.getText()); + await waitForPatientView(); + await waitForTabs(expectedTabNames.length); + }); + it('covers all tabs with download control tests', async () => { + const tabElements = $$('.tabAnchor'); + const displayedTabs = await Promise.all( + tabElements.map(async a => + (await a.isDisplayed()) ? a : null + ) + ); + const visibleTabs = displayedTabs.filter(a => a !== null); + const observedTabNames = await Promise.all( + visibleTabs.map(async a => await a.getText()) + ); + assert.deepStrictEqual( expectedTabNames, observedTabNames, @@ -401,52 +515,64 @@ describe('hide download controls feature', function() { ); }); describe('summary tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_summary').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_summary'); + await getElement('[data-test=LazyMobXTable]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('pathways tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_pathways').click(); - $('.pathwayMapper').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_pathways'); + await getElement('.pathwayMapper', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('clinical data tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_clinicalData').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_clinicalData'); + await getElement('[data-test=LazyMobXTable]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('files and links tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_filesAndLinks').click(); - $('.resourcesSection').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_filesAndLinks'); + await getElement('.resourcesSection', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('tissue image tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_tissueImage').click(); - $('iframe').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_tissueImage'); + await getElement('iframe', { waitForExist: true }); + await globalCheck(); }); }); describe('pathology slide tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_openResource_PATHOLOGY_SLIDE').click(); - $('h2').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( + '.tabAnchor_openResource_PATHOLOGY_SLIDE' + ); + await getElement('h2', { waitForExist: true }); + await globalCheck(); }); }); describe('study sponsors tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_openResource_STUDY_SPONSORS').click(); - $('h2').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( + '.tabAnchor_openResource_STUDY_SPONSORS' + ); + await getElement('h2', { waitForExist: true }); + await globalCheck(); }); }); }); @@ -460,19 +586,29 @@ describe('hide download controls feature', function() { 'Plots Beta!', 'Study Sponsors', ]; - before(() => { - openAndSetProperty( + before(async () => { + await openAndSetProperty( `${CBIOPORTAL_URL}/study/summary?id=study_es_0`, { skin_hide_download_controls: 'hide' } ); - waitForStudyView(); - waitForTabs(expectedTabNames.length); + await waitForStudyView(); + await waitForTabs(expectedTabNames.length); }); describe('summary tab', () => { - it('covers all tabs with download control tests', () => { - const observedTabNames = $$('.tabAnchor') - .filter(a => a.isDisplayed()) - .map(a => a.getText()); + it('covers all tabs with download control tests', async () => { + const tabElements = await $$('.tabAnchor'); + console.log('visibleTabs', { tabElements }); + const displayedTabs = await Promise.all( + tabElements.map(async a => + (await a.isDisplayed()) ? a : null + ) + ); + console.log('visibleTabs', { displayedTabs }); + const visibleTabs = displayedTabs.filter(a => a !== null); + console.log('visibleTabs', { visibleTabs }); + const observedTabNames = await Promise.all( + visibleTabs.map(async a => await a.getText()) + ); assert.deepStrictEqual( expectedTabNames, observedTabNames, @@ -484,68 +620,74 @@ describe('hide download controls feature', function() { ' tests for this in hide-download-controls.spec.js.' ); }); - it('global check for icon and occurrence of "Download" as a word', () => { - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await globalCheck(); }); - it('does not show download option in chart menu-s', () => { - studyViewChartHoverHamburgerIcon( + it('does not show download option in chart menu-s', async () => { + await studyViewChartHoverHamburgerIcon( 'chart-container-SAMPLE_COUNT', 1000 ); - globalCheck(); - studyViewChartHoverHamburgerIcon( + await globalCheck(); + await studyViewChartHoverHamburgerIcon( 'chart-container-study_es_0_mutations', 1000 ); - globalCheck(); - studyViewChartHoverHamburgerIcon( + await globalCheck(); + await studyViewChartHoverHamburgerIcon( 'chart-container-MUTATION_COUNT', 1000 ); - globalCheck(); - studyViewChartHoverHamburgerIcon( + await globalCheck(); + await studyViewChartHoverHamburgerIcon( 'chart-container-GENOMIC_PROFILES_SAMPLE_COUNT', 1000 ); - globalCheck(); - studyViewChartHoverHamburgerIcon( + await globalCheck(); + await studyViewChartHoverHamburgerIcon( 'chart-container-FRACTION_GENOME_ALTERED', 1000 ); - globalCheck(); - studyViewChartHoverHamburgerIcon( + await globalCheck(); + await studyViewChartHoverHamburgerIcon( 'chart-container-OS_SURVIVAL', 1000 ); - globalCheck(); + await globalCheck(); }); }); describe('clinical data tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_clinicalData').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_clinicalData'); + await getElement('[data-test=LazyMobXTable]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('CN segments tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_cnSegments').click(); - $('.igvContainer').waitForExist(30000); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_cnSegments'); + await getElement('.igvContainer', { timeout: 30000 }); + await globalCheck(); }); }); describe('files and links tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_filesAndLinks').click(); - $('.resourcesSection').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_filesAndLinks'); + await getElement('.resourcesSection', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('study sponsors tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_openResource_STUDY_SPONSORS').click(); - $('h2').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( + '.tabAnchor_openResource_STUDY_SPONSORS' + ); + await getElement('h2', { waitForExist: true }); + await globalCheck(); }); }); }); @@ -563,20 +705,20 @@ describe('hide download controls feature', function() { 'Mutational Signature', 'Treatment Response', ]; - before(() => { - openAndSetProperty(browser.getUrl(), { + before(async () => { + await openAndSetProperty(await browser.getUrl(), { skin_hide_download_controls: 'show', }); - openGroupComparison( + await openGroupComparison( `${CBIOPORTAL_URL}/study/summary?id=study_es_0`, 'chart-container-OS_STATUS', true, 30000 ); - openAndSetProperty(browser.getUrl(), { + await openAndSetProperty(await browser.getUrl(), { skin_hide_download_controls: 'hide', }); - waitForTabs(expectedTabNames.length); + await waitForTabs(expectedTabNames.length); }); it('covers all tabs with download control tests', () => { const observedTabNames = $$('.tabAnchor') @@ -594,104 +736,162 @@ describe('hide download controls feature', function() { ); }); describe('overlap tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('[data-test=ComparisonPageOverlapTabDiv]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await getElement( + '[data-test=ComparisonPageOverlapTabDiv]', + { + waitForExist: true, + } + ); + await globalCheck(); }); }); describe('survival tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_survival').click(); - $( - '[data-test=ComparisonPageSurvivalTabDiv]' - ).waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_survival'); + await getElement( + '[data-test=ComparisonPageSurvivalTabDiv]', + { + waitForExist: true, + } + ); + await globalCheck(); }); }); describe('clinical tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_clinical').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - $('[data-test=ClinicalTabPlotDiv]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_clinical'); + await getElement('[data-test=LazyMobXTable]', { + waitForExist: true, + }); + await getElement('[data-test=ClinicalTabPlotDiv]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('genomic alterations tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_alterations').click(); - $('[data-test=GeneBarPlotDiv]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_alterations'); + await getElement('[data-test=GeneBarPlotDiv]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('mRNA tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_mrna').click(); - $( - '[data-test=GroupComparisonMRNAEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonMRNAEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_mrna'); + getElement('[data-test=GroupComparisonMRNAEnrichments]', { + waitForExist: true, + }); + await ( + await getNthElements( + '[data-test=GroupComparisonMRNAEnrichments] tbody tr b', + 0 + ) + ).click(); + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('DNA methylation tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_dna_methylation').click(); - $( - '[data-test=GroupComparisonMethylationEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonMethylationEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement('.tabAnchor_dna_methylation'); + await getElement( + '[data-test=GroupComparisonMethylationEnrichments]', + { + waitForExist: true, + } + ); + await ( + await getNthElements( + '[data-test=GroupComparisonMethylationEnrichments] tbody tr b', + 0 + ) + ).click(); + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('treatment response tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_generic_assay_treatment_response').click(); - $('[data-test=LazyMobXTable]').waitForExist(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[0].click(); - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( + '.tabAnchor_generic_assay_treatment_response' + ); + await getElement('[data-test=LazyMobXTable]', { + waitForExist: true, + }); + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments]', + { + waitForExist: true, + } + ); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 0 + ) + ).click(); + + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); describe('mutational signature tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $('.tabAnchor_generic_assay_mutational_signature').click(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - ).waitForExist(); - browser.pause(1000); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[5].click(); // first 5 rows is invisible treatment responses - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( + '.tabAnchor_generic_assay_mutational_signature' + ); + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + { + waitForExist: true, + } + ); + await browser.pause(1000); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 5 + ) + ).click(); // first 5 rows is invisible treatment responses + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); // Activation of the 'Patient Test' tab results in a backend error. Omitting for now. // Inactivation of download tabs is also covered by other Generic Assay tabs. describe.skip('generic assay patient test tab', () => { - it('global check for icon and occurrence of "Download" as a word', () => { - $( + it('global check for icon and occurrence of "Download" as a word', async () => { + await clickElement( '.tabAnchor_generic_assay_generic_assay_patient_test' - ).click(); - $( - '[data-test=GroupComparisonGenericAssayEnrichments]' - ).waitForExist(); - $$( - '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b' - )[5].click(); // first 5 rows is invisible treatment responses - $('[data-test=MiniBoxPlot]').waitForExist(); - globalCheck(); + ); + await getElement( + '[data-test=GroupComparisonGenericAssayEnrichments]', + { + waitForExist: true, + } + ); + await ( + await getNthElements( + '[data-test=GroupComparisonGenericAssayEnrichments] tbody tr b', + 5 + ) + ).click(); // first 5 rows is invisible treatment responses + await getElement('[data-test=MiniBoxPlot]', { + waitForExist: true, + }); + await globalCheck(); }); }); }); diff --git a/end-to-end-test/local/specs/hide-login-button.spec.js b/end-to-end-test/local/specs/hide-login-button.spec.js index e93ee561cbc..e4650667331 100644 --- a/end-to-end-test/local/specs/hide-login-button.spec.js +++ b/end-to-end-test/local/specs/hide-login-button.spec.js @@ -1,16 +1,17 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorageWithProperty = require('../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorageWithProperty, + getElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const loggedInButton = '#rightHeaderContent .identity'; -describe('hide logged-in button feature', function() { - it('does not show logged-in button when portal property set', function() { - goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { +describe('hide logged-in button feature', () => { + it('does not show logged-in button when portal property set', async function() { + await goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { skin_hide_logout_button: true, }); - assert(!$(loggedInButton).isExisting()); + assert(!(await (await getElement(loggedInButton)).isExisting())); }); }); diff --git a/end-to-end-test/local/specs/init-columns-in-cna-tables.spec.js b/end-to-end-test/local/specs/init-columns-in-cna-tables.spec.js index 053ae72c95a..b256968219a 100644 --- a/end-to-end-test/local/specs/init-columns-in-cna-tables.spec.js +++ b/end-to-end-test/local/specs/init-columns-in-cna-tables.spec.js @@ -1,8 +1,8 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, - getElementByTestHandle, -} = require('../../shared/specUtils'); + getNestedElement, +} = require('../../shared/specUtils_Async'); const { waitForTable } = require('./namespace-columns-utils'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -20,58 +20,72 @@ describe('namespace columns in cna tables', function() { const patientViewUrl = `${CBIOPORTAL_URL}/patient?studyId=study_es_0&caseId=TCGA-A2-A04U`; const patientCnaTable = 'patientview-copynumber-table'; - it('shows default columns when property is not set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, {}); - waitForTable(patientCnaTable); - assert(defaultColumnsAreDisplayed()); + it('shows default columns when property is not set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + patientViewUrl, + true, + {} + ); + await waitForTable(patientCnaTable); + assert(await defaultColumnsAreDisplayed()); }); - it('shows selected columns when property is set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows selected columns when property is set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_patient_view_copy_number_table_columns_show_on_init: 'Gene,Annotation,Gene panel', }); - waitForTable(patientCnaTable); - assert(columnIsDisplayed(DEFAULT_COLS.GENE)); - assert(columnIsNotDisplayed(DEFAULT_COLS.CNA)); - assert(columnIsDisplayed(DEFAULT_COLS.ANNOTATION)); - assert(columnIsNotDisplayed(DEFAULT_COLS.CYTOBAND)); - assert(columnIsNotDisplayed(DEFAULT_COLS.COHORT)); - assert(columnIsDisplayed('Gene panel')); //Failing + await waitForTable(patientCnaTable); + assert(await columnIsDisplayed(DEFAULT_COLS.GENE)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.CNA)); + assert(await columnIsDisplayed(DEFAULT_COLS.ANNOTATION)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.CYTOBAND)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.COHORT)); + assert(await columnIsDisplayed('Gene panel')); //Failing }); }); }); - -defaultColumnsAreDisplayed = () => { - const patientCnaTable = 'patientview-copynumber-table'; +const patientCnaTable = '[data-test="patientview-copynumber-table"]'; +const defaultColumnsAreDisplayed = async () => { return ( - getElementByTestHandle(patientCnaTable).$( - `span=${DEFAULT_COLS.GENE}` - ) && - getElementByTestHandle(patientCnaTable).$(`span=${DEFAULT_COLS.CNA}`) && - getElementByTestHandle(patientCnaTable).$( - `span=${DEFAULT_COLS.ANNOTATION}` - ) && - getElementByTestHandle(patientCnaTable).$( - `span=${DEFAULT_COLS.CYTOBAND}` - ) && - getElementByTestHandle(patientCnaTable).$( - `span=${DEFAULT_COLS.COHORT}` - ) && - !$(`[data-test=${patientCnaTable}]`) - .$("//span[text() = 'Gene panel']") - .isDisplayed() + (await getNestedElement([ + patientCnaTable, + `span=${DEFAULT_COLS.GENE}`, + ])) && + (await getNestedElement([ + patientCnaTable, + `span=${DEFAULT_COLS.CNA}`, + ])) && + (await getNestedElement([ + patientCnaTable, + `span=${DEFAULT_COLS.ANNOTATION}`, + ])) && + (await getNestedElement([ + patientCnaTable, + `span=${DEFAULT_COLS.CYTOBAND}`, + ])) && + (await getNestedElement([ + patientCnaTable, + `span=${DEFAULT_COLS.COHORT}`, + ])) && + !(await ( + await getNestedElement([ + patientCnaTable, + "//span[text() = 'Gene panel']", + ]) + ).isDisplayed()) ); }; -function columnIsDisplayed(column) { - return getElementByTestHandle('patientview-copynumber-table').$( - `span=${column}` - ); +async function columnIsDisplayed(column) { + return getNestedElement([patientCnaTable, `span=${column}`]); } -function columnIsNotDisplayed(column) { - return !$(`[data-test=${'patientview-copynumber-table'}]`) - .$("//span[text() = '" + column + "']") - .isDisplayed(); +async function columnIsNotDisplayed(column) { + return !(await ( + await getNestedElement([ + patientCnaTable, + "//span[text() = '" + column + "']", + ]) + ).isDisplayed()); } diff --git a/end-to-end-test/local/specs/init-columns-in-mutation-tables.spec.js b/end-to-end-test/local/specs/init-columns-in-mutation-tables.spec.js index 5fbba2db17e..68f154002f4 100644 --- a/end-to-end-test/local/specs/init-columns-in-mutation-tables.spec.js +++ b/end-to-end-test/local/specs/init-columns-in-mutation-tables.spec.js @@ -1,7 +1,10 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, -} = require('../../shared/specUtils'); + isDisplayed, + getElement, + waitForElementDisplayed, +} = require('../../shared/specUtils_Async'); 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`; @@ -29,195 +32,231 @@ const DEFAULT_PATIENT_COLS = { describe('default init columns in mutation tables', function() { describe('results view', () => { - it('shows default columns when properties not set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, {}); - waitForMutationTable(); - assert(defaultResultColumnsAreDisplayed()); - assert(namespaceColumnsAreNotDisplayed()); + it('shows default columns when properties not set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + resultsViewUrl, + true, + {} + ); + await waitForMutationTable(); + assert(await defaultResultColumnsAreDisplayed()); + assert(await namespaceColumnsAreNotDisplayed()); }); - it('shows default and namespace columns when only namespace property set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { + it('shows default and namespace columns when only namespace property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { skin_mutation_table_namespace_column_show_by_default: true, }); - waitForMutationTable(); - assert(defaultResultColumnsAreDisplayed()); - assert(namespaceColumnsAreDisplayed()); + await waitForMutationTable(); + assert(await defaultResultColumnsAreDisplayed()); + assert(await namespaceColumnsAreDisplayed()); }); - it('shows selected columns when only selected property set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { + it('shows selected columns when only selected property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { skin_results_view_mutation_table_columns_show_on_init: 'Sample ID,Protein Change', }); - waitForMutationTable(); - assert(columnIsDisplayed(DEFAULT_RESULT_COLS.SAMPLE_ID)); - assert(columnIsDisplayed(DEFAULT_RESULT_COLS.PROTEIN_CHANGE)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.ANNOTATION)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.MUTATION_TYPE)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.COPY_NUM)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.COSMIC)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.NUM_MUT_IN_SAMPLE)); - assert(columnIsNotDisplayed('Functional Impact')); - assert(columnIsNotDisplayed('Variant Type')); - assert(namespaceColumnsAreNotDisplayed()); + await waitForMutationTable(); + assert(await columnIsDisplayed(DEFAULT_RESULT_COLS.SAMPLE_ID)); + assert(await columnIsDisplayed(DEFAULT_RESULT_COLS.PROTEIN_CHANGE)); + assert(await columnIsNotDisplayed(DEFAULT_RESULT_COLS.ANNOTATION)); + assert( + await columnIsNotDisplayed(DEFAULT_RESULT_COLS.MUTATION_TYPE) + ); + assert(await columnIsNotDisplayed(DEFAULT_RESULT_COLS.COPY_NUM)); + assert(await columnIsNotDisplayed(DEFAULT_RESULT_COLS.COSMIC)); + assert( + await columnIsNotDisplayed( + DEFAULT_RESULT_COLS.NUM_MUT_IN_SAMPLE + ) + ); + assert(await columnIsNotDisplayed('Functional Impact')); + assert(await columnIsNotDisplayed('Variant Type')); + assert(await namespaceColumnsAreNotDisplayed()); }); - it('shows selected and namespace columns when both properties are set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { + it('shows selected and namespace columns when both properties are set', async () => { + await goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { skin_results_view_mutation_table_columns_show_on_init: 'Sample ID,Protein Change', skin_mutation_table_namespace_column_show_by_default: true, }); - waitForMutationTable(); - assert(columnIsDisplayed(DEFAULT_RESULT_COLS.SAMPLE_ID)); - assert(columnIsDisplayed(DEFAULT_RESULT_COLS.PROTEIN_CHANGE)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.MUTATION_TYPE)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.COPY_NUM)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.COSMIC)); - assert(columnIsNotDisplayed(DEFAULT_RESULT_COLS.NUM_MUT_IN_SAMPLE)); - assert(columnIsNotDisplayed('Functional Impact')); - assert(columnIsNotDisplayed('Variant Type')); - assert(namespaceColumnsAreDisplayed()); + await waitForMutationTable(); + assert(await columnIsDisplayed(DEFAULT_RESULT_COLS.SAMPLE_ID)); + assert(await columnIsDisplayed(DEFAULT_RESULT_COLS.PROTEIN_CHANGE)); + assert( + await columnIsNotDisplayed(DEFAULT_RESULT_COLS.MUTATION_TYPE) + ); + assert(await columnIsNotDisplayed(DEFAULT_RESULT_COLS.COPY_NUM)); + assert(await columnIsNotDisplayed(DEFAULT_RESULT_COLS.COSMIC)); + assert( + await columnIsNotDisplayed( + DEFAULT_RESULT_COLS.NUM_MUT_IN_SAMPLE + ) + ); + assert(await columnIsNotDisplayed('Functional Impact')); + assert(await columnIsNotDisplayed('Variant Type')); + assert(await namespaceColumnsAreDisplayed()); }); }); describe('patient view', () => { - it('shows default columns when properties not set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, {}); - waitForPatientViewMutationTable(); - assert(defaultPatientColumnsAreDisplayed()); - assert(namespaceColumnsAreNotDisplayed()); + it('shows default columns when properties not set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + patientViewUrl, + true, + {} + ); + await waitForPatientViewMutationTable(); + assert(await defaultPatientColumnsAreDisplayed()); + assert(await namespaceColumnsAreNotDisplayed()); }); - it('shows default and namespace columns when only namespace property set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows default and namespace columns when only namespace property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_mutation_table_namespace_column_show_by_default: true, }); - waitForPatientViewMutationTable(); - assert(defaultPatientColumnsAreDisplayed()); - assert(namespaceColumnsAreDisplayed()); + await waitForPatientViewMutationTable(); + assert(await defaultPatientColumnsAreDisplayed()); + assert(await namespaceColumnsAreDisplayed()); }); - it('shows selected columns when only selected property set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows selected columns when only selected property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_patient_view_mutation_table_columns_show_on_init: 'Gene,Protein Change', }); - waitForPatientViewMutationTable(); - assert(columnIsDisplayed(DEFAULT_PATIENT_COLS.GENE)); - assert(columnIsDisplayed(DEFAULT_PATIENT_COLS.PROTEIN_CHANGE)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.ANNOTATION)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.MUTATION_TYPE)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COPY_NUM)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COHORT)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COSMIC)); - assert(columnIsNotDisplayed('Functional Impact')); - assert(columnIsNotDisplayed('Variant Type')); - assert(namespaceColumnsAreNotDisplayed()); + await waitForPatientViewMutationTable(); + assert(await columnIsDisplayed(DEFAULT_PATIENT_COLS.GENE)); + assert( + await columnIsDisplayed(DEFAULT_PATIENT_COLS.PROTEIN_CHANGE) + ); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.ANNOTATION)); + assert( + await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.MUTATION_TYPE) + ); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COPY_NUM)); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COHORT)); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COSMIC)); + assert(await columnIsNotDisplayed('Functional Impact')); + assert(await columnIsNotDisplayed('Variant Type')); + assert(await namespaceColumnsAreNotDisplayed()); }); - it('shows selected and namespace columns when both properties are set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows selected and namespace columns when both properties are set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_patient_view_mutation_table_columns_show_on_init: 'Gene,Protein Change', skin_mutation_table_namespace_column_show_by_default: true, }); - waitForPatientViewMutationTable(); - assert(columnIsDisplayed(DEFAULT_PATIENT_COLS.GENE)); - assert(columnIsDisplayed(DEFAULT_PATIENT_COLS.PROTEIN_CHANGE)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.ANNOTATION)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.MUTATION_TYPE)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COPY_NUM)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COHORT)); - assert(columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COSMIC)); - assert(columnIsNotDisplayed('Functional Impact')); - assert(columnIsNotDisplayed('Variant Type')); - assert(namespaceColumnsAreDisplayed()); + await waitForPatientViewMutationTable(); + assert(await columnIsDisplayed(DEFAULT_PATIENT_COLS.GENE)); + assert( + await columnIsDisplayed(DEFAULT_PATIENT_COLS.PROTEIN_CHANGE) + ); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.ANNOTATION)); + assert( + await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.MUTATION_TYPE) + ); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COPY_NUM)); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COHORT)); + assert(await columnIsNotDisplayed(DEFAULT_PATIENT_COLS.COSMIC)); + assert(await columnIsNotDisplayed('Functional Impact')); + assert(await columnIsNotDisplayed('Variant Type')); + assert(await namespaceColumnsAreDisplayed()); }); }); }); -defaultResultColumnsAreDisplayed = () => { +const defaultResultColumnsAreDisplayed = async () => { return ( - $( + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.SAMPLE_ID + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.PROTEIN_CHANGE + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.ANNOTATION + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.MUTATION_TYPE + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.COPY_NUM + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.COSMIC + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_RESULT_COLS.NUM_MUT_IN_SAMPLE + "']" - ).isDisplayed() && - !$("//span[text() = 'Functional Impact']").isDisplayed() && - !$("//span[text() = 'Variant Type']").isDisplayed() + )) && + !(await isDisplayed("//span[text() = 'Functional Impact']")) && + !(await isDisplayed("//span[text() = 'Variant Type']")) ); }; -defaultPatientColumnsAreDisplayed = () => { +const defaultPatientColumnsAreDisplayed = async () => { return ( - $( + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.GENE + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.PROTEIN_CHANGE + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.ANNOTATION + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.MUTATION_TYPE + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.COPY_NUM + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.COHORT + "']" - ).isDisplayed() && - $( + )) && + (await isDisplayed( "//span[text() = '" + DEFAULT_PATIENT_COLS.COSMIC + "']" - ).isDisplayed() && - !$("//span[text() = 'Functional Impact']").isDisplayed() && - !$("//span[text() = 'Variant Type']").isDisplayed() + )) && + !(await isDisplayed("//span[text() = 'Functional Impact']")) && + !(await isDisplayed("//span[text() = 'Variant Type']")) ); }; -namespaceColumnsAreDisplayed = () => { +const namespaceColumnsAreDisplayed = async () => { return ( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() + (await isDisplayed("//span[text() = 'Zygosity Code']")) && + (await isDisplayed("//span[text() = 'Zygosity Name']")) ); }; -namespaceColumnsAreNotDisplayed = () => { +const namespaceColumnsAreNotDisplayed = async () => { return !( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() + (await ( + await getElement("//span[text() = 'Zygosity Code']") + ).isDisplayed()) && + (await ( + await getElement("//span[text() = 'Zygosity Name']") + ).isDisplayed()) ); }; -function columnIsDisplayed(column) { - return $("//span[text() = '" + column + "']").isDisplayed(); +async function columnIsDisplayed(column) { + return ( + await getElement("//span[text() = '" + column + "']") + ).isDisplayed(); } -function columnIsNotDisplayed(column) { - return !$("//span[text() = '" + column + "']").isDisplayed(); +async function columnIsNotDisplayed(column) { + return !( + await getElement("//span[text() = '" + column + "']") + ).isDisplayed(); } -waitForMutationTable = () => { - $('[data-test=LazyMobXTable]').waitForDisplayed(); +const waitForMutationTable = async () => { + await waitForElementDisplayed('[data-test=LazyMobXTable]'); }; -waitForPatientViewMutationTable = () => { - $('[data-test=patientview-mutation-table]').waitForDisplayed(); - $('[data-test=LazyMobXTable]').waitForDisplayed(); +const waitForPatientViewMutationTable = async () => { + await waitForElementDisplayed('[data-test=patientview-mutation-table]'); + await waitForElementDisplayed('[data-test=LazyMobXTable]'); }; diff --git a/end-to-end-test/local/specs/init-columns-in-struct-var-tables.spec.js b/end-to-end-test/local/specs/init-columns-in-struct-var-tables.spec.js index 85993aabae6..b5702032b3f 100644 --- a/end-to-end-test/local/specs/init-columns-in-struct-var-tables.spec.js +++ b/end-to-end-test/local/specs/init-columns-in-struct-var-tables.spec.js @@ -2,7 +2,9 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, getElementByTestHandle, -} = require('../../shared/specUtils'); + waitForElementDisplayed, + getNestedElement, +} = require('../../shared/specUtils_Async'); const { waitForTable } = require('./namespace-columns-utils'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -22,69 +24,79 @@ describe('namespace columns in structural variant tables', function() { const patientViewUrl = `${CBIOPORTAL_URL}/patient?studyId=study_es_0&caseId=TCGA-A2-A04P`; const patientStructVarTable = 'patientview-structural-variant-table'; - it('shows default columns when property is not set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, {}); - waitForTable(patientStructVarTable); + it('shows default columns when property is not set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + patientViewUrl, + true, + {} + ); + await waitForTable(patientStructVarTable); - assert(defaultColumnsAreDisplayed()); + assert(await defaultColumnsAreDisplayed()); }); - it('shows selected columns when property is set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows selected columns when property is set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_patient_view_structural_variant_table_columns_show_on_init: 'Gene 1,Annotation,Breakpoint Type', }); - waitForTable(patientStructVarTable); - assert(columnIsDisplayed(DEFAULT_COLS.GENE_1)); - assert(columnIsNotDisplayed(DEFAULT_COLS.GENE_2)); - assert(columnIsNotDisplayed(DEFAULT_COLS.STATUS)); - assert(columnIsDisplayed(DEFAULT_COLS.ANNOTATION)); - assert(columnIsNotDisplayed(DEFAULT_COLS.VARIANT_CLASS)); - assert(columnIsNotDisplayed(DEFAULT_COLS.EVENT_INFO)); - assert(columnIsNotDisplayed(DEFAULT_COLS.CONNECTION_TYPE)); - assert(columnIsDisplayed('Breakpoint Type')); + await waitForTable(patientStructVarTable); + assert(await columnIsDisplayed(DEFAULT_COLS.GENE_1)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.GENE_2)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.STATUS)); + assert(await columnIsDisplayed(DEFAULT_COLS.ANNOTATION)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.VARIANT_CLASS)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.EVENT_INFO)); + assert(await columnIsNotDisplayed(DEFAULT_COLS.CONNECTION_TYPE)); + assert(await columnIsDisplayed('Breakpoint Type')); }); }); }); -defaultColumnsAreDisplayed = () => { +const defaultColumnsAreDisplayed = async () => { const patientStructVarTable = 'patientview-structural-variant-table'; return ( - $("//span[text() = '" + DEFAULT_COLS.GENE_1 + "']").waitForDisplayed({ - timeout: 10000, - }) && - getElementByTestHandle(patientStructVarTable).$( + (await waitForElementDisplayed( + "//span[text() = '" + DEFAULT_COLS.GENE_1 + "']", + { + timeout: 10000, + } + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.GENE_2}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.STATUS}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.ANNOTATION}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.VARIANT_CLASS}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.EVENT_INFO}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span=${DEFAULT_COLS.CONNECTION_TYPE}` - ) && - getElementByTestHandle(patientStructVarTable).$( + )) && + (await (await getElementByTestHandle(patientStructVarTable)).$( `span='Breakpoint Type'` - ) + )) ); }; -function columnIsDisplayed(column) { - return getElementByTestHandle('patientview-structural-variant-table').$( - `span=${column}` - ); +async function columnIsDisplayed(column) { + return ( + await getElementByTestHandle('patientview-structural-variant-table') + ).$(`span=${column}`); } -function columnIsNotDisplayed(column) { - return !$(`[data-test=${'patientview-structural-variant-table'}]`) - .$("//span[text() = '" + column + "']") - .isDisplayed(); +async function columnIsNotDisplayed(column) { + return !(await ( + await getNestedElement([ + `[data-test=${'patientview-structural-variant-table'}]`, + "//span[text() = '" + column + "']", + ]) + ).isDisplayed()); } 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 247bb3c57b1..62e48481f8e 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 @@ -1,7 +1,7 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, -} = require('../../shared/specUtils'); +} = require('../../shared/specUtils_Async'); const { namespaceColumnsAreNotDisplayed, waitForTable, @@ -24,30 +24,34 @@ describe('namespace columns in cna tables', function() { const patientCnaTable = 'patientview-copynumber-table'; const geneWithCustomNamespaceData = 'ACAP3'; - it('hides namespace columns when no property set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, {}); - waitForTable(patientCnaTable); - assert(namespaceColumnsAreNotDisplayed(namespaceColumns)); + it('hides namespace columns when no property set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + patientViewUrl, + true, + {} + ); + await waitForTable(patientCnaTable); + assert(await namespaceColumnsAreNotDisplayed(namespaceColumns)); }); - it('shows columns when column menu is used', () => { - clickColumnSelectionButton(patientCnaTable); - selectColumn(namespaceColumn1); - selectColumn(namespaceColumn2); - clickColumnSelectionButton(patientCnaTable); - assert(namespaceColumnsAreDisplayed(namespaceColumns)); + it('shows columns when column menu is used', async () => { + await clickColumnSelectionButton(patientCnaTable); + await selectColumn(namespaceColumn1); + await selectColumn(namespaceColumn2); + await clickColumnSelectionButton(patientCnaTable); + assert(await namespaceColumnsAreDisplayed(namespaceColumns)); }); /** * Expected custom namespace columns to be shown */ - it('displays custom namespace data', () => { - const rowWithNamespaceData = getRowByGene( + it('displays custom namespace data', async () => { + const rowWithNamespaceData = await getRowByGene( patientCnaTable, geneWithCustomNamespaceData ); assert(!!rowWithNamespaceData); - const text = rowWithNamespaceData.getText(); + const text = await rowWithNamespaceData.getText(); assert(text.includes(namespaceValue1)); assert(text.includes(namespaceValue2)); }); 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..e3ee746eefb 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 @@ -1,7 +1,13 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, -} = require('../../shared/specUtils'); + clickElement, + setInputText, + getNestedElement, + getElement, + isDisplayed, + waitForElementDisplayed, +} = require('../../shared/specUtils_Async'); 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`; @@ -9,57 +15,79 @@ const patientViewUrl = `${CBIOPORTAL_URL}/patient?sampleId=TEST_SAMPLE_SOMATIC_H describe('namespace columns in mutation tables', function() { describe('results view', () => { - it('hides namespace columns when no property set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, {}); - waitForMutationTable(); - assert(namespaceColumnsAreNotDisplayed()); + it('hides namespace columns when no property set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + resultsViewUrl, + true, + {} + ); + await waitForMutationTable(); + assert(await namespaceColumnsAreNotDisplayed()); }); - it('shows columns when column menu is used', () => { + it('shows columns when column menu is used', async () => { // Click on column button. - $('button*=Columns').click(); + await clickElement('button*=Columns'); // Filter menu options. - $('[data-test=fixed-header-table-search-input]').setValue( + await setInputText( + '[data-test=fixed-header-table-search-input]', 'zygosity' ); - $('[data-test=add-by-type]') - .$('div*=Zygosity') - .waitForDisplayed(); + await ( + await getNestedElement([ + '[data-test=add-by-type]', + 'div*=Zygosity', + ]) + ).waitForDisplayed(); // Click namespace column checkboxes. - $('[data-test=add-by-type]') + await (await getElement('[data-test=add-by-type]')) .$$('div*=Zygosity') - .forEach(checkbox => checkbox.click()); - $('button*=Columns').click(); - assert(namespaceColumnsAreDisplayed()); + .forEach(async checkbox => await checkbox.click()); + await clickElement('button*=Columns'); + assert(await namespaceColumnsAreDisplayed()); }); - it('shows namespace columns when property set', () => { - goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { + it('shows namespace columns when property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(resultsViewUrl, true, { skin_mutation_table_namespace_column_show_by_default: true, }); - waitForMutationTable(); - assert(namespaceColumnsAreDisplayed()); + await waitForMutationTable(); + assert(await namespaceColumnsAreDisplayed()); }); - it('has filter icons', () => { - $("//span[text() = 'Zygosity Code']").click(); - filterIconOfHeader( - "//span[text() = 'Zygosity Code']" + it('has filter icons', async () => { + await clickElement("//span[text() = 'Zygosity Code']"); + await ( + await filterIconOfHeader("//span[text() = 'Zygosity Code']") ).waitForDisplayed(); - $("//span[text() = 'Zygosity Name']").click(); - filterIconOfHeader( - "//span[text() = 'Zygosity Name']" + await clickElement("//span[text() = 'Zygosity Name']"); + await ( + await filterIconOfHeader("//span[text() = 'Zygosity Name']") ).waitForDisplayed(); }); - it('filters rows when using numerical filter menu', () => { - filterIconOfHeader("//span[text() = 'Zygosity Code']").click(); + it('filters rows when using numerical filter menu', async () => { + await ( + await filterIconOfHeader("//span[text() = 'Zygosity Code']") + ).click(); // Empty rows - var numberOfRowsBefore = numberOfTableRows(); - $('#Zygosity_Code-lowerValue-box').setValue('2'); - $('[data-test=numerical-filter-menu-remove-empty-rows]').click(); - browser.waitUntil(() => numberOfTableRows() < numberOfRowsBefore); + const numberOfRowsBefore = await numberOfTableRows(); + await (await getElement('#Zygosity_Code-lowerValue-box')).setValue( + '2' + ); + await clickElement( + '[data-test=numerical-filter-menu-remove-empty-rows]' + ); + await browser.waitUntil( + async () => (await numberOfTableRows()) < numberOfRowsBefore + ); // reset state - $('#Zygosity_Code-lowerValue-box').setValue('1'); - $('[data-test=numerical-filter-menu-remove-empty-rows]').click(); - browser.waitUntil(() => numberOfTableRows() === numberOfRowsBefore); + await (await getElement('#Zygosity_Code-lowerValue-box')).setValue( + '1' + ); + await clickElement( + '[data-test=numerical-filter-menu-remove-empty-rows]' + ); + await browser.waitUntil( + async () => (await numberOfTableRows()) === numberOfRowsBefore + ); }); it('filters rows when using categorical filter menu', () => { filterIconOfHeader("//span[text() = 'Zygosity Name']").click(); @@ -77,56 +105,65 @@ describe('namespace columns in mutation tables', function() { waitForPatientViewMutationTable(); assert(namespaceColumnsAreNotDisplayed()); }); - it('shows columns when column menu is used', () => { + it('shows columns when column menu is used', async () => { // Click on column button. - $('[data-test=patientview-mutation-table]') - .$('button*=Columns') - .click(); + await ( + await getNestedElement([ + '[data-test=patientview-mutation-table]', + 'button*=Columns', + ]) + ).click(); // Click namespace column checkboxes. - $('[data-id="Zygosity Code"]').click(); - $('[data-id="Zygosity Name"]').click(); - $('[data-test=patientview-mutation-table]') - .$('button*=Columns') - .click(); - assert(namespaceColumnsAreDisplayed()); + await clickElement('[data-id="Zygosity Code"]'); + await clickElement('[data-id="Zygosity Name"]'); + await ( + await getNestedElement([ + '[data-test=patientview-mutation-table]', + 'button*=Columns', + ]) + ).click(); + assert(await namespaceColumnsAreDisplayed()); }); - it('shows namespace columns when property set', () => { - goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { + it('shows namespace columns when property set', async () => { + await goToUrlAndSetLocalStorageWithProperty(patientViewUrl, true, { skin_mutation_table_namespace_column_show_by_default: true, }); - waitForPatientViewMutationTable(); - assert(namespaceColumnsAreDisplayed()); + await waitForPatientViewMutationTable(); + assert(await namespaceColumnsAreDisplayed()); }); }); }); -waitForMutationTable = () => { - $('[data-test=LazyMobXTable]').waitForDisplayed(); +const waitForMutationTable = async () => { + await waitForElementDisplayed('[data-test=LazyMobXTable]'); }; -waitForPatientViewMutationTable = () => { - $('[data-test=patientview-mutation-table]').waitForDisplayed(); +const waitForPatientViewMutationTable = async () => { + await waitForElementDisplayed('[data-test=patientview-mutation-table]'); }; -namespaceColumnsAreDisplayed = () => { +const namespaceColumnsAreDisplayed = async () => { return ( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() + (await isDisplayed("//span[text() = 'Zygosity Code']")) && + (await isDisplayed("//span[text() = 'Zygosity Name']")) ); }; -namespaceColumnsAreNotDisplayed = () => { +const namespaceColumnsAreNotDisplayed = async () => { return !( - $("//span[text() = 'Zygosity Code']").isDisplayed() && - $("//span[text() = 'Zygosity Name']").isDisplayed() + (await isDisplayed("//span[text() = 'Zygosity Code']")) && + (await isDisplayed("//span[text() = 'Zygosity Name']")) ); }; -filterIconOfHeader = selector => { - return $(selector) - .parentElement() - .parentElement() - .$('.fa-filter'); +const filterIconOfHeader = async selector => { + // return await (await ( + // await (await $(selector)) + // .parentElement()) + // .parentElement()) + // .$('.fa-filter'); + + return getNestedElement([selector, '..', '..', '.fa-filter']); }; -numberOfTableRows = () => $$('.lazy-mobx-table tr').length; +const numberOfTableRows = async () => (await $$('.lazy-mobx-table tr')).length; 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 index f4599925d14..276e5b85e1d 100644 --- 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 @@ -1,7 +1,7 @@ const assert = require('assert'); const { goToUrlAndSetLocalStorageWithProperty, -} = require('../../shared/specUtils'); +} = require('../../shared/specUtils_Async'); const { namespaceColumnsAreNotDisplayed, waitForTable, @@ -24,30 +24,34 @@ describe('namespace columns in struct var tables', function() { 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('hides namespace columns when no property set', async () => { + await goToUrlAndSetLocalStorageWithProperty( + patientViewUrl, + true, + {} + ); + await waitForTable(patientStructVarTable); + assert(await namespaceColumnsAreNotDisplayed(namespaceColumns)); }); - it('shows columns when column menu is used', () => { - clickColumnSelectionButton(patientStructVarTable); - selectColumn(namespaceColumn1); - selectColumn(namespaceColumn2); - clickColumnSelectionButton(patientStructVarTable); - assert(namespaceColumnsAreDisplayed(namespaceColumns)); + it('shows columns when column menu is used', async () => { + await clickColumnSelectionButton(patientStructVarTable); + await selectColumn(namespaceColumn1); + await selectColumn(namespaceColumn2); + await clickColumnSelectionButton(patientStructVarTable); + assert(await namespaceColumnsAreDisplayed(namespaceColumns)); }); /** * Expected custom namespace columns to be shown */ - it('displays custom namespace data', () => { - const rowWithNamespaceData = getRowByGene( + it('displays custom namespace data', async () => { + const rowWithNamespaceData = await getRowByGene( patientStructVarTable, geneWithCustomNamespaceData ); assert(!!rowWithNamespaceData); - const text = rowWithNamespaceData.getText(); + const text = await 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 index 95ed902d0fe..71a54246c55 100644 --- a/end-to-end-test/local/specs/namespace-columns-utils.js +++ b/end-to-end-test/local/specs/namespace-columns-utils.js @@ -1,33 +1,51 @@ -const clickColumnSelectionButton = patientCnaTable => { - $(`[data-test=${patientCnaTable}]`) - .$('button*=Columns') - .click(); +const { + getElement, + getNestedElement, + clickElement, + isDisplayed, +} = require('../../shared/specUtils_Async'); + +const clickColumnSelectionButton = async patientCnaTable => { + await ( + await getNestedElement([ + `[data-test=${patientCnaTable}]`, + 'button*=Columns', + ]) + ).click(); }; -const selectColumn = namespaceColumn1 => { - $(`[data-id="${namespaceColumn1}"]`).click(); +const selectColumn = async namespaceColumn1 => { + await clickElement(`[data-id="${namespaceColumn1}"]`); }; -const waitForTable = table => { - $(`[data-test=${table}]`).waitForDisplayed(); +const waitForTable = async table => { + await (await getElement(`[data-test=${table}]`)).waitForDisplayed(); }; -const namespaceColumnsAreDisplayed = columns => { +const namespaceColumnsAreDisplayed = async columns => { for (const column of columns) { - if (!$(`//span[text()='${column}']`).isDisplayed()) { + if (!(await isDisplayed(`//span[text()='${column}']`))) { return false; } } return true; }; -const namespaceColumnsAreNotDisplayed = columns => { +const namespaceColumnsAreNotDisplayed = async columns => { return !namespaceColumnsAreDisplayed(columns); }; -const getRowByGene = (tableName, gene) => { - const tableRows = $$(`[data-test="${tableName}"] tr`); - return tableRows.find(r => r.$('td=' + gene).isExisting()); +const getRowByGene = async (tableName, gene) => { + const tableRows = await $$(`[data-test="${tableName}"] tr`); + + for (const row of tableRows) { + const cell = await row.$(`td=${gene}`); + if (await cell.isExisting()) { + return row; + } + } + + return null; }; module.exports = { diff --git a/end-to-end-test/local/specs/struct-var-table.spec.js b/end-to-end-test/local/specs/struct-var-table.spec.js index 40647686583..091ed9269b5 100644 --- a/end-to-end-test/local/specs/struct-var-table.spec.js +++ b/end-to-end-test/local/specs/struct-var-table.spec.js @@ -1,7 +1,13 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorageWithProperty = require('../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; -var waitForStudyView = require('../../shared/specUtils').waitForStudyView; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorageWithProperty, + waitForStudyView, + getNestedElement, + getElement, + clickElement, + getNthElements, + waitForElementDisplayed, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const studyViewUrl = `${CBIOPORTAL_URL}/study/summary?id=study_es_0`; @@ -14,141 +20,172 @@ const structVarNameCell = '[data-test=structVarNameCell]'; const toast = '.Toastify div[role=alert]'; describe('study view structural variant table', function() { - beforeEach(() => { - goToUrlAndSetLocalStorageWithProperty(studyViewUrl, true, { + beforeEach(async () => { + await goToUrlAndSetLocalStorageWithProperty(studyViewUrl, true, { skin_study_view_show_sv_table: true, }); - waitForStudyView(); - showSvPane(); + await waitForStudyView(); + await showSvPane(); }); - it('adds structural variant to study view filter', () => { - $(structVarTable) - .$(filterCheckBox) - .click(); - $('[data-test=selectSamplesButton]').waitForExist(); - $('[data-test=selectSamplesButton]').click(); - assert($(structVarFilterPillTag).isExisting()); + it('adds structural variant to study view filter', async () => { + await ( + await getNestedElement([structVarTable, filterCheckBox]) + ).click(); + await getElement('[data-test=selectSamplesButton]', { + waitForExist: true, + }); + await clickElement('[data-test=selectSamplesButton]'); + assert(await (await getElement(structVarFilterPillTag)).isExisting()); }); - it.skip('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'); + it.skip('shows all checkboxes when row is hovered', async () => { + await getElement(structVarNameCell, { + waitForExist: true, + }); + const firstSvRowCell = await getNthElements(structVarNameCell, 0); + assert.equal( + await (await getNthElements(structVarNameCell, 1)).getText(), + 'SND1' + ); + assert.equal( + await (await getNthElements(structVarNameCell, 2)).getText(), + 'BRAF' + ); - movePointerWithRetry(firstSvRowCell, () => - $(uncheckedSvIcon).waitForDisplayed() + await movePointerWithRetry( + firstSvRowCell, + async () => await waitForElementDisplayed(uncheckedSvIcon) ); - assert.equal($$(uncheckedSvIcon).length, 3); + assert.equal((await $$(uncheckedSvIcon)).length, 3); }); - it.skip('shows only checked checkboxes when row is not hovered', () => { - $(structVarNameCell).waitForExist(); - const gene1Cell = $$(structVarNameCell)[1]; - movePointerWithRetry(gene1Cell, () => - $(uncheckedSvIcon).waitForDisplayed() + it.skip('shows only checked checkboxes when row is not hovered', async () => { + await getElement(structVarNameCell, { + waitForExist: true, + }); + const gene1Cell = getNestedElement(structVarNameCell, 1); + await movePointerWithRetry( + gene1Cell, + async () => await waitForElementDisplayed(uncheckedSvIcon) ); - assert.equal($$(uncheckedSvIcon).length, 3); + assert.equal((await $$(uncheckedSvIcon)).length, 3); - gene1Cell.waitForClickable(); - gene1Cell.click(); + await gene1Cell.waitForClickable(); + await gene1Cell.click(); // hover somewhere else: - movePointerWithRetry($('span=Gene 2'), $(checkedSvIcon).waitForExist()); + await movePointerWithRetry( + await getElement('span=Gene 2'), + await getElement(checkedSvIcon, { + waitForExist: true, + }) + ); - assert.equal($$(uncheckedSvIcon).length, 0); - assert.equal($$(checkedSvIcon).length, 1); + assert.equal((await $$(uncheckedSvIcon)).length, 0); + assert.equal((await $$(checkedSvIcon)).length, 1); }); - it.skip('adds gene1::gene2 to Results View query', () => { - $(structVarNameCell).waitForExist(); - const firstSvRowCell = $$(structVarNameCell)[0]; - - movePointerWithRetry(firstSvRowCell, () => { - $$(uncheckedSvIcon)[0].waitForClickable(); + it.skip('adds gene1::gene2 to Results View query', async () => { + await getElement(structVarNameCell, { + waitForExist: true, }); - const gene1And2Checkbox = $$(uncheckedSvIcon)[0]; - gene1And2Checkbox.click(); - $(toast).waitForDisplayed(); - clearToast(); + const firstSvRowCell = await getNthElements(structVarNameCell, 0); - const resultsViewQueryBox = openResultViewQueryBox(); - assert.equal('SND1: FUSION::BRAF;', resultsViewQueryBox.getValue()); + await movePointerWithRetry(firstSvRowCell, async () => { + await (await getNthElements(uncheckedSvIcon, 0)).waitForClickable(); + }); + const gene1And2Checkbox = await getNthElements(uncheckedSvIcon, 0); + await gene1And2Checkbox.click(); + await waitForElementDisplayed(toast); + await clearToast(); + + const resultsViewQueryBox = await openResultViewQueryBox(); + assert.equal( + 'SND1: FUSION::BRAF;', + await resultsViewQueryBox.getValue() + ); }); - it.skip('adds gene1::* to Results View query', () => { - $(structVarNameCell).waitForExist(); - const gene1Cell = $$(structVarNameCell)[1]; - movePointerWithRetry(gene1Cell, () => - $(uncheckedSvIcon).waitForDisplayed() + it.skip('adds gene1::* to Results View query', async () => { + await getElement(structVarNameCell, { + waitForExist: true, + }); + const gene1Cell = getNthElements(structVarNameCell, 1); + await movePointerWithRetry( + gene1Cell, + async () => await waitForElementDisplayed(uncheckedSvIcon) ); - gene1Cell.waitForClickable(); - gene1Cell.click(); - $(toast).waitForDisplayed(); - clearToast(); + await gene1Cell.waitForClickable(); + await gene1Cell.click(); + await waitForElementDisplayed(toast); + await clearToast(); - const resultsViewQueryBox = openResultViewQueryBox(); - assert.equal('SND1: FUSION::;', resultsViewQueryBox.getValue()); + const resultsViewQueryBox = await openResultViewQueryBox(); + assert.equal('SND1: FUSION::;', await resultsViewQueryBox.getValue()); }); - it.skip('adds *::gene2 to Results View query', () => { - $(structVarNameCell).waitForExist(); - const gene2Cell = $$(structVarNameCell)[2]; - movePointerWithRetry(gene2Cell, () => - $(uncheckedSvIcon).waitForDisplayed() + it.skip('adds *::gene2 to Results View query', async () => { + await getElement(structVarNameCell, { + waitForExist: true, + }); + const gene2Cell = await getNthElements(structVarNameCell, 2); + await movePointerWithRetry( + gene2Cell, + async () => await waitForElementDisplayed(uncheckedSvIcon) ); - gene2Cell.waitForClickable(); - gene2Cell.click(); - $(toast).waitForDisplayed(); - clearToast(); + await gene2Cell.waitForClickable(); + await gene2Cell.click(); + await waitForElementDisplayed(toast); + await clearToast(); - const resultsViewQueryBox = openResultViewQueryBox(); - assert.equal('BRAF: ::FUSION;', resultsViewQueryBox.getValue()); + const resultsViewQueryBox = await openResultViewQueryBox(); + assert.equal('BRAF: ::FUSION;', await resultsViewQueryBox.getValue()); }); }); -function showSvPane() { - const $chartsBtn = $('[data-test=add-charts-button]'); - $chartsBtn.waitForExist(); - $chartsBtn.waitForClickable(); - $chartsBtn.click(); - const $chartsGenomicTab = $('.tabAnchor_Genomic'); - $chartsGenomicTab.waitForExist(); - $chartsGenomicTab.waitForClickable(); - $chartsGenomicTab.click(); - const $svChartCheckbox = $( - '[data-test="add-chart-option-structural-variants"]' - ).$('[data-test="labeledCheckbox"]'); - $svChartCheckbox.waitForExist(); - $svChartCheckbox.waitForClickable(); - if (!$svChartCheckbox.isSelected()) { - $svChartCheckbox.click(); +async function showSvPane() { + const $chartsBtn = getElement('[data-test=add-charts-button]'); + await $chartsBtn.waitForExist(); + await $chartsBtn.waitForClickable(); + await $chartsBtn.click(); + const $chartsGenomicTab = getElement('.tabAnchor_Genomic'); + await $chartsGenomicTab.waitForExist(); + await $chartsGenomicTab.waitForClickable(); + await $chartsGenomicTab.click(); + const $svChartCheckbox = await getNestedElement([ + '[data-test="add-chart-option-structural-variants"]', + '[data-test="labeledCheckbox"]', + ]); + await $svChartCheckbox.waitForExist(); + await $svChartCheckbox.waitForClickable(); + if (!(await $svChartCheckbox.isSelected())) { + await $svChartCheckbox.click(); } - $chartsBtn.click(); - waitForStudyView(); + await $chartsBtn.click(); + await waitForStudyView(); } -function openResultViewQueryBox() { - const resultsViewQueryBox = $('[data-test=geneSet]'); - resultsViewQueryBox.waitForClickable(); - resultsViewQueryBox.click(); +async function openResultViewQueryBox() { + const resultsViewQueryBox = getElement('[data-test=geneSet]'); + await resultsViewQueryBox.waitForClickable(); + await resultsViewQueryBox.click(); return resultsViewQueryBox; } -function clearToast() { - const toastify = $('.Toastify button'); - toastify.waitForClickable(); - toastify.click(); - browser.pause(100); +async function clearToast() { + const toastify = await getElement('.Toastify button'); + await toastify.waitForClickable(); + await toastify.click(); + await browser.pause(100); } -function movePointerTo(element) { - element.waitForDisplayed(); - element.scrollIntoView(); - const x = element.getLocation('x'); - const y = element.getLocation('y'); - browser.performActions([ +async function movePointerTo(element) { + await element.waitForDisplayed(); + await element.scrollIntoView(); + const x = await element.getLocation('x'); + const y = await element.getLocation('y'); + await browser.performActions([ { type: 'pointer', parameters: { pointerType: 'mouse' }, @@ -164,14 +201,14 @@ function movePointerTo(element) { * 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); +async function movePointerWithRetry(element, isOk) { + await movePointerTo(element); try { - if (isOk()) { + if (await isOk()) { return; } } catch (e) { // retry - movePointerTo(element); + await movePointerTo(element); } } diff --git a/end-to-end-test/local/specs/study-view-custom-bins.screenshot.spec.js b/end-to-end-test/local/specs/study-view-custom-bins.screenshot.spec.js index 2c7465f9fee..8c304d81af3 100644 --- a/end-to-end-test/local/specs/study-view-custom-bins.screenshot.spec.js +++ b/end-to-end-test/local/specs/study-view-custom-bins.screenshot.spec.js @@ -4,7 +4,11 @@ const { checkElementWithMouseDisabled, goToUrlAndSetLocalStorage, jsApiHover, -} = require('../../shared/specUtils'); + getElement, + waitForElementDisplayed, + getNestedElement, + setInputText, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const studyViewUrl = `${CBIOPORTAL_URL}/study/summary?id=lgg_ucsf_2014_test_generic_assay`; @@ -18,72 +22,72 @@ const MIN_VALUE_INPUT = '[data-test=anchorvalue-input]'; const CUSTOM_BINS_TEXTAREA = '[data-test=custom-bins-textarea]'; describe('Custom Bins menu in study view chart header', function() { - beforeEach(() => { - goToUrlAndSetLocalStorage(studyViewUrl, true); - openCustomBinsMenu(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(studyViewUrl, true); + await openCustomBinsMenu(); }); - it('creates quartiles bins', () => { - selectMenuOption('label=Quartiles'); - clickUpdate(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(MUTATION_COUNT_CHART); + it('creates quartiles bins', async () => { + await selectMenuOption('label=Quartiles'); + await clickUpdate(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(MUTATION_COUNT_CHART); assertScreenShotMatch(res); }); - it('creates median split bins', () => { - selectMenuOption('label=Median split'); - clickUpdate(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(MUTATION_COUNT_CHART); + it('creates median split bins', async () => { + await selectMenuOption('label=Median split'); + await clickUpdate(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(MUTATION_COUNT_CHART); assertScreenShotMatch(res); }); - it('generates bins using min and bin size input fields', () => { - selectMenuOption('label=Generate bins'); - $(BIN_SIZE_INPUT).waitForExist(); - $(BIN_SIZE_INPUT).setValue('2'); - $(MIN_VALUE_INPUT).setValue('2'); - clickUpdate(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(MUTATION_COUNT_CHART); + it('generates bins using min and bin size input fields', async () => { + await selectMenuOption('label=Generate bins'); + await getElement(BIN_SIZE_INPUT, { + waitForExist: true, + }); + await setInputText(BIN_SIZE_INPUT, '2'); + await setInputText(MIN_VALUE_INPUT, '2'); + await clickUpdate(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(MUTATION_COUNT_CHART); assertScreenShotMatch(res); }); - it('creates custom bins using custom bins input field', () => { - selectMenuOption('label=Custom bins'); - $(CUSTOM_BINS_TEXTAREA).waitForExist(); - $(CUSTOM_BINS_TEXTAREA).setValue('0,10,20,30,40'); - clickUpdate(); - $('body').moveTo(); - const res = checkElementWithMouseDisabled(MUTATION_COUNT_CHART); + it('creates custom bins using custom bins input field', async () => { + await selectMenuOption('label=Custom bins'); + await getElement(CUSTOM_BINS_TEXTAREA, { + waitForExist: true, + }); + await dsetInputText(CUSTOM_BINS_TEXTAREA, '0,10,20,30,40'); + await clickUpdate(); + await (await getElement('body')).moveTo(); + const res = await checkElementWithMouseDisabled(MUTATION_COUNT_CHART); assertScreenShotMatch(res); }); }); -function openCustomBinsMenu() { - $(MUTATION_COUNT_CHART).waitForDisplayed(); - jsApiHover(MUTATION_COUNT_CHART); +async function openCustomBinsMenu() { + await waitForElementDisplayed(MUTATION_COUNT_CHART); + await jsApiHover(MUTATION_COUNT_CHART); - $(MUTATION_COUNT_HAMBURGER_ICON).waitForDisplayed(); - jsApiHover(MUTATION_COUNT_HAMBURGER_ICON); + await waitForElementDisplayed(MUTATION_COUNT_HAMBURGER_ICON); + await jsApiHover(MUTATION_COUNT_HAMBURGER_ICON); - $(MUTATION_COUNT_MENU).waitForDisplayed(); - $(MUTATION_COUNT_MENU) - .$('a.dropdown-item') - .click(); + await waitForElementDisplayed(MUTATION_COUNT_MENU); + await ( + await getNestedElement([MUTATION_COUNT_MENU, 'a.dropdown-item']) + ).click(); - $(CUSTOM_BINS_MENU).waitForDisplayed(); + await waitForElementDisplayed(CUSTOM_BINS_MENU); } -function selectMenuOption(identifier) { - $(CUSTOM_BINS_MENU) - .$(identifier) - .click(); +async function selectMenuOption(identifier) { + await (await getNestedElement([CUSTOM_BINS_MENU, identifier])).click(); } -function clickUpdate() { - $(CUSTOM_BINS_MENU) - .$(UPDATE_BUTTON) - .click(); +async function clickUpdate() { + await (await getNestedElement([CUSTOM_BINS_MENU, UPDATE_BUTTON])).click(); } diff --git a/end-to-end-test/local/specs/study-view-filters-autocommit-toggle.spec.js b/end-to-end-test/local/specs/study-view-filters-autocommit-toggle.spec.js index 28371edee32..0c213d26072 100644 --- a/end-to-end-test/local/specs/study-view-filters-autocommit-toggle.spec.js +++ b/end-to-end-test/local/specs/study-view-filters-autocommit-toggle.spec.js @@ -1,4 +1,10 @@ -const { goToUrlAndSetLocalStorage } = require('../../shared/specUtils'); +const { + goToUrlAndSetLocalStorage, + getNestedElement, + waitForElementDisplayed, + clickElement, + getElement, +} = require('../../shared/specUtils_Async'); const assert = require('assert'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -18,56 +24,71 @@ const PILL_TAG = 'div[data-test="pill-tag"]'; const DELETE_PILL_TAG = 'span[data-test="pill-tag-delete"]'; describe('Toggling of study view filters autosubmit', function() { - it('autocommits filters by default', () => { - goToUrlAndSetLocalStorage(studyViewUrl, true); + it('autocommits filters by default', async () => { + await goToUrlAndSetLocalStorage(studyViewUrl, true); //this seems to fix issue with intermittent fail of test due to //menu not being clickeable - browser.setWindowSize(1600, 1000); + await browser.setWindowSize(1600, 1000); - selectMutationProfile(0); - selectSamples(); + await selectMutationProfile(0); + await selectSamples(); - const filterInHeader = $(STUDY_VIEW_HEADER).$(PUTATIVE_PROFILE); - assert(filterInHeader.isDisplayed()); - const isFilterQueued = hasFilterClass(filterInHeader, 'pending'); + const filterInHeader = await getNestedElement([ + STUDY_VIEW_HEADER, + PUTATIVE_PROFILE, + ]); + assert(await filterInHeader.isDisplayed()); + const isFilterQueued = await hasFilterClass(filterInHeader, 'pending'); assert(!isFilterQueued); }); - it('can disable filter submission in settings menu', () => { - $(SETTINGS_MENU_BUTTON).waitForDisplayed({ timeout: 20000 }); - $(SETTINGS_MENU_BUTTON).click(); - $(DISABLE_AUTOCOMMIT_FIELD).waitForDisplayed({ timeout: 20000 }); - $(DISABLE_AUTOCOMMIT_FIELD).click(); + it('can disable filter submission in settings menu', async () => { + await waitForElementDisplayed(SETTINGS_MENU_BUTTON, { timeout: 20000 }); + await clickElement(SETTINGS_MENU_BUTTON); + await waitForElementDisplayed(DISABLE_AUTOCOMMIT_FIELD, { + timeout: 20000, + }); + await clickElement(DISABLE_AUTOCOMMIT_FIELD); }); - it('queues new filters when autosubmit disabled', () => { + it('queues new filters when autosubmit disabled', async () => { // no submit button - assert.equal($(SUBMIT_STUDY_FILTERS).isExisting(), false); + assert.equal( + await (await getElement(SUBMIT_STUDY_FILTERS)).isExisting(), + false + ); - selectMutationProfile(1); + await selectMutationProfile(1); - queueFilter(); + await queueFilter(); // now we see the submit button - $(SUBMIT_STUDY_FILTERS).waitForDisplayed(); - - const queuedFilterInHeader = $(STUDY_VIEW_HEADER).$(LOG2_PROFILE); - assert(queuedFilterInHeader.isDisplayed()); - const isFilterQueued = hasFilterClass(queuedFilterInHeader, 'pending'); + await waitForElementDisplayed(SUBMIT_STUDY_FILTERS); + + const queuedFilterInHeader = await getNestedElement([ + STUDY_VIEW_HEADER, + LOG2_PROFILE, + ]); + assert(await queuedFilterInHeader.isDisplayed()); + const isFilterQueued = await hasFilterClass( + queuedFilterInHeader, + 'pending' + ); assert(isFilterQueued); }); // - it('queues deleted filters when autosubmit disabled', () => { - const submittedFilterInHeader = $(STUDY_VIEW_HEADER).$( - PUTATIVE_PROFILE - ); - assert(submittedFilterInHeader.isDisplayed()); + it('queues deleted filters when autosubmit disabled', async () => { + const submittedFilterInHeader = await getNestedElement([ + STUDY_VIEW_HEADER, + PUTATIVE_PROFILE, + ]); + assert(await submittedFilterInHeader.isDisplayed()); - deleteFilter(submittedFilterInHeader); + await deleteFilter(submittedFilterInHeader); - assert(submittedFilterInHeader.isDisplayed()); - const isFilterQueued = hasFilterClass( + assert(await submittedFilterInHeader.isDisplayed()); + const isFilterQueued = await hasFilterClass( submittedFilterInHeader, 'pending' ); @@ -79,45 +100,60 @@ describe('Toggling of study view filters autosubmit', function() { assert(isFilterDeleted); }); // - it('submits queued and deleted filters when manually submitting', () => { - const queuedDeletedFilterInHeader = $(STUDY_VIEW_HEADER).$( - PUTATIVE_PROFILE + it('submits queued and deleted filters when manually submitting', async () => { + const queuedDeletedFilterInHeader = await getNestedElement([ + STUDY_VIEW_HEADER, + PUTATIVE_PROFILE, + ]); + assert(await queuedDeletedFilterInHeader.isDisplayed()); + const queuedFilterInHeader = await getNestedElement([ + STUDY_VIEW_HEADER, + LOG2_PROFILE, + ]); + assert(await queuedFilterInHeader.isDisplayed()); + + await clickElement(SUBMIT_STUDY_FILTERS); + + await browser.waitUntil( + async () => !(await queuedDeletedFilterInHeader.isDisplayed()) + ); + assert(await queuedFilterInHeader.isDisplayed()); + const isFilterQueued = await hasFilterClass( + queuedFilterInHeader, + 'pending' ); - assert(queuedDeletedFilterInHeader.isDisplayed()); - const queuedFilterInHeader = $(STUDY_VIEW_HEADER).$(LOG2_PROFILE); - assert(queuedFilterInHeader.isDisplayed()); - - $(SUBMIT_STUDY_FILTERS).click(); - - browser.waitUntil(() => !queuedDeletedFilterInHeader.isDisplayed()); - assert(queuedFilterInHeader.isDisplayed()); - const isFilterQueued = hasFilterClass(queuedFilterInHeader, 'pending'); assert(!isFilterQueued); }); }); -function selectMutationProfile(index = 0) { - $(GENOMIC_PROFILES_SAMPLE_COUNT_TABLE) - .$$('input') - [index].click(); +async function selectMutationProfile(index = 0) { + await ( + await getNestedElement([GENOMIC_PROFILES_SAMPLE_COUNT_TABLE, 'input']) + )[index].click(); } -function queueFilter() { - $(GENOMIC_PROFILES_SAMPLE_COUNT_TABLE) - .$(ADD_FILTERS_BUTTON) - .click(); +async function queueFilter() { + await ( + await getNestedElement([ + GENOMIC_PROFILES_SAMPLE_COUNT_TABLE, + ADD_FILTERS_BUTTON, + ]) + ).click(); } -function selectSamples() { - $(GENOMIC_PROFILES_SAMPLE_COUNT_TABLE) - .$(SELECT_SAMPLES_BUTTON) - .click(); +async function selectSamples() { + await ( + await getNestedElement([ + GENOMIC_PROFILES_SAMPLE_COUNT_TABLE, + SELECT_SAMPLES_BUTTON, + ]) + ).click(); } /** * Execute in browser to be able to use parentElement.closest() */ -function hasFilterClass(queuedFilterInHeader, toInclude) { +async function hasFilterClass(queuedFilterInHeader, toInclude) { return browser.execute( (queuedFilterInHeader, toInclude, PILL_TAG) => { return queuedFilterInHeader.parentElement @@ -131,8 +167,8 @@ function hasFilterClass(queuedFilterInHeader, toInclude) { ); } -function deleteFilter(queuedFilterInHeader) { - browser.execute( +async function deleteFilter(queuedFilterInHeader) { + await browser.execute( (queuedFilterInHeader, PILL_TAG, DELETE_PILL_TAG) => { return queuedFilterInHeader.parentElement .closest(PILL_TAG) diff --git a/end-to-end-test/local/specs/treatment.screenshot.spec.js b/end-to-end-test/local/specs/treatment.screenshot.spec.js index 529dc13adb6..47d3c483811 100644 --- a/end-to-end-test/local/specs/treatment.screenshot.spec.js +++ b/end-to-end-test/local/specs/treatment.screenshot.spec.js @@ -1,20 +1,22 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var assertScreenShotMatch = require('../../shared/lib/testUtils') - .assertScreenShotMatch; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var waitForPlotsTab = require('../../shared/specUtils').waitForPlotsTab; -var selectReactSelectOption = require('../../shared/specUtils') - .selectReactSelectOption; -var oncoprintTabUrl = require('./treatment.spec').oncoprintTabUrl; -var plotsTabUrl = require('./treatment.spec').plotsTabUrl; -var selectReactSelectOption = require('../../shared/specUtils') - .selectReactSelectOption; -var goToTreatmentTab = require('./treatment.spec').goToTreatmentTab; -var selectTreamentsBothAxes = require('./treatment.spec') - .selectTreamentsBothAxes; -var selectElementByText = require('../../shared/specUtils').selectElementByText; +const assert = require('assert'); +const { assertScreenShotMatch } = require('../../shared/lib/testUtils'); +const { + goToUrlAndSetLocalStorage, + waitForOncoprint, + waitForPlotsTab, + selectReactSelectOption, + selectElementByText, + clickElement, + setInputText, + getNestedElement, + getElement, +} = require('../../shared/specUtils_Async'); +const { + oncoprintTabUrl, + plotsTabUrl, + goToTreatmentTab, + selectTreamentsBothAxes, +} = require('./treatment.spec'); const TREATMENT_EC50_PROFILE_NAME = 'EC50 values of compounds on cellular phenotype readout'; @@ -25,173 +27,219 @@ const GENERIC_ASSAY_PROFILE_SELECTOR = describe('treatment feature', () => { describe('oncoprint tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); }); - it('shows treatment profile heatmap track for treatment', () => { - goToTreatmentTab(); + it('shows treatment profile heatmap track for treatment', async () => { + await goToTreatmentTab(); // change profile to EC50 - $(GENERIC_ASSAY_PROFILE_SELECTOR).click(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).waitForExist(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).click(); - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - $('[data-test="GenericAssayEntitySelection"] input').setValue( + await clickElement(GENERIC_ASSAY_PROFILE_SELECTOR); + await selectElementByText(TREATMENT_EC50_PROFILE_NAME, { + waitForExist: true, + }); + await ( + await selectElementByText(TREATMENT_EC50_PROFILE_NAME) + ).click(); + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + await setInputText( + '[data-test="GenericAssayEntitySelection"] input', '17-AAG' ); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); - options[0].click(); - var indicators = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="indicatorContainer"]' - ); + const options = await getNestedElement([ + GENERIC_ASSAY_ENTITY_SELECTOR, + 'div[class$="option"]', + ]); + await options[0].click(); + const indicators = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="indicatorContainer"]'); // close the dropdown - indicators[0].click(); - var selectedOptions = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="multiValue"]' - ); + await indicators[0].click(); + const selectedOptions = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="multiValue"]'); + assert.equal(selectedOptions.length, 1); - $('button=Add Track').click(); + await clickElement('button=Add Track'); // close add tracks menu - var addTracksButton = $('button[id=addTracksDropdown]'); - addTracksButton.click(); - waitForOncoprint(); - var res = browser.checkElement('[id=oncoprintDiv]'); + await clickElement('button[id=addTracksDropdown]'); + await waitForOncoprint(); + const res = await browser.checkElement('[id=oncoprintDiv]'); assertScreenShotMatch(res); }); }); describe('plots tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(plotsTabUrl, true); - waitForPlotsTab(); - selectTreamentsBothAxes(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(plotsTabUrl, true); + await waitForPlotsTab(); + await selectTreamentsBothAxes(); }); - it('shows `value larger_than_8.00` in figure legend and indicates sub-threshold data points in plot', () => { - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + it('shows `value larger_than_8.00` in figure legend and indicates sub-threshold data points in plot', async () => { + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); - browser.execute(() => { + await browser.execute(() => { $('div').css({ border: '1px solid red !important' }); }); assertScreenShotMatch(res); }); - it('when option deselected, hides `value larger_than_8.00` in figure legend and sub-threshold data points in plot', () => { - $('[data-test=ViewLimitValues]').waitForExist({ timeout: 10000 }); - $('[data-test=ViewLimitValues]').click(); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + it('when option deselected, hides `value larger_than_8.00` in figure legend and sub-threshold data points in plot', async () => { + await getElement('[data-test=ViewLimitValues]', { timeout: 10000 }); + await clickElement('[data-test=ViewLimitValues]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('shows waterfall plot when `Ordered samples` option is selected', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('shows waterfall plot when `Ordered samples` option is selected', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist({ timeout: 10000 }); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { timeout: 10000 }); + await clickElement('[data-test=ViewCopyNumber]'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('when option deselected, hides `value larger_than_8.00` in figure legend and sub-threshold data point indicators in waterfall plot', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('when option deselected, hides `value larger_than_8.00` in figure legend and sub-threshold data point indicators in waterfall plot', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - $('[data-test=ViewLimitValues]').click(); + await clickElement('[data-test=ViewLimitValues]'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('rotates waterfall plot when swapping axes', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('rotates waterfall plot when swapping axes', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - $('[data-test=swapHorzVertButton]').click(); + await clickElement('[data-test=swapHorzVertButton]'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('updates title of watefall plot when selecting a new gene', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('updates title of watefall plot when selecting a new gene', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - $('.gene-select').click(); + await clickElement('.gene-select'); // select gene menu entries - var geneMenuEntries = $('[data-test=GeneColoringMenu]') - .$('div=Genes') - .$('..') - .$$('div')[1] - .$$('div'); - geneMenuEntries[3].click(); - - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const geneMenuEntries = await ( + await ( + await getNestedElement([ + '[data-test=GeneColoringMenu]', + 'div=Genes', + '..', + ]) + ).$$('div')[1] + ).$$('div'); + + await geneMenuEntries[3].click(); + + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('applies log-scale in waterfall plot', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('applies log-scale in waterfall plot', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - $('[data-test=VerticalLogCheckbox]').click(); + await clickElement('[data-test=VerticalLogCheckbox]'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('reverses order of waterfall plot data when `Sort order` button pressed', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('reverses order of waterfall plot data when `Sort order` button pressed', async () => { + const horzDataSelect = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - $('[data-test=changeSortOrderButton]').click(); + await clickElement('[data-test=changeSortOrderButton]'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); - it('shows a search indicator when sample search term is entered', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Ordered samples'); + it('shows a search indicator when sample search term is entered', async () => { + const horzDataSelect = await getElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Ordered samples'); // make sure bars become visible (no mut data is available) - $('[data-test=ViewCopyNumber]').waitForExist(); - $('[data-test=ViewCopyNumber]').click(); + await getElement('[data-test=ViewCopyNumber]', { + waitForExist: true, + }); + await clickElement('[data-test=ViewCopyNumber]'); - var sampleSearch = $('label=Search Case(s)') - .$('..') - .$('input'); - sampleSearch.setValue('TCGA-A2-A04U-01 TCGA-A1-A0SE-01'); + const sampleSearch = await getNestedElement([ + 'label=Search Case(s)', + '..', + 'input', + ]); + await sampleSearch.setValue('TCGA-A2-A04U-01 TCGA-A1-A0SE-01'); - var res = browser.checkElement('[id=plots-tab-plot-svg]'); + const res = await browser.checkElement('[id=plots-tab-plot-svg]'); assertScreenShotMatch(res); }); }); diff --git a/end-to-end-test/local/specs/treatment.spec.js b/end-to-end-test/local/specs/treatment.spec.js index 154c9d90ca6..d21d5f1fbc1 100644 --- a/end-to-end-test/local/specs/treatment.spec.js +++ b/end-to-end-test/local/specs/treatment.spec.js @@ -1,13 +1,16 @@ -var assert = require('assert'); -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var waitForOncoprint = require('../../shared/specUtils').waitForOncoprint; -var waitForPlotsTab = require('../../shared/specUtils').waitForPlotsTab; -var reactSelectOption = require('../../shared/specUtils').reactSelectOption; -var selectReactSelectOption = require('../../shared/specUtils') - .selectReactSelectOption; -var selectElementByText = require('../../shared/specUtils').selectElementByText; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + waitForOncoprint, + waitForPlotsTab, + reactSelectOption, + selectReactSelectOption, + selectElementByText, + clickElement, + getElement, + setInputText, + getNestedElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const oncoprintTabUrl = @@ -31,240 +34,298 @@ describe('treatment feature', function() { //this.retries(2); describe('oncoprint tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(oncoprintTabUrl, true); - waitForOncoprint(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(oncoprintTabUrl, true); + await waitForOncoprint(); }); - it('shows treatment data type option in heatmap menu', () => { - goToTreatmentTab(); + it('shows treatment data type option in heatmap menu', async () => { + await goToTreatmentTab(); // open treatment profile selection menu - $(GENERIC_ASSAY_PROFILE_SELECTOR).click(); - selectElementByText(TREATMENT_IC50_PROFILE_NAME).waitForExist(); - assert($(`//*[text()="${TREATMENT_IC50_PROFILE_NAME}"]`)); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).waitForExist(); - assert($(`//*[text()="${TREATMENT_EC50_PROFILE_NAME}"]`)); + await clickElement(GENERIC_ASSAY_PROFILE_SELECTOR); + await ( + await selectElementByText(TREATMENT_IC50_PROFILE_NAME) + ).waitForExist(); + assert( + await getElement(`//*[text()="${TREATMENT_IC50_PROFILE_NAME}"]`) + ); + await ( + await selectElementByText(TREATMENT_EC50_PROFILE_NAME) + ).waitForExist(); + assert( + await getElement(`//*[text()="${TREATMENT_EC50_PROFILE_NAME}"]`) + ); }); - it('shows treatment selection box in heatmap menu when treatment data type is selected', () => { - goToTreatmentTab(); + it('shows treatment selection box in heatmap menu when treatment data type is selected', async () => { + await goToTreatmentTab(); // change profile to IC50 - $(GENERIC_ASSAY_PROFILE_SELECTOR).click(); - selectElementByText(TREATMENT_IC50_PROFILE_NAME).waitForExist(); - selectElementByText(TREATMENT_IC50_PROFILE_NAME).click(); - assert($(`//*[text()="${TREATMENT_IC50_PROFILE_NAME}"]`)); + await clickElement(GENERIC_ASSAY_PROFILE_SELECTOR); + await ( + await selectElementByText(TREATMENT_IC50_PROFILE_NAME) + ).waitForExist(); + await ( + await selectElementByText(TREATMENT_IC50_PROFILE_NAME) + ).click(); + assert( + await getElement(`//*[text()="${TREATMENT_IC50_PROFILE_NAME}"]`) + ); // change profile to EC50 - $(GENERIC_ASSAY_PROFILE_SELECTOR).click(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).waitForExist(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).click(); - assert($(`//*[text()="${TREATMENT_EC50_PROFILE_NAME}"]`)); + await clickElement(GENERIC_ASSAY_PROFILE_SELECTOR); + await ( + await selectElementByText(TREATMENT_EC50_PROFILE_NAME) + ).waitForExist(); + await ( + await selectElementByText(TREATMENT_EC50_PROFILE_NAME) + ).click(); + assert( + await getElement(`//*[text()="${TREATMENT_EC50_PROFILE_NAME}"]`) + ); }); - it('shows all treatments in generic assay selector', () => { - goToTreatmentTab(); + it('shows all treatments in generic assay selector', async () => { + await goToTreatmentTab(); // open entity dropdown menu - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); assert.equal(options.length, 10); }); - it('select one treatment in generic assay selector', () => { - goToTreatmentTab(); - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - $('[data-test="GenericAssayEntitySelection"] input').setValue( + it('select one treatment in generic assay selector', async () => { + await goToTreatmentTab(); + clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + await setInputText( + '[data-test="GenericAssayEntitySelection"] input', '17-AAG' ); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); - options[1].click(); - $(GENERIC_ASSAY_ENTITY_SELECTOR) - .$('div[class$="multiValue"]') - .waitForExist(); - var selectedOptions = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="multiValue"]' - ); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); + await options[1].click(); + await ( + await getNestedElement([ + GENERIC_ASSAY_ENTITY_SELECTOR, + 'div[class$="multiValue"]', + ]) + ).waitForExist(); + const selectedOptions = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="multiValue"]'); assert.equal(selectedOptions.length, 1); }); - it('show multiple filtered treatments', () => { - goToTreatmentTab(); - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - $('[data-test="GenericAssayEntitySelection"] input').setValue( + it('show multiple filtered treatments', async () => { + await goToTreatmentTab(); + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + setInputText( + '[data-test="GenericAssayEntitySelection"] input', 'AZD' ); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); assert.equal(options.length, 3); }); - it('select multiple filtered treatments in generic assay selector', () => { - goToTreatmentTab(); - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - $('[data-test="GenericAssayEntitySelection"] input').setValue( + it('select multiple filtered treatments in generic assay selector', async () => { + await goToTreatmentTab(); + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + await setInputText( + '[data-test="GenericAssayEntitySelection"] input', 'AZD' ); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); - options[0].click(); - $('div[class$="multiValue"]').waitForExist(); - var selectedOptions = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="multiValue"]' - ); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); + await options[0].click(); + await (await getElement('div[class$="multiValue"]')).waitForExist(); + const selectedOptions = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="multiValue"]'); assert.equal(selectedOptions.length, 2); }); - it('keeps the filtered treatments list open after selecting an option', () => { - goToTreatmentTab(); - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); + it('keeps the filtered treatments list open after selecting an option', async () => { + await goToTreatmentTab(); + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); assert.equal(options.length, 10); - options[0].click(); - options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); + await options[0].click(); + options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); assert.equal(options.length, 9); }); - it('initializes from `generic_assay_groups` URL parameter', () => { - goToUrlAndSetLocalStorage( + it('initializes from `generic_assay_groups` URL parameter', async () => { + await goToUrlAndSetLocalStorage( oncoprintTabUrl.concat( '&generic_assay_groups=study_es_0_treatment_ic50,17-AAG' ), true ); - waitForOncoprint(); - goToTreatmentTab(); - $(GENERIC_ASSAY_ENTITY_SELECTOR) - .$('div[class$="multiValue"]') - .waitForExist(); - var selectedOptions = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="multiValue"]' - ); + await waitForOncoprint(); + await goToTreatmentTab(); + await ( + await getNestedElement([ + GENERIC_ASSAY_ENTITY_SELECTOR, + 'div[class$="multiValue"]', + ]) + ).waitForExist(); + const selectedOptions = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="multiValue"]'); assert.equal(selectedOptions.length, 1); assert.equal( - selectedOptions[0].getText(), + await selectedOptions[0].getText(), 'Name of 17-AAG (17-AAG): Desc of 17-AAG' ); }); - it('sets `generic_assay_groups` URL parameter', () => { - goToTreatmentTab(); + it('sets `generic_assay_groups` URL parameter', async () => { + await goToTreatmentTab(); // Select treatment profile - $(GENERIC_ASSAY_PROFILE_SELECTOR).click(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).waitForExist(); - selectElementByText(TREATMENT_EC50_PROFILE_NAME).click(); + await clickElement(GENERIC_ASSAY_PROFILE_SELECTOR); + await ( + await selectElementByText(TREATMENT_EC50_PROFILE_NAME) + ).waitForExist(); + await selectElementByText(TREATMENT_EC50_PROFILE_NAME); // Select treatments - $(GENERIC_ASSAY_ENTITY_SELECTOR).click(); - $('[data-test="GenericAssayEntitySelection"] input').setValue( + await clickElement(GENERIC_ASSAY_ENTITY_SELECTOR); + await setInputText( + '[data-test="GenericAssayEntitySelection"] input', '17-AAG' ); - var options = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="option"]' - ); - options[0].click(); - var indicators = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="indicatorContainer"]' - ); + const options = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="option"]'); + await options[0].click(); + const indicators = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="indicatorContainer"]'); // close the dropdown - indicators[0].click(); - var selectedOptions = $(GENERIC_ASSAY_ENTITY_SELECTOR).$$( - 'div[class$="multiValue"]' - ); + await indicators[0].click(); + const selectedOptions = await ( + await getElement(GENERIC_ASSAY_ENTITY_SELECTOR) + ).$$('div[class$="multiValue"]'); assert.equal(selectedOptions.length, 1); - $('button=Add Track').click(); - waitForOncoprint(); - var url = browser.getUrl(); + await clickElement('button=Add Track'); + await waitForOncoprint(); + const url = await browser.getUrl(); - var regex = /generic_assay_groups=study_es_0_treatment_ec50%2C17-AAG/; + const regex = /generic_assay_groups=study_es_0_treatment_ec50%2C17-AAG/; assert(url.match(regex)); }); }); describe('plots tab', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(plotsTabUrl, true); - waitForPlotsTab(); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(plotsTabUrl, true); + await waitForPlotsTab(); }); - it('shows treatment option in horizontal data type selection box', () => { - var select = $('[name=h-profile-type-selector]').$('..'); - assert(reactSelectOption(select, 'Treatment Response')); + it('shows treatment option in horizontal data type selection box', async () => { + const select = await getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + assert(await reactSelectOption(select, 'Treatment Response')); }); - it('shows treatment option in vertical data type selection box', () => { - var select = $('[name=v-profile-type-selector]').$('..'); - assert(reactSelectOption(select, 'Treatment Response')); + it('shows treatment option in vertical data type selection box', async () => { + const select = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + ]); + assert(await reactSelectOption(select, 'Treatment Response')); }); - it('horizontal axis menu shows treatments in profile menu', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Treatment Response'); - - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); + it('horizontal axis menu shows treatments in profile menu', async () => { + const horzDataSelect = getNestedElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Treatment Response'); + + const horzProfileSelect = await getNestedElement([ + '[name=h-profile-name-selector]', + '..', + ]); assert( - reactSelectOption( + await reactSelectOption( horzProfileSelect, 'EC50 values of compounds on cellular phenotype readout' ) ); assert( - reactSelectOption( + await reactSelectOption( horzProfileSelect, 'IC50 values of compounds on cellular phenotype readout' ) ); }); - it('vertical axis menu shows treatments in profile menu', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - selectReactSelectOption(vertDataSelect, 'Treatment Response'); - - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); + it('vertical axis menu shows treatments in profile menu', async () => { + const vertDataSelect = await getNestedElement([ + '[name=v-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(vertDataSelect, 'Treatment Response'); + + const vertProfileSelect = await getNestedElement([ + '[name=v-profile-name-selector]', + '..', + ]); assert( - reactSelectOption( + await reactSelectOption( vertProfileSelect, 'EC50 values of compounds on cellular phenotype readout' ) ); assert( - reactSelectOption( + await reactSelectOption( vertProfileSelect, 'IC50 values of compounds on cellular phenotype readout' ) ); }); - it('horizontal axis menu shows treatment entry in entity menu', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); - selectReactSelectOption(horzDataSelect, 'Treatment Response'); - - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); - selectReactSelectOption( + it('horizontal axis menu shows treatment entry in entity menu', async () => { + const horzDataSelect = await getElement([ + '[name=h-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(horzDataSelect, 'Treatment Response'); + + const horzProfileSelect = await getNestedElement([ + '[name=h-profile-name-selector]', + '..', + ]); + await selectReactSelectOption( horzProfileSelect, 'IC50 values of compounds on cellular phenotype readout' ); - $('[data-test=generic-assay-info-icon]').waitForExist(); + await getElement('[data-test=generic-assay-info-icon]', { + waitForExist: true, + }); // NOT SUPER CLEAR WHY THESE ARE NECESSARY - browser.execute(function() { + await browser.execute(function() { resultsViewPlotsTab.onHorizontalAxisGenericAssaySelect({ value: '17-AAG', label: 'Name of 17-AAG', }); }); - browser.execute(function() { + await browser.execute(function() { resultsViewPlotsTab.onHorizontalAxisGenericAssaySelect({ value: 'AEW541', label: 'Name of AEW541', @@ -272,17 +333,25 @@ describe('treatment feature', function() { }); }); - it('vertical axis menu shows treatment entry in entity menu', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); - selectReactSelectOption(vertDataSelect, 'Treatment Response'); - - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); - selectReactSelectOption( + it('vertical axis menu shows treatment entry in entity menu', async () => { + const vertDataSelect = await getElement([ + '[name=v-profile-type-selector]', + '..', + ]); + await selectReactSelectOption(vertDataSelect, 'Treatment Response'); + + const vertProfileSelect = await getNestedElement([ + '[name=v-profile-name-selector]', + '..', + ]); + await selectReactSelectOption( vertProfileSelect, 'IC50 values of compounds on cellular phenotype readout' ); - $('[data-test=generic-assay-info-icon]').waitForExist(); + await getElement('[data-test=generic-assay-info-icon]', { + waitForExist: true, + }); // browser.execute(function() { // resultsViewPlotsTab.onVerticalAxisGenericAssaySelect({ @@ -300,11 +369,13 @@ describe('treatment feature', function() { // }) }); - it('has Ordered samples entry in vert. menu when treatment selected on horz. axis', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); + it('has Ordered samples entry in vert. menu when treatment selected on horz. axis', async () => { + const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); selectReactSelectOption(vertDataSelect, 'Treatment Response'); - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); + const vertProfileSelect = $('[name=v-profile-name-selector]').$( + '..' + ); selectReactSelectOption( vertProfileSelect, 'IC50 values of compounds on cellular phenotype readout' @@ -319,15 +390,17 @@ describe('treatment feature', function() { }); }); - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); assert(reactSelectOption(horzDataSelect, 'Ordered samples')); }); - it('has `Ordered samples` entry in horz. menu when treatment selected on vert. axis', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + it('has `Ordered samples` entry in horz. menu when treatment selected on vert. axis', async () => { + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Treatment Response'); - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); + const horzProfileSelect = $('[name=h-profile-name-selector]').$( + '..' + ); selectReactSelectOption( horzProfileSelect, 'IC50 values of compounds on cellular phenotype readout' @@ -342,27 +415,29 @@ describe('treatment feature', function() { }); }); - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); + const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); assert(reactSelectOption(vertDataSelect, 'Ordered samples')); }); - it('shows `Log Scale` checkbox when treatment selected on vert. axis', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + it('shows `Log Scale` checkbox when treatment selected on vert. axis', async () => { + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Treatment Response'); assert($('[data-test=HorizontalLogCheckbox]')); }); - it('shows `Log Scale` checkbox when treatment selected on horz. axis', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); + it('shows `Log Scale` checkbox when treatment selected on horz. axis', async () => { + const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); selectReactSelectOption(vertDataSelect, 'Treatment Response'); assert($('[data-test=VerticalLogCheckbox]')); }); - it('shows checkbox for limit values (e.g., larger_than_8.00) checkbox when such profile selected on horz. axis', () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + it('shows checkbox for limit values (e.g., larger_than_8.00) checkbox when such profile selected on horz. axis', async () => { + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Treatment Response'); - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); + const horzProfileSelect = $('[name=h-profile-name-selector]').$( + '..' + ); selectReactSelectOption( horzProfileSelect, 'EC50 values of compounds on cellular phenotype readout' @@ -385,11 +460,13 @@ describe('treatment feature', function() { assert($('[data-test=ViewLimitValues]').isDisplayed()); }); - it('shows checkbox for limit values (e.g., larger_than_8.00) checkbox when such profile selected on vert. axis', () => { - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); + it('shows checkbox for limit values (e.g., larger_than_8.00) checkbox when such profile selected on vert. axis', async () => { + const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); selectReactSelectOption(vertDataSelect, 'Treatment Response'); - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); + const vertProfileSelect = $('[name=v-profile-name-selector]').$( + '..' + ); selectReactSelectOption( vertProfileSelect, 'EC50 values of compounds on cellular phenotype readout' @@ -409,28 +486,28 @@ describe('treatment feature', function() { assert($('[data-test=ViewLimitValues]').isDisplayed()); }); - it('shows hint for handling of threshold values for treatment data in scatter plot', () => { + it('shows hint for handling of threshold values for treatment data in scatter plot', async () => { assert($('label=Value >8.00 Labels **')); assert($('div*=** ')); }); - it('shows gene selection box in utilities menu for waterfall plot', () => { + it('shows gene selection box in utilities menu for waterfall plot', async () => { selectTreamentsBothAxes(); - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Ordered samples'); assert($('.gene-select-container')); assert($('.gene-select-container')); }); - it('shows selected genes in gene selection box in utilities menu for waterfall plot', () => { + it('shows selected genes in gene selection box in utilities menu for waterfall plot', async () => { selectTreamentsBothAxes(); - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Ordered samples'); $('.gene-select-container').waitForExist(); - var geneSelect = $('.gene-select-container'); + const geneSelect = $('.gene-select-container'); geneSelect.click(); $('[data-test=GeneColoringMenu]') @@ -438,7 +515,7 @@ describe('treatment feature', function() { .waitForDisplayed(); // select gene menu entries - var geneMenuEntries = $('[data-test=GeneColoringMenu]') + const geneMenuEntries = $('[data-test=GeneColoringMenu]') .$('div=Genes') .$('..') .$$('div')[1] @@ -450,36 +527,35 @@ describe('treatment feature', function() { assert.strictEqual(geneMenuEntries[3].getText(), 'TP53'); }); - it('shows sort order button for waterfall plot when `Ordered samples` selected', () => { + it('shows sort order button for waterfall plot when `Ordered samples` selected', async () => { selectTreamentsBothAxes(); - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Ordered samples'); assert($('[data-test=changeSortOrderButton')); }); }); }); -var goToTreatmentTab = () => { - var addTracksButton = $('button[id=addTracksDropdown]'); - addTracksButton.click(); - - var addTracksMenu = $(ADD_TRACKS_TREATMENT_TAB); - addTracksMenu.waitForExist(); - $(ADD_TRACKS_TREATMENT_TAB).click(); +const goToTreatmentTab = async () => { + await clickElement('button[id=addTracksDropdown]'); + await getElement(ADD_TRACKS_TREATMENT_TAB, { + waitForExist: true, + }); + await clickElement(ADD_TRACKS_TREATMENT_TAB); }; -var selectTreamentsBothAxes = () => { - var horzDataSelect = $('[name=h-profile-type-selector]').$('..'); +const selectTreamentsBothAxes = () => { + const horzDataSelect = $('[name=h-profile-type-selector]').$('..'); selectReactSelectOption(horzDataSelect, 'Treatment Response'); - var horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); + const horzProfileSelect = $('[name=h-profile-name-selector]').$('..'); selectReactSelectOption( horzProfileSelect, 'IC50 values of compounds on cellular phenotype readout' ); - var vertDataSelect = $('[name=v-profile-type-selector]').$('..'); + const vertDataSelect = $('[name=v-profile-type-selector]').$('..'); selectReactSelectOption(vertDataSelect, 'Treatment Response'); - var vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); + const vertProfileSelect = $('[name=v-profile-name-selector]').$('..'); selectReactSelectOption( vertProfileSelect, 'IC50 values of compounds on cellular phenotype readout' diff --git a/end-to-end-test/local/specs/user-display-name.spec.js b/end-to-end-test/local/specs/user-display-name.spec.js index 65ebb3cf0ed..8f4740bc065 100644 --- a/end-to-end-test/local/specs/user-display-name.spec.js +++ b/end-to-end-test/local/specs/user-display-name.spec.js @@ -1,27 +1,37 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorageWithProperty = require('../../shared/specUtils') - .goToUrlAndSetLocalStorageWithProperty; -var useExternalFrontend = require('../../shared/specUtils').useExternalFrontend; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorageWithProperty, + getText, + getElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('displays appropriate user name/email', function() { - it('shows email in the logged-in button with new value defined', function() { - userEmailAddress = 'other@email.com'; - goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { + it('shows email in the logged-in button with new value defined', async function() { + const userEmailAddress = 'other@email.com'; + await goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { user_display_name: userEmailAddress, }); assert.equal( - $('#dat-dropdown.btn-sm.dropdown-toggle.btn.btn-default').getText(), + await getText( + '#dat-dropdown.btn-sm.dropdown-toggle.btn.btn-default' + ), 'Logged in as ' + userEmailAddress + ' ' ); }); - it('does not display login button if no value defined', function() { - goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { + it('does not display login button if no value defined', async function() { + await goToUrlAndSetLocalStorageWithProperty(CBIOPORTAL_URL, true, { user_display_name: null, }); - $('#rightHeaderContent').waitForExist(); - !$('#dat-dropdown.btn-sm.dropdown-toggle.btn.btn-default').isExisting(); + await getElement('#rightHeaderContent', { + waitForExist: true, + }); + !(await ( + await getElement( + '#dat-dropdown.btn-sm.dropdown-toggle.btn.btn-default' + ) + ).isExisting()); }); }); diff --git a/end-to-end-test/local/specs/virtual-study.spec.js b/end-to-end-test/local/specs/virtual-study.spec.js index d3d873180bb..5dffe761614 100644 --- a/end-to-end-test/local/specs/virtual-study.spec.js +++ b/end-to-end-test/local/specs/virtual-study.spec.js @@ -1,6 +1,8 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../shared/specUtils') - .goToUrlAndSetLocalStorage; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + getElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const studyEs0Summary = CBIOPORTAL_URL + '/study/summary?id=study_es_0'; @@ -11,29 +13,29 @@ describe('Virtual Study life cycle', function() { let vsId; const X_PUBLISHER_API_KEY = 'SECRETKEY'; - it('Login and navigate to the study_es_0 study summary page', function() { - goToUrlAndSetLocalStorage(studyEs0Summary, true); + it('Login and navigate to the study_es_0 study summary page', async function() { + await goToUrlAndSetLocalStorage(studyEs0Summary, true); }); - it('Click Share Virtual Study button', function() { - const studyView = $('.studyView'); - const shareVSBtn = studyView.$( + it('Click Share Virtual Study button', async function() { + const studyView = await getElement('.studyView'); + const shareVSBtn = await studyView.$( 'button[data-tour="action-button-bookmark"]' ); - shareVSBtn.waitForClickable(); - shareVSBtn.click(); + await shareVSBtn.waitForClickable(); + await shareVSBtn.click(); }); - it('Provide the title and save', function() { - const modalDialog = $('.modal-dialog'); - modalDialog.waitForDisplayed(); - const titleInput = modalDialog.$('input#sniglet'); - titleInput.setValue(vsTitle); - const saveBtn = modalDialog.$( + it('Provide the title and save', async function() { + const modalDialog = await getElement('.modal-dialog'); + await modalDialog.waitForDisplayed(); + const titleInput = await modalDialog.$('input#sniglet'); + await titleInput.setValue(vsTitle); + const saveBtn = await modalDialog.$( '[data-tour="virtual-study-summary-save-btn"]' ); - saveBtn.click(); - modalDialog.$('.text-success').waitForDisplayed(); - const linkInput = modalDialog.$('input[type="text"]'); - link = linkInput.getValue(); + await saveBtn.click(); + await modalDialog.$('.text-success').waitForDisplayed(); + const linkInput = await modalDialog.$('input[type="text"]'); + const link = await linkInput.getValue(); assert.ok( link.startsWith('http'), 'The value should be link, but was ' + link @@ -45,20 +47,22 @@ describe('Virtual Study life cycle', function() { .find(([key, value]) => key === 'id')[1]; assert.ok(vsId, 'Virtual Study ID has not to be empty'); }); - it('See the VS in My Virtual Studies section on the landing page', function() { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - const vsSection = $(`//*[text()="${vsTitle}"]/ancestor::ul[1]`); - vsSection.waitForDisplayed(); - const sectionTitle = vsSection.$('li label span'); - assert.equal(sectionTitle.getText(), 'My Virtual Studies'); + it('See the VS in My Virtual Studies section on the landing page', async function() { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + const vsSection = await getElement( + `//*[text()="${vsTitle}"]/ancestor::ul[1]` + ); + await vsSection.waitForDisplayed(); + const sectionTitle = await vsSection.$('li label span'); + assert.equal(await sectionTitle.getText(), 'My Virtual Studies'); }); - it('Publish the VS', function() { - const result = browser.executeAsync( - function(cbioUrl, vsId, key, done) { + it('Publish the VS', async function() { + const result = await browser.executeAsync( + async function(cbioUrl, vsId, key, done) { const url = cbioUrl + '/api/public_virtual_studies/' + vsId; const headers = new Headers(); headers.append('X-PUBLISHER-API-KEY', key); - fetch(url, { + await fetch(url, { method: 'POST', headers: headers, }) @@ -78,19 +82,21 @@ describe('Virtual Study life cycle', function() { ); assert.ok(result.success, result.message); }); - it('See the VS in Public Virtual Studies section on the landing page', function() { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - const vsSection = $(`//*[text()="${vsTitle}"]/ancestor::ul[1]`); - vsSection.waitForDisplayed(); - const sectionTitle = vsSection.$('li label span'); - assert.equal(sectionTitle.getText(), 'Public Virtual Studies'); + it('See the VS in Public Virtual Studies section on the landing page', async function() { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + const vsSection = await getElement( + `//*[text()="${vsTitle}"]/ancestor::ul[1]` + ); + await vsSection.waitForDisplayed(); + const sectionTitle = await vsSection.$('li label span'); + assert.equal(await sectionTitle.getText(), 'Public Virtual Studies'); }); - it('Re-publish the VS specifying PubMed ID and type of cancer', function() { - const result = browser.executeAsync( - function(cbioUrl, vsId, key, done) { + it('Re-publish the VS specifying PubMed ID and type of cancer', async function() { + const result = await browser.executeAsync( + async function(cbioUrl, vsId, key, done) { const headers = new Headers(); headers.append('X-PUBLISHER-API-KEY', key); - fetch( + await fetch( cbioUrl + '/api/public_virtual_studies/' + vsId + @@ -116,22 +122,24 @@ describe('Virtual Study life cycle', function() { ); assert.ok(result.success, result.message); }); - it('See the VS in the Adrenocortical Adenoma section with PubMed link', function() { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - const vsRow = $(`//*[text()="${vsTitle}"]/ancestor::li[1]`); - const vsSection = vsRow.parentElement(); - vsSection.waitForDisplayed(); - const sectionTitle = vsSection.$('li label span'); - assert.equal(sectionTitle.getText(), 'Adrenocortical Adenoma'); + it('See the VS in the Adrenocortical Adenoma section with PubMed link', async function() { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + const vsRow = await getElement( + `//*[text()="${vsTitle}"]/ancestor::li[1]` + ); + const vsSection = await vsRow.parentElement(); + await vsSection.waitForDisplayed(); + const sectionTitle = await vsSection.$('li label span'); + assert.equal(await sectionTitle.getText(), 'Adrenocortical Adenoma'); //has PubMed link - assert.ok(vsRow.$('.fa-book').isExisting()); + assert.ok(await vsRow.$('.fa-book').isExisting()); }); - it('Un-publish the VS', function() { - const result = browser.executeAsync( - function(cbioUrl, vsId, key, done) { + it('Un-publish the VS', async function() { + const result = await browser.executeAsync( + async function(cbioUrl, vsId, key, done) { const headers = new Headers(); headers.append('X-PUBLISHER-API-KEY', key); - fetch(cbioUrl + '/api/public_virtual_studies/' + vsId, { + await fetch(cbioUrl + '/api/public_virtual_studies/' + vsId, { method: 'DELETE', headers: headers, }) @@ -152,20 +160,24 @@ describe('Virtual Study life cycle', function() { assert.ok(result.success, result.message); }); - it('Removing the VS', function() { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - const vsRow = $(`//*[text()="${vsTitle}"]/ancestor::li[1]`); - vsRow.waitForDisplayed(); + it('Removing the VS', async function() { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + const vsRow = await getElement( + `//*[text()="${vsTitle}"]/ancestor::li[1]` + ); + await vsRow.waitForDisplayed(); - const removeBtn = vsRow.$('.fa-trash'); - removeBtn.click(); + const removeBtn = await vsRow.$('.fa-trash'); + await removeBtn.click(); }); - it('The VS disappears from the landing page', function() { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); - $('[data-test="cancerTypeListContainer"]').waitForDisplayed(); - const vsRowTitle = $(`//*[text()="${vsTitle}"]`); - browser.pause(100); - assert.ok(!vsRowTitle.isExisting()); + it('The VS disappears from the landing page', async function() { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + await ( + await getElement('[data-test="cancerTypeListContainer"]') + ).waitForDisplayed(); + const vsRowTitle = await getElement(`//*[text()="${vsTitle}"]`); + await browser.pause(100); + assert.ok(!(await vsRowTitle.isExisting())); }); }); diff --git a/end-to-end-test/local/specs/web-tour.spec.js b/end-to-end-test/local/specs/web-tour.spec.js index 03b42f3abf9..5039130e899 100644 --- a/end-to-end-test/local/specs/web-tour.spec.js +++ b/end-to-end-test/local/specs/web-tour.spec.js @@ -1,5 +1,11 @@ const { goToUrlAndSetLocalStorage } = require('../../shared/specUtils'); const assert = require('assert'); +const { + getElement, + waitForElementDisplayed, + clickElement, + getNestedElement, +} = require('../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const VIRTUAL_STUDY_TOUR_MODAL = '.virtual-study-tour-modal'; @@ -16,90 +22,106 @@ const LAST_STEP_BTN = '.finish-step-btn'; describe('Virtual Study Tour', () => { let step = -1; - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); }); it('Initial step with -1.', () => { assert.equal(step, -1); }); - it('Click the entry to start tour.', () => { + it('Click the entry to start tour.', async () => { // There should be a tour entry for virtual study, with the content `Create a Virtual Study` - const virtualStudyTourEntry = $('div[data-type="virtual-study-tour"]'); - virtualStudyTourEntry.waitForDisplayed(); - assert.equal(virtualStudyTourEntry.getText(), 'Create a Virtual Study'); + const virtualStudyTourEntry = getElement( + 'div[data-type="virtual-study-tour"]' + ); + await virtualStudyTourEntry.waitForDisplayed(); + assert.equal( + await virtualStudyTourEntry.getText(), + 'Create a Virtual Study' + ); // Click on the tour entry to start the tour - virtualStudyTourEntry.click(); + await virtualStudyTourEntry.click(); step++; }); - it('Step 0: Type “glioma” in the search box automatically.', () => { + it('Step 0: Type “glioma” in the search box automatically.', async () => { // The tour should be on the first step: step = 0 assert.equal(step, 0); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL); + await tourModal.waitForExist(); // On the modal, the title of the content should be `Search for the studies` - assert.equal(tourModal.$('.title').getText(), 'Search for the studies'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Search for the studies' + ); // On the modal, there should be a `Skip All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); assert.equal(nextStepBtn.getText(), 'Next Step'); // There should be a search box on the homepage, the value should be `glioma` - const cancerStudySearchBox = $( + const cancerStudySearchBox = await getElement( '[data-tour="cancer-study-search-box"] input' ); - assert.equal(cancerStudySearchBox.getValue(), 'glioma'); + assert.equal(await cancerStudySearchBox.getValue(), 'glioma'); // TODO: This is a temporary fix for the tour // when searching for the keyword "glioma," there's only one study in the results // but I need two studies for the tour, so I'm going to clear the filter // and select two studies - browser.pause(2000); - $('[data-test="clearStudyFilter"]').waitForDisplayed(); - $('[data-test="clearStudyFilter"]').click(); - browser.pause(2000); + await browser.pause(2000); + await waitForElementDisplayed('[data-test="clearStudyFilter"]'); + clickElement('[data-test="clearStudyFilter"]'); + await browser.pause(2000); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 1: User should select two studies, on the homepage', () => { + it('Step 1: User should select two studies, on the homepage', async () => { // The tour should be on the second step: step = 1 assert.equal(step, 1); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL); + await tourModal.waitForExist(); // On the modal, the title of the content should be `Select two studies` - assert.equal(tourModal.$('.title').getText(), 'Select two studies'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Select two studies' + ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should have a list container with at least two studies - const cancerStudyListContainer = $( + const cancerStudyListContainer = await getElement( '[data-tour="cancer-study-list-container"]' ); - cancerStudyListContainer.waitForDisplayed(); - const cancerStudyList = cancerStudyListContainer.$$( + await cancerStudyListContainer.waitForDisplayed(); + const cancerStudyList = await cancerStudyListContainer.$$( '[data-test="StudySelect"]' ); assert(cancerStudyList.length >= 2); // Select two study - $('[data-tour="cancer-study-list-container"]') - .$$('input')[0] - .click(); + await ( + await ( + await getElement('[data-tour="cancer-study-list-container"]') + ).$$('input') + )[0].click(); // cancerStudyListContainer.$$('input')[0].waitForDisplayed(); // cancerStudyListContainer.$$('input')[0].click(); @@ -111,245 +133,295 @@ describe('Virtual Study Tour', () => { // ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 2: Click the “Explore Selected Studies” button, on the homepage.', () => { + it('Step 2: Click the “Explore Selected Studies” button, on the homepage.', async () => { // The tour should be step = 2 assert.equal(step, 2); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); + const tourModal = getElement(VIRTUAL_STUDY_TOUR_MODAL); tourModal.waitForExist(); // On the modal, the title of the content should be `Click the Explore button` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'Click the Explore button' ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be the “Explore Selected Studies” button // Click on the “Explore Selected Studies” button, the tour should go to the next step - $('[data-tour="explore-studies-button"]').click(); + await clickElement('[data-tour="explore-studies-button"]'); step++; }); - it('Step 3: Click the “+” icon, on the study summary page.', () => { + it('Step 3: Click the “+” icon, on the study summary page.', async () => { // Should be on the Study Summary page. - browser.waitUntil(() => browser.getUrl().includes('study/summary'), { - timeout: 20000, - timeoutMsg: 'expected to be on study summary page', - }); + await browser.waitUntil( + async () => (await browser.getUrl()).includes('study/summary'), + { + timeout: 20000, + timeoutMsg: 'expected to be on study summary page', + } + ); // The tour should be at step = 3. assert.equal(step, 3); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL); + await tourModal.waitForExist(); // On the modal, the title of the content should be `See list of studies` - assert.equal(tourModal.$('.title').getText(), 'See list of studies'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'See list of studies' + ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // There should be the “+” icon - $('[data-tour="show-more-description-icon"]').waitForDisplayed(); - browser.pause(3000); + await waitForElementDisplayed( + '[data-tour="show-more-description-icon"]' + ); + await browser.pause(3000); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 4: Select samples in the Mutated Genes table, on the study summary page.', () => { + it('Step 4: Select samples in the Mutated Genes table, on the study summary page.', async () => { // The tour should be at step = 4. assert.equal(step, 4); - browser.pause(1000); + await browser.pause(1000); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Select samples` - assert.equal(tourModal.$('.title').getText(), 'Select samples'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Select samples' + ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be the Mutated Genes table [data-tour="mutated-genes-table"] - const mutatedGenesTable = $('[data-tour="mutated-genes-table"]').$( - '[data-test="mutations-table"]' - ); - mutatedGenesTable.waitForDisplayed(); + const mutatedGenesTable = await getNestedElement([ + '[data-tour="mutated-genes-table"]', + '[data-test="mutations-table"]', + ]); + await mutatedGenesTable.waitForDisplayed(); // Select samples - mutatedGenesTable.$$('input')[0].waitForDisplayed(); - mutatedGenesTable.$$('input')[0].click(); - browser.pause(1000); - mutatedGenesTable.$('button=Select Samples').waitForDisplayed(); - mutatedGenesTable.$('button=Select Samples').click(); + await (await mutatedGenesTable.$$('input'))[0].waitForDisplayed(); + await (await mutatedGenesTable.$$('input'))[0].click(); + await browser.pause(1000); + await ( + await mutatedGenesTable.$('button=Select Samples') + ).waitForDisplayed(); + await (await mutatedGenesTable.$('button=Select Samples')).click(); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 5: Describe what they would see later, on the study summary page.', () => { + it('Step 5: Describe what they would see later, on the study summary page.', async () => { // The tour should be at step = 5 assert.equal(step, 5); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); - + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Share/save your virtual study` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'Share/save your virtual study' ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 6: Click the bookmark icon, on the study summary page.', () => { + it('Step 6: Click the bookmark icon, on the study summary page.', async () => { // The tour should be at step = 6. assert.equal(step, 6); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Click the bookmark icon` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'Click the bookmark icon' ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be a bookmark icon [data-tour="action-button-bookmark"] // Click the bookmark icon, the tour should go to the next step - browser.pause(4000); - const node = $('.studyView'); - node.$('button[data-tour="action-button-bookmark"]').waitForDisplayed(); - node.$('button[data-tour="action-button-bookmark"]').click(); - browser.pause(4000); + await browser.pause(4000); + const node = await getElement('.studyView'); + await ( + await node.$('button[data-tour="action-button-bookmark"]') + ).waitForDisplayed(); + await ( + await node.$('button[data-tour="action-button-bookmark"]') + ).click(); + await browser.pause(4000); step++; }); - it('Step 7: Click on the Save button, on the study summary page.', () => { + it('Step 7: Click on the Save button, on the study summary page.', async () => { // The tour should be at step = 7. assert.equal(step, 7); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Click on the Save button` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'Click on the Save button' ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be a share panel [data-tour="virtual-study-summary-panel"] - const sharePanel = $('[data-tour="virtual-study-summary-panel"]'); - sharePanel.waitForDisplayed(); + const sharePanel = await waitForElementDisplayed( + '[data-tour="virtual-study-summary-panel"]' + ); // There should be a share button [data-tour="virtual-study-summary-save-btn"] // Click the share button, the tour should go to the next step - sharePanel - .$('button[data-tour="virtual-study-summary-save-btn"]') - .click(); - browser.pause(4000); + await ( + await sharePanel.$( + 'button[data-tour="virtual-study-summary-save-btn"]' + ) + ).click(); + await browser.pause(4000); step++; }); - it('Step 8: Show the share link.', () => { + it('Step 8: Show the share link.', async () => { // The tour should be at step = 8. assert.equal(step, 8); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Already saved` - assert.equal(tourModal.$('.title').getText(), 'Already saved'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Already saved' + ); // On the modal, there should be a `Finish guidance` button and a `Help me find it` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Finish guidance'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Finish guidance' + ); const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Help me find it'); + assert.equal(await nextStepBtn.getText(), 'Help me find it'); // There should be a link panel [data-tour="virtual-study-summary-panel"] - const linkPanel = $('[data-tour="virtual-study-summary-panel"]'); - linkPanel.waitForDisplayed(); + await waitForElementDisplayed( + '[data-tour="virtual-study-summary-panel"]' + ); // Click on the `Help me find it` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 9: In homepage, Show the new virtual study pre-selected.', () => { + it('Step 9: In homepage, Show the new virtual study pre-selected.', async () => { // Should be on the homepage. - browser.pause(3000); + await browser.pause(3000); // The tour should be at step = 9. assert.equal(step, 9); // There should be a tour modal - const tourModal = $(VIRTUAL_STUDY_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(VIRTUAL_STUDY_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `My Virtual Studies` - assert.equal(tourModal.$('.title').getText(), 'My Virtual Studies'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'My Virtual Studies' + ); // On the modal, there should be a `Skip All` button and a `Finish guidance` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(LAST_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Finish guidance 🎉'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(LAST_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Finish guidance 🎉'); // There should be a 'My Virtual Studies' list [data-tour="my_virtual_studies_list"] - const linkPanel = $('[data-tour="my_virtual_studies_list"]'); - linkPanel.waitForDisplayed(); + await waitForElementDisplayed('[data-tour="my_virtual_studies_list"]'); // Click on the `Finish guidance` button, the tour should end - nextStepBtn.click(); + await nextStepBtn.click(); }); }); @@ -358,88 +430,98 @@ describe('Group Comparison Tour', function() { this.retries(0); - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL, true); }); - beforeEach(() => { - browser.setWindowSize(1600, 1200); + beforeEach(async () => { + await browser.setWindowSize(1600, 1200); }); it('Initial step with -1.', () => { assert.equal(step, -1); }); - it('Click the entry to start tour.', () => { + it('Click the entry to start tour.', async () => { // There should be a tour entry for virtual study, with the content `Compare User-defined Groups of Samples`. - const groupComparisonTourEntry = $( + const groupComparisonTourEntry = await waitForElementDisplayed( 'div[data-type="group-comparison-tour"]' ); - groupComparisonTourEntry.waitForDisplayed(); assert.equal( - groupComparisonTourEntry.getText(), + await groupComparisonTourEntry.getText(), 'Compare User-defined Groups of Samples' ); // Click on the tour entry to start the tour - groupComparisonTourEntry.click(); + await groupComparisonTourEntry.click(); step++; }); - it('Step 0: Type “glioma” in the search box automatically.', () => { + it('Step 0: Type “glioma” in the search box automatically.', async () => { // The tour should be on the first step: step = 0 assert.equal(step, 0); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Search for the studies` - assert.equal(tourModal.$('.title').getText(), 'Search for the studies'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Search for the studies' + ); // On the modal, there should be a `Skip All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // There should be a search box on the homepage, the value should be `glioma` - const cancerStudySearchBox = $( + const cancerStudySearchBox = await getElement( '[data-tour="cancer-study-search-box"] input' ); - assert.equal(cancerStudySearchBox.getValue(), 'glioma'); + assert.equal(await cancerStudySearchBox.getValue(), 'glioma'); // Click on the `Next Step` button, the tour should go to the next step - browser.pause(3000); - nextStepBtn.click(); + await browser.pause(3000); + await nextStepBtn.click(); step++; }); - it('Step 1: Click on “View study summary” button, on the homepage.', () => { + it('Step 1: Click on “View study summary” button, on the homepage.', async () => { // The tour should be at step = 1. assert.equal(step, 1); // There should be a tour modal - browser.pause(3000); - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + await browser.pause(3000); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL); + await tourModal.waitForExist(); // On the modal, the title of the content should be `Click the button` - assert.equal(tourModal.$('.title').getText(), 'Click the button'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Click the button' + ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be a `View study summary` button in the study list [data-tour="cancer-study-list-container"] - const cancerStudyListContainer = $( + const cancerStudyListContainer = await waitForElementDisplayed( '[data-tour="cancer-study-list-container"]' ); - cancerStudyListContainer.waitForDisplayed(); // Click on the `View study summary` button next to 'Merged Cohort of LGG and GBM (TCGA, Cell 2016)' // the tour should go to the next step - cancerStudyListContainer.$$('a.ci-pie-chart')[0].waitForDisplayed(); - cancerStudyListContainer.$$('a.ci-pie-chart')[0].click(); + await ( + await cancerStudyListContainer.$$('a.ci-pie-chart') + )[0].waitForDisplayed(); + await (await cancerStudyListContainer.$$('a.ci-pie-chart'))[0].click(); // clickViewSummaryStudyView( // 'Merged Cohort of LGG and GBM (TCGA, Cell 2016)' @@ -447,275 +529,330 @@ describe('Group Comparison Tour', function() { step++; }); - it('Step 2: Select more than one sample in the Mutated Genes table, on the study summary page.', () => { + it('Step 2: Select more than one sample in the Mutated Genes table, on the study summary page.', async () => { // Should be on the Study Summary page. - browser.waitUntil(() => browser.getUrl().includes('study/summary'), { - timeout: 20000, - timeoutMsg: 'expected to be on study summary page', - }); + await browser.waitUntil( + async () => (await browser.getUrl()).includes('study/summary'), + { + timeout: 20000, + timeoutMsg: 'expected to be on study summary page', + } + ); - browser.pause(3000); + await browser.pause(3000); // A little bit hacky here // I need to resize the window to make sure the tour modal can render correctly - browser.setWindowSize( - browser.getWindowSize().width, - browser.getWindowSize().height + await browser.setWindowSize( + (await browser.getWindowSize()).width, + (await browser.getWindowSize()).height ); - browser.pause(3000); + await browser.pause(3000); // The tour should be at step = 2. assert.equal(step, 2); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Select two samples` - assert.equal(tourModal.$('.title').getText(), 'Select two samples'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'Select two samples' + ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); - browser.setWindowSize( - browser.getWindowSize().width + 400, - browser.getWindowSize().height + await browser.setWindowSize( + (await browser.getWindowSize()).width + 400, + (await browser.getWindowSize()).height ); - browser.pause(1000); + await browser.pause(1000); // There should be the Mutated Genes table [data-tour="mutated-genes-table"] - const mutatedGenesTable = $('[data-tour="mutated-genes-table"]').$( - '[data-test="mutations-table"]' - ); - mutatedGenesTable.waitForDisplayed(); + const mutatedGenesTable = await getNestedElement([ + '[data-tour="mutated-genes-table"]', + '[data-test="mutations-table"]', + ]); + await mutatedGenesTable.waitForDisplayed(); // Select samples, IDH1 mutations, TP53 mutant and EGFR amplified samples - mutatedGenesTable.$$('input')[0].waitForDisplayed(); + await (await mutatedGenesTable.$$('input'))[0].waitForDisplayed(); //browser.debug(); - mutatedGenesTable.$$('input')[0].click(); - mutatedGenesTable.$$('input')[1].click(); + await (await mutatedGenesTable.$$('input'))[0].click(); + await (await mutatedGenesTable.$$('input'))[1].click(); - browser.pause(3000); + await browser.pause(3000); // The tour should go to the next step step++; }); - it('Step 3: Click the “Compare” button, on the study summary page.', () => { + it('Step 3: Click the “Compare” button, on the study summary page.', async () => { // The tour should be at step = 3. assert.equal(step, 3); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `Click the Compare button` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'Click the Compare button' ); // On the modal, there should not be a `Skill All` button and a `Next Step` button - !tourModal.$(SKIP_ALL_BTN).isDisplayed(); - !tourModal.$(NEXT_STEP_BTN).isDisplayed(); + !(await (await tourModal.$(SKIP_ALL_BTN)).isDisplayed()); + !(await (await tourModal.$(NEXT_STEP_BTN)).isDisplayed()); // There should be a compare button [data-tour="mutated-genes-table-compare-btn"] - const compareBtn = $('[data-tour="mutated-genes-table-compare-btn"]'); - compareBtn.waitForDisplayed(); + const compareBtn = await waitForElementDisplayed( + '[data-tour="mutated-genes-table-compare-btn"]' + ); // Click the compare button, the tour should go to the next step - compareBtn.click(); + await compareBtn.click(); step++; }); - it('Step 4: Show the header of the page, on the group comparison page.', () => { + it('Step 4: Show the header of the page, on the group comparison page.', async () => { // Switch to the new tab by selecting the last handle - browser.pause(1000); - const handles = browser.getWindowHandles(); + await browser.pause(1000); + const handles = await browser.getWindowHandles(); const newTabHandle = handles[handles.length - 1]; - console.log('handles', handles); - browser.switchToWindow(newTabHandle); + await browser.switchToWindow(newTabHandle); // Should be on the group comparison page. - browser.waitUntil(() => browser.getUrl().includes('/comparison'), { - timeout: 10000, - timeoutMsg: 'expected to be on group comparison page', - }); + await browser.waitUntil( + async () => (await browser.getUrl()).includes('/comparison'), + { + timeout: 10000, + timeoutMsg: 'expected to be on group comparison page', + } + ); // The tour should be at step = 4 assert.equal(step, 4); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `The original study` - assert.equal(tourModal.$('.title').getText(), 'The original study'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The original study' + ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // There should be a header [data-tour="single-study-group-comparison-header"] - $( + await waitForElementDisplayed( '[data-tour="single-study-group-comparison-header"]' - ).waitForDisplayed(); + ); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 5: Show the attribute, on the group comparison page.', () => { + it('Step 5: Show the attribute, on the group comparison page.', async () => { // The tour should be at step = 5 assert.equal(step, 5); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `The attribute` - assert.equal(tourModal.$('.title').getText(), 'The attribute'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The attribute' + ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // There should be a subheader [data-tour="single-study-group-comparison-attribute"] - $( + await waitForElementDisplayed( '[data-tour="single-study-group-comparison-attribute"]' - ).waitForDisplayed(); + ); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 6: Show the available groups, on the group comparison page.', () => { + it('Step 6: Show the available groups, on the group comparison page.', async () => { // The tour should be at step = 6 assert.equal(step, 6); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `The available groups` - assert.equal(tourModal.$('.title').getText(), 'The available groups'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The available groups' + ); // On the modal, there should be a `Skill All` button and a `Next Step` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Skip All'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Step'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Skip All' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Step'); // There should be a subheader [data-tour="single-study-group-comparison-groups"] - $( + await waitForElementDisplayed( '[data-tour="single-study-group-comparison-groups"]' - ).waitForDisplayed(); + ); // Click on the `Next Step` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it('Step 7: Intro to the Overlap tab, on the group comparison page.', () => { + it('Step 7: Intro to the Overlap tab, on the group comparison page.', async () => { // The tour should be at step = 7 assert.equal(step, 7); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist(); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + waitForExist: true, + }); // On the modal, the title of the content should be `The Overlap tab` - assert.equal(tourModal.$('.title').getText(), 'The Overlap tab'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The Overlap tab' + ); // On the modal, there should be a `Finish guidance` button and a `Next Tab` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Finish guidance'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Tab'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Finish guidance' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Tab'); // There should be a Overlap tab .mainTabs - $('.mainTabs').waitForDisplayed(); + await waitForElementDisplayed('.mainTabs'); // Click on the `Next Tab` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it.skip('Step 8: Intro to the Survival tab, on the group comparison page.', () => { + it.skip('Step 8: Intro to the Survival tab, on the group comparison page.', async () => { // The tour should be at step = 8 assert.equal(step, 8); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist({ timeout: 1000 }); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + timeout: 1000, + }); // On the modal, the title of the content should be `The Survival tab` - assert.equal(tourModal.$('.title').getText(), 'The Survival tab'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The Survival tab' + ); // On the modal, there should be a `Finish guidance` button and a `Next Tab` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Finish guidance'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Tab'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Finish guidance' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Tab'); // There should be a Survival tab [data-tour="mainColumn"] - $('[data-tour="mainColumn"]').waitForDisplayed(); + await waitForElementDisplayed('[data-tour="mainColumn"]'); // Click on the `Next Tab` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it.skip('Step 9: Intro to the Clinical tab, on the group comparison page.', () => { + it.skip('Step 9: Intro to the Clinical tab, on the group comparison page.', async () => { // The tour should be at step = 9 assert.equal(step, 9); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist({ timeout: 1000 }); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + timeout: 1000, + }); // On the modal, the title of the content should be `The Clinical tab` - assert.equal(tourModal.$('.title').getText(), 'The Clinical tab'); + assert.equal( + await (await tourModal.$('.title')).getText(), + 'The Clinical tab' + ); // On the modal, there should be a `Finish guidance` button and a `Next Tab` button - assert.equal(tourModal.$(SKIP_ALL_BTN).getText(), 'Finish guidance'); - const nextStepBtn = tourModal.$(NEXT_STEP_BTN); - assert.equal(nextStepBtn.getText(), 'Next Tab'); + assert.equal( + await (await tourModal.$(SKIP_ALL_BTN)).getText(), + 'Finish guidance' + ); + const nextStepBtn = await tourModal.$(NEXT_STEP_BTN); + assert.equal(await nextStepBtn.getText(), 'Next Tab'); // There should be a Clinical tab [data-tour="mainColumn"] - $('[data-tour="mainColumn"]').waitForDisplayed(); + await waitForElementDisplayed('[data-tour="mainColumn"]'); // Click on the `Next Tab` button, the tour should go to the next step - nextStepBtn.click(); + await nextStepBtn.click(); step++; }); - it.skip('Step 10: Intro to the Genomic Alterations tab, on the group comparison page.', () => { + it.skip('Step 10: Intro to the Genomic Alterations tab, on the group comparison page.', async () => { // The tour should be at step = 10 assert.equal(step, 10); // There should be a tour modal - const tourModal = $(GROUP_COMPARISON_TOUR_MODAL); - tourModal.waitForExist({ timeout: 1000 }); + const tourModal = await getElement(GROUP_COMPARISON_TOUR_MODAL, { + timeout: 1000, + }); // On the modal, the title of the content should be `The Genomic Alterations tab` assert.equal( - tourModal.$('.title').getText(), + await (await tourModal.$('.title')).getText(), 'The Genomic Alterations tab' ); // On the modal, there should be a `Finish guidance 🎉` button - const finishStepBtn = tourModal.$(LAST_STEP_BTN); - assert.equal(finishStepBtn.getText(), 'Finish guidance 🎉'); + const finishStepBtn = await tourModal.$(LAST_STEP_BTN); + assert.equal(await finishStepBtn.getText(), 'Finish guidance 🎉'); // There should be a Genomic Alterations tab [data-tour="mainColumn"] - $('[data-tour="mainColumn"]').waitForDisplayed(); + await waitForElementDisplayed('[data-tour="mainColumn"]'); // Click on the `Finish guidance 🎉` button, the tour should end - finishStepBtn.click(); + await finishStepBtn.click(); }); }); diff --git a/end-to-end-test/shared/specUtils_Async.js b/end-to-end-test/shared/specUtils_Async.js index a6d3c25e35c..99eda5d3e18 100644 --- a/end-to-end-test/shared/specUtils_Async.js +++ b/end-to-end-test/shared/specUtils_Async.js @@ -3,8 +3,8 @@ const assertScreenShotMatch = require('./lib/testUtils').assertScreenShotMatch; const DEFAULT_TIMEOUT = 5000; -function waitForStudyQueryPage(timeout) { - $('div[data-test="cancerTypeListContainer"]').waitForExist({ +async function waitForStudyQueryPage(timeout) { + await getElement('div[data-test="cancerTypeListContainer"]', { timeout: timeout || 10000, }); } @@ -39,16 +39,16 @@ async function waitForAndCheckPlotsTab() { assertScreenShotMatch(res); } -function waitForCoExpressionTab(timeout) { - $('#coexpressionTabGeneTabs').waitForExist({ timeout: timeout || 20000 }); +async function waitForCoExpressionTab(timeout) { + await getElement('#coexpressionTabGeneTabs', { timeout: timeout || 20000 }); } -function waitForPatientView(timeout) { - $('#patientViewPageTabs').waitForExist({ timeout: timeout || 20000 }); - $('[data-test=patientview-copynumber-table]').waitForDisplayed({ +async function waitForPatientView(timeout) { + await getElement('#patientViewPageTabs', { timeout: timeout || 20000 }); + await waitForElementDisplayed('[data-test=patientview-copynumber-table]', { timeout: timeout || 20000, }); - $('[data-test=patientview-mutation-table]').waitForDisplayed({ + await waitForElementDisplayed('[data-test=patientview-mutation-table]', { timeout: timeout || 20000, }); } @@ -129,7 +129,6 @@ async function getCSSProperty(selector, property) { const { value } = await element.getCSSProperty(property); return value; } - /** * @param {string} selector * @param {number} index @@ -270,24 +269,53 @@ async function goToUrlAndSetLocalStorage(url, authenticated = false) { await browser.url(`${url}${prefix}${urlparam}=true`); console.log('Connecting to: ' + `${url}${prefix}${urlparam}=true`); } - if (needToLogin) keycloakLogin(10000); + if (needToLogin) await keycloakLogin(10000); await browser.pause(1000); } -const setServerConfiguration = serverConfig => { - browser.execute(function(_serverConfig) { - this.localStorage.setItem( - 'frontendConfig', - JSON.stringify({ serverConfig: _serverConfig }) - ); - }, serverConfig); +const goToUrlAndSetLocalStorageWithProperty = async ( + url, + authenticated, + props +) => { + await goToUrlAndSetLocalStorage(url, authenticated); + await setServerConfiguration(props); + await goToUrlAndSetLocalStorage(url, authenticated); }; -const goToUrlAndSetLocalStorageWithProperty = (url, authenticated, props) => { - goToUrlAndSetLocalStorage(url, authenticated); - setServerConfiguration(props); - goToUrlAndSetLocalStorage(url, authenticated); -}; +async function setServerConfiguration(props) { + await browser.execute( + function(frontendConf) { + this.localStorage.setItem( + 'frontendConfig', + JSON.stringify(frontendConf) + ); + }, + { serverConfig: props } + ); +} + +async function waitForElementDisplayed(selector, options = {}) { + const element = await getElement(selector, options); + await element.waitForDisplayed({ + timeout: options.timeout || 10000, + ...options, + }); + + return element; +} + +function setServerConfiguration(props) { + browser.execute( + function(frontendConf) { + this.localStorage.setItem( + 'frontendConfig', + JSON.stringify(frontendConf) + ); + }, + { serverConfig: props } + ); +} async function waitForElementDisplayed(selector, options = {}) { const element = await getElement(selector, options); @@ -305,8 +333,8 @@ function sessionServiceIsEnabled() { }).value; } -function showGsva() { - setServerConfiguration({ skin_show_gsva: true }); +async function showGsva() { + await setServerConfiguration({ skin_show_gsva: true }); } async function waitForNumberOfStudyCheckboxes(expectedNumber, text) { @@ -407,8 +435,8 @@ async function waitForStudyView() { ); } -function waitForGroupComparisonTabOpen(timeout) { - $('[data-test=ComparisonPageOverlapTabDiv]').waitForDisplayed({ +async function waitForGroupComparisonTabOpen(timeout) { + await waitForElementDisplayed('[data-test=ComparisonPageOverlapTabDiv]', { timeout: timeout || 10000, }); } @@ -434,13 +462,13 @@ async function setInputText(selector, text) { await (await $(selector)).setValue(text); } -function getReactSelectOptions(parent) { - parent.$('.Select-control').click(); - return parent.$$('.Select-option'); +async function getReactSelectOptions(parent) { + await (await parent.$('.Select-control')).click(); + return await parent.$$('.Select-option'); } -function selectReactSelectOption(parent, optionText) { - reactSelectOption(parent, optionText).click(); +async function selectReactSelectOption(parent, optionText) { + await (await reactSelectOption(parent, optionText)).click(); } async function reactSelectOption(parent, optionText, loose = false) { @@ -627,13 +655,13 @@ async function getOncoprintGroupHeaderOptionsElements(trackGroupIndex) { * @param {any} data * @param {boolean} authenticated */ -function postDataToUrl(url, data, authenticated = true) { - const currentUrl = browser.getUrl(); +async function postDataToUrl(url, data, authenticated = true) { + const currentUrl = await browser.getUrl(); const needToLogin = authenticated && (!currentUrl || !currentUrl.includes('http')); url = getUrl(url); - browser.execute( + await browser.execute( (/** @type {string} */ url, /** @type {any} */ data) => { function formSubmit(url, params) { // method="smart" means submit with GET iff the URL wouldn't be too long @@ -660,84 +688,96 @@ function postDataToUrl(url, data, authenticated = true) { url, data ); - if (needToLogin) keycloakLogin(10000); + if (needToLogin) await keycloakLogin(10000); } -function keycloakLogin(timeout) { - browser.waitUntil(() => browser.getUrl().includes('/auth/realms/cbio'), { - timeout, - timeoutMsg: 'No redirect to Keycloak could be detected.', - }); - $('#username').waitForDisplayed(timeout); +async function keycloakLogin(timeout) { + await browser.waitUntil( + async () => (await browser.getUrl()).includes('/auth/realms/cbio'), + { + timeout, + timeoutMsg: 'No redirect to Keycloak could be detected.', + } + ); + await isDisplayed('#username'); - $('#username').setValue('testuser'); - $('#password').setValue('P@ssword1'); - $('#kc-login').click(); + await setInputText('#username', 'testuser'); + await setInputText('#password', 'P@ssword1'); + await clickElement('#kc-login'); - browser.waitUntil(() => !browser.getUrl().includes('/auth/realms/cbio')); - $('body').waitForDisplayed(timeout); + await browser.waitUntil( + async () => !(await browser.getUrl()).includes('/auth/realms/cbio') + ); + await isDisplayed('body', timeout); } -function closeOtherTabs() { - const studyWindow = browser.getWindowHandle(); - browser.getWindowHandles().forEach(id => { - if (id === studyWindow) { - return; - } - console.log('close tab:', id); - browser.switchToWindow(id); - browser.closeWindow(); - }); - browser.switchToWindow(studyWindow); +async function closeOtherTabs() { + const studyWindow = await browser.getWindowHandle(); + const windowHandles = await browser.getWindowHandles(); + + await Promise.all( + windowHandles.map(async id => { + if (id !== studyWindow) { + console.log('close tab:', id); + await browser.switchToWindow(id); + await browser.closeWindow(); + } + }) + ); + + await browser.switchToWindow(studyWindow); } -function openGroupComparison(studyViewUrl, chartDataTest, timeout) { - goToUrlAndSetLocalStorage(studyViewUrl, true); - $('[data-test=summary-tab-content]').waitForDisplayed(); - waitForNetworkQuiet(); +async function openGroupComparison(studyViewUrl, chartDataTest, timeout) { + await goToUrlAndSetLocalStorage(studyViewUrl, true); + await waitForElementDisplayed('[data-test=summary-tab-content]'); + await waitForNetworkQuiet(); // needed to switch to group comparison tab later on: - closeOtherTabs(); + await closeOtherTabs(); const chart = '[data-test=' + chartDataTest + ']'; - $(chart).waitForDisplayed({ timeout: timeout || 10000 }); - jsApiHover(chart); + await waitForElementDisplayed(chart, { timeout: timeout || 10000 }); + await jsApiHover(chart); - browser.waitUntil( - () => { - return $(chart + ' .controls').isExisting(); + await browser.waitUntil( + async () => { + return await getElement(chart + ' .controls', { + waitForExist: true, + }); }, { timeout: timeout || 10000 } ); // move to hamburger icon const hamburgerIcon = '[data-test=chart-header-hamburger-icon]'; - jsApiHover(hamburgerIcon); + await jsApiHover(hamburgerIcon); // wait for the menu available - $(hamburgerIcon).waitForDisplayed({ timeout: timeout || 10000 }); + await waitForElementDisplayed(hamburgerIcon, { timeout: timeout || 10000 }); - // open comparison session - const studyViewTabId = browser.getWindowHandle(); + const studyViewTabId = await browser.getWindowHandle(); - const chartHamburgerIcon = $(chart).$(hamburgerIcon); - $(chartHamburgerIcon).waitForDisplayed({ timeout: timeout || 10000 }); + const chartHamburgerIcon = await getNestedElement([chart, hamburgerIcon]); + await waitForElementDisplayed(chartHamburgerIcon, { + timeout: timeout || 10000, + }); - $(chartHamburgerIcon) - .$$('li')[1] - .click(); + await (await (await getElement(chartHamburgerIcon)).$$('li'))[1].click(); - browser.waitUntil(() => browser.getWindowHandles().length > 1); // wait until new tab opens + await browser.waitUntil( + async () => (await browser.getWindowHandles()).length > 1 + ); // wait until new tab opens - const groupComparisonTabId = browser - .getWindowHandles() - .find(id => id !== studyViewTabId); + const groupComparisonTabId = (await browser.getWindowHandles()).find( + id => id !== studyViewTabId + ); - browser.switchToWindow(groupComparisonTabId); - waitForGroupComparisonTabOpen(timeout); + await browser.switchToWindow(groupComparisonTabId); + await waitForGroupComparisonTabOpen(timeout); } -function selectElementByText(text) { +async function selectElementByText(text) { return $(`//*[text()="${text}"]`); } @@ -793,8 +833,26 @@ async function getElement(selector, options = {}) { if (options.timeout) { await el.waitForExist(options); } + + if (options.waitForExist) { + await el.waitForExist(); + } + return el; } + +const getNestedElement = async function(selector = [], options = {}) { + let currentElement; + for (const element of selector) { + if (!currentElement) { + currentElement = await getElement(element, options); + } else { + currentElement = await currentElement.$(element); + } + } + return currentElement; +}; + /** * @param {string} selector css selector * @param {number} index index of the element @@ -883,11 +941,13 @@ module.exports = { selectReactSelectOption, reactSelectOption, getReactSelectOptions, + waitForElementDisplayed, COEXPRESSION_TIMEOUT: 120000, getSelectCheckedOptions, selectCheckedOption, getOncoprintGroupHeaderOptionsElements, showGsva, + isDisplayed, setSettingsMenuOpen, setDropdownOpen, postDataToUrl, @@ -901,6 +961,7 @@ module.exports = { strIsNumeric, getNthElements, getColorByTestHandle, + getNestedElement, getColorOfNthElement, jq, setServerConfiguration,