From 534daad653d52595c97c5927cb59acfe8b25d427 Mon Sep 17 00:00:00 2001 From: Jonathan Atiene <34762800+bemijonathan@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:18:42 +0100 Subject: [PATCH] move sync to async for all remote tests (#4920) * migrate all remote e2e tests from sync to async style --------- Co-authored-by: lismana --- .../remote/specs/core/customTabs.spec.js | 256 ++++++---- .../specs/core/expressionComparison.spec.js | 236 +++++---- .../specs/core/genomicEvolution.spec.js | 106 ++-- .../remote/specs/core/groupComparison.spec.js | 321 ++++++++---- .../remote/specs/core/oncoprinter.spec.js | 81 +-- .../remote/specs/core/patient.logic.spec.js | 27 +- .../remote/specs/core/plots.spec.js | 57 ++- .../remote/specs/core/quickSearch.spec.js | 87 ++-- .../remote/specs/core/redirect.spec.js | 8 +- .../remote/specs/core/results.logic.spec.js | 481 ++++++++++-------- end-to-end-test/shared/specUtils_Async.js | 183 ++++--- 11 files changed, 1079 insertions(+), 764 deletions(-) diff --git a/end-to-end-test/remote/specs/core/customTabs.spec.js b/end-to-end-test/remote/specs/core/customTabs.spec.js index b9687fc8d15..16f75f696f3 100644 --- a/end-to-end-test/remote/specs/core/customTabs.spec.js +++ b/end-to-end-test/remote/specs/core/customTabs.spec.js @@ -1,13 +1,18 @@ -var assert = require('assert'); - -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var setServerConfiguration = require('../../../shared/specUtils') - .setServerConfiguration; +const assert = require('assert'); +const { + setServerConfiguration, + goToUrlAndSetLocalStorage, + getElement, + clickElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -function customTabBase(location) { +const getBrowserHeight = async () => { + return Number((await browser.getWindowSize()).height); +}; + +const customTabBase = location => { return [ { title: 'Sync Tab', @@ -33,58 +38,81 @@ function customTabBase(location) { }`, }, ]; -} - -function goToUrlWithCustomTabConfig(url, custom_tabs) { - browser.url(`${CBIOPORTAL_URL}/blank`); - setServerConfiguration({ - custom_tabs, - }); - goToUrlAndSetLocalStorage(url); -} +}; + +const goToUrlWithCustomTabConfig = async (url, custom_tabs) => { + await browser.url(`${CBIOPORTAL_URL}/blank`); + setServerConfiguration({ custom_tabs }); + await goToUrlAndSetLocalStorage(url); +}; + +const waitForMainTabs = async () => { + await browser.waitUntil( + async () => { + return await (await getElement('.mainTabs')).isDisplayed(); + }, + { timeout: 50000 } + ); +}; -function runTests(pageName, url, tabLocation) { +const runTests = async (pageName, url, tabLocation) => { describe(`${pageName} Custom Tabs`, () => { - it.skip('Sync and async hide/show works', function() { + before( + async () => + await browser.setWindowSize(2000, await getBrowserHeight()) + ); + + it.skip('Sync and async hide/show works', async function() { this.retries(0); - goToUrlWithCustomTabConfig(url, customTabBase(tabLocation)); + await goToUrlWithCustomTabConfig(url, customTabBase(tabLocation)); - browser.execute(() => { - window.renderCustomTab1 = function(div, tab) { - $(div).append( + await browser.execute(() => { + window.renderCustomTab1 = async function(div, tab) { + (await getElement(div)).append( `
this is the content for ${tab.title}
` ); }; }); - $('.mainTabs').waitForDisplayed(); + await waitForMainTabs(); assert.equal( - $('=Async Tab').isDisplayed(), + await (await getElement('=Async Tab')).isDisplayed(), false, 'We do NOT see async tab initially' ); - assert($('=Sync Tab').isDisplayed(), 'We see sync tab immediately'); + assert( + await (await getElement('=Sync Tab')).isDisplayed(), + 'We see sync tab immediately' + ); - browser.pause(6000); + await browser.pause(6000); assert( - $('=Async Tab').isDisplayed(), + await (await getElement('=Async Tab')).isDisplayed(), 'Async tab displays after pause' ); - $('=Sync Tab').click(); + await (await getElement('=Sync Tab')).click(); - assert($('div=this is the content for Sync Tab').isDisplayed()); + assert( + await ( + await getElement('div=this is the content for Sync Tab') + ).isDisplayed() + ); - $('=Async Tab').click(); + await (await getElement('=Async Tab')).click(); - assert($('div=this is the content for Async Tab').isDisplayed()); + assert( + await ( + await getElement('div=this is the content for Async Tab') + ).isDisplayed() + ); }); - it('Tab page location configuration is obeyed', () => { + it('Tab page location configuration is obeyed', async () => { const conf = [ { title: 'Patient Tab', @@ -102,26 +130,26 @@ function runTests(pageName, url, tabLocation) { }, ]; - goToUrlWithCustomTabConfig(url, conf); + await goToUrlWithCustomTabConfig(url, conf); - browser.setWindowSize(2000, browser.getWindowSize().height); + await browser.setWindowSize(2500, await getBrowserHeight()); - $('.mainTabs').waitForDisplayed(); + await waitForMainTabs(); assert.equal( - $('=Patient Tab').isDisplayed(), + await (await getElement('=Patient Tab')).isDisplayed(), false, 'We do NOT see hidden tab' ); assert.equal( - $('=Result Tab').isDisplayed(), + await (await getElement('=Result Tab')).isDisplayed(), true, 'We do see showing tab' ); }); - it('Hide property indeed hides custom tab', () => { + it('Hide property indeed hides custom tab', async () => { const conf = [ { title: 'Hidden Tab', @@ -141,26 +169,26 @@ function runTests(pageName, url, tabLocation) { }, ]; - goToUrlWithCustomTabConfig(url, conf); + await goToUrlWithCustomTabConfig(url, conf); - browser.setWindowSize(2000, browser.getWindowSize().height); + await browser.setWindowSize(2000, Number(await getBrowserHeight())); - $('.mainTabs').waitForDisplayed(); + await waitForMainTabs(); assert.equal( - $('=Hidden Tab').isDisplayed(), + await (await getElement('=Hidden Tab')).isDisplayed(), false, 'We do NOT see hidden tab' ); assert.equal( - $('=Showing Tab').isDisplayed(), + await (await getElement('=Showing Tab')).isDisplayed(), true, 'We do see showing tab' ); }); - it('Routing directly to conditional tab forces it to show', () => { + it('Routing directly to conditional tab forces it to show', async () => { const conf = [ { title: 'Async Tab', @@ -188,33 +216,46 @@ function runTests(pageName, url, tabLocation) { }, ]; - goToUrlWithCustomTabConfig(url.replace(/\?/, '/customTab1?'), conf); + await goToUrlWithCustomTabConfig( + url.replace(/\?/, '/customTab1?'), + conf + ); + await waitForMainTabs(); - $('.mainTabs').waitForDisplayed(); + // TODO: why are we assert + assert.equal( + await ( + await getElement('[data-test=LoadingIndicator]', { + timeout: 5000, + }) + ).isDisplayed(), + true, + 'tab loading indicator is showing' + ); + // TODO: this is not a quality test // when we are directly routed to tab // the navigation tab button DOES show // even though hideAsync is still pending - assert.equal( - $('=Async Tab').isDisplayed(), - true, - 'We see pending custom tab button when routed to it' - ); assert.equal( - $('[data-test=LoadingIndicator]').isDisplayed(), + await ( + await getElement('=Async Tab', { + timeout: 5000, + }) + ).isDisplayed(), true, - 'tab loading indicator is showing' + 'We see pending custom tab button when routed to it' ); assert.equal( - $('=Async Tab 2').isDisplayed(), + await (await getElement('=Async Tab 2')).isDisplayed(), false, 'We do not see the second custom tab button' ); }); - it('Remounts tab only when tracked url param changes (part of hash in url wrapper)', function() { + it('Remounts tab only when tracked url param changes (part of hash in url wrapper)', async () => { const conf = [ { title: 'Async Tab', @@ -231,39 +272,49 @@ function runTests(pageName, url, tabLocation) { }, ]; - goToUrlWithCustomTabConfig(url, conf); + await goToUrlWithCustomTabConfig(url, conf); + + await waitForMainTabs(); - browser.setWindowSize(1600, browser.getWindowSize().height); + await browser.setWindowSize(2000, await getBrowserHeight()); - browser.execute(() => { - window.renderCustomTab1 = function(div, tab) { + await browser.execute(() => { + window.renderCustomTab1 = div => { $(div).append(`
First render
`); }; }); // offset to avoid overlapping elements - $('=Async Tab').click(); + await clickElement('=Async Tab'); - browser.pause(1000); + await browser.pause(1000); - assert($('div=First render').isDisplayed()); + assert(await (await getElement('div=First render')).isDisplayed()); // redefine custom tab render // so we can see when it's called - browser.execute(() => { - window.renderCustomTab1 = function(div, tab) { + await browser.execute(() => { + window.renderCustomTab1 = function(div, _tab) { $(div).append(`
Second render
`); }; }); + await browser.pause(2000); + // switch to new tab and then back - $$('.mainTabs .tabAnchor')[0].click(); - $('=Async Tab').click(); + await clickElement('.mainTabs .tabAnchor'); + await clickElement('=Async Tab'); + + const render1 = await ( + await getElement('div=First render') + ).isDisplayed(); + const render2 = await ( + await getElement('div=Second render') + ).isDisplayed(); // we haven't re-mounted the tab assert( - $('div=First render').isDisplayed() && - !$('div=Second render').isDisplayed(), + !render2 && render1, "merely switching tabs didn't call mount function" ); @@ -279,33 +330,37 @@ function runTests(pageName, url, tabLocation) { // kinda annoying, i know switch (tabLocation) { case 'RESULTS_PAGE': - browser.execute(() => { + await browser.execute(() => { window.urlWrapper.updateRoute({ gene_list: 'BRAF KRAS', }); }); break; case 'PATIENT_PAGE': - $('.nextPageBtn').isDisplayed() && - $('.nextPageBtn').click(); + await (await getElement('.nextPageBtn')).isDisplayed(); + await clickElement('.nextPageBtn'); break; case 'COMPARISON_PAGE': - $("[data-test='groupSelectorButtonMSI/CIMP']").click(); + await clickElement( + "[data-test='groupSelectorButtonMSI/CIMP']" + ); break; case 'STUDY_PAGE': // For study page, I do not see a way to evoke a remount (eg. by changing query params) break; } - $('div=Second render').waitForDisplayed(); + await browser.pause(2000); + + await (await getElement('div=Second render')).waitForDisplayed(); assert( - $('div=Second render').isDisplayed(), + await (await getElement('div=Second render')).isDisplayed(), 'changing query causes custom tab to remount' ); }); }); -} +}; const resultsUrl = `${CBIOPORTAL_URL}/results?cancer_study_list=coadread_tcga_pub&cancer_study_id=coadread_tcga_pub&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&Z_SCORE_THRESHOLD=2.0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF`; @@ -345,63 +400,70 @@ describe('Patient Cohort View Custom Tab Tests', () => { }, ]; - it('Navigating between patients changes tab contents', function() { + it('Navigating between patients changes tab contents', async function() { this.retries(0); - goToUrlWithCustomTabConfig(patientUrl, conf); + await goToUrlWithCustomTabConfig(patientUrl, conf); - $('a=Summary').waitForDisplayed(); + await (await getElement('a=Summary')).waitForDisplayed(); - const asyncExists = $('a=Async Tab').isExisting(); + const asyncExists = await ( + await getElement('a=Async Tab') + ).isExisting(); if (asyncExists) { assert.fail("Async exists when it shouldn't!"); } - $('=Sync Tab').click(); + await clickElement('=Sync Tab'); assert.equal( - $('div=tab for patient TCGA-AP-A053').isDisplayed(), + await ( + await getElement('div=tab for patient TCGA-AP-A053') + ).isDisplayed(), true, 'We first patient' ); - browser.pause(11000); + await browser.pause(11000); assert.equal( - $('=Async Tab').isDisplayed(), + await (await getElement('=Async Tab')).isDisplayed(), true, 'Async tab has showed up' ); - $('.nextPageBtn').click(); + await clickElement('.nextPageBtn'); - $('.mainTabs').waitForDisplayed(); + await (await getElement('.mainTabs')).waitForDisplayed(); assert.equal( - $('=Async Tab').isDisplayed(), + await (await getElement('=Async Tab')).isDisplayed(), false, 'Async is hidden again (pending)' ); assert.equal( - $('div=tab for patient TCGA-BG-A0M8').isDisplayed(), + await ( + await getElement('div=tab for patient TCGA-BG-A0M8') + ).isDisplayed(), true, 'We see next patient' ); - $('.prevPageBtn').waitForDisplayed(); + await (await getElement('.prevPageBtn')).waitForDisplayed(); - $('.prevPageBtn').click(); + await clickElement('.prevPageBtn'); - $('div=tab for patient TCGA-AP-A053').waitForDisplayed(); + await ( + await getElement('div=tab for patient TCGA-AP-A053') + ).waitForDisplayed(); }); }); -runTests('ResultsView', resultsUrl, 'RESULTS_PAGE'); - -runTests('StudyView', studyUrl, 'STUDY_PAGE'); - -runTests('PatientView', patientUrl, 'PATIENT_PAGE'); - -runTests('ComparisonPage', comparisonUrl, 'COMPARISON_PAGE'); +describe('It runs test for the respective Tab views', async () => { + await runTests('ResultsView', resultsUrl, 'RESULTS_PAGE'); + await runTests('StudyView', studyUrl, 'STUDY_PAGE'); + await runTests('PatientView', patientUrl, 'PATIENT_PAGE'); + await runTests('ComparisonPage', comparisonUrl, 'COMPARISON_PAGE'); +}); diff --git a/end-to-end-test/remote/specs/core/expressionComparison.spec.js b/end-to-end-test/remote/specs/core/expressionComparison.spec.js index 5a684844ddc..f93e5054185 100644 --- a/end-to-end-test/remote/specs/core/expressionComparison.spec.js +++ b/end-to-end-test/remote/specs/core/expressionComparison.spec.js @@ -1,35 +1,27 @@ -var assert = require('assert'); -var expect = require('chai').expect; +const assert = require('assert'); -var { +const { + getElement, goToUrlAndSetLocalStorage, - clickQueryByGeneButton, - useExternalFrontend, - useNetlifyDeployPreview, - setInputText, - waitForNumberOfStudyCheckboxes, - clickModifyStudySelectionButton, - waitForOncoprint, - setDropdownOpen, - jq, waitForNetworkQuiet, getElementByTestHandle, setServerConfiguration, -} = require('../../../shared/specUtils'); + clickElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -var searchInputSelector = 'div[data-test=study-search] input[type=text]'; - -function expressionDataAvailable() { - return $( - 'span=mRNA Expression. Select one of the profiles below:' +const expressionDataAvailable = async () => { + return ( + await getElement( + 'span=mRNA Expression. Select one of the profiles below:' + ) ).isExisting(); -} +}; describe('plots tab expression data with rule configuration', function() { - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); setServerConfiguration({ enable_cross_study_expression: ` @@ -38,50 +30,62 @@ describe('plots tab expression data with rule configuration', function() { }); }); - it('For multi study query, if all studies are pan_can then we CAN compare expression in plots', () => { + it('For multi study query, if all studies are pan_can then we CAN compare expression in plots', async () => { const url = `/results/plots?cancer_study_list=acc_tcga_pan_can_atlas_2018%2Cchol_tcga_pan_can_atlas_2018&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cstructural_variants%2Cgistic&case_set_id=all&gene_list=CDKN2A%2520MDM2&geneset_list=%20&tab_index=tab_visualize&Action=Submit`; - goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); - waitForNetworkQuiet(); - $('.Select-arrow-zone').click(); - $('.Select-option').waitForExist(); - $('.Select-option=mRNA').isExisting(); + await waitForNetworkQuiet(); + await clickElement('.Select-arrow-zone'); + await (await getElement('.Select-option')).waitForExist(); + await (await getElement('.Select-option=mRNA')).isExisting(); assert.equal( - $( - 'div=Expression data cannot be compared across the selected studies.' + await ( + await getElement( + 'div=Expression data cannot be compared across the selected studies.' + ) ).isExisting(), false ); }); - it('For multi study query that is NOT all pan_can, no expression data in plots', () => { + it('For multi study query that is NOT all pan_can, no expression data in plots', async () => { const url = `/results/plots?cancer_study_list=acc_tcga_pan_can_atlas_2018%2Cchol_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cstructural_variants%2Cgistic&case_set_id=all&gene_list=CDKN2A%2520MDM2&geneset_list=%20&tab_index=tab_visualize&Action=Submit`; - goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); - waitForNetworkQuiet(); - $('.Select-arrow-zone').click(); - $('.Select-option=Mutation').waitForExist(); - assert.equal($('.Select-option=mRNA').isExisting(), false); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); + await waitForNetworkQuiet(); + await clickElement('.Select-arrow-zone'); + await (await getElement('.Select-option=Mutation')).waitForExist(); + assert.equal( + await (await getElement('.Select-option=mRNA')).isExisting(), + false + ); assert.equal( - $( - 'div=Expression data cannot be compared across the selected studies.' + await ( + await getElement( + 'div=Expression data cannot be compared across the selected studies.' + ) ).isExisting(), true ); }); - it('For single study, NOT pan_can, there is expression available in plots', () => { + it('For single study, NOT pan_can, there is expression available in plots', async () => { const url = `/results/plots?cancer_study_list=chol_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cstructural_variants%2Cgistic&case_set_id=all&gene_list=CDKN2A%2520MDM2&geneset_list=%20&tab_index=tab_visualize&Action=Submit`; - goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); - waitForNetworkQuiet(); - $('.Select-arrow-zone').click(); - $('.Select-option=Mutation').waitForExist(); - assert.equal($('.Select-option=mRNA').isExisting(), true); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); + await waitForNetworkQuiet(); + await clickElement('.Select-arrow-zone'); + await (await getElement('.Select-option=Mutation')).waitForExist(); + assert.equal( + await (await getElement('.Select-option=mRNA')).isExisting(), + true + ); assert.equal( - $( - 'div=Expression data cannot be compared across the selected studies.' + await ( + await getElement( + 'div=Expression data cannot be compared across the selected studies.' + ) ).isExisting(), false ); @@ -89,36 +93,41 @@ describe('plots tab expression data with rule configuration', function() { }); describe('plots tab expression data without rule configuration', function() { - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); setServerConfiguration({ enable_cross_study_expression: undefined, }); }); - it('for multi study query that is NOT all pan_can, expression data is NOT available in plots', () => { + it('for multi study query that is NOT all pan_can, expression data is NOT available in plots', async () => { const url = `/results/plots?cancer_study_list=acc_tcga_pan_can_atlas_2018%2Cchol_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&profileFilter=mutations%2Cstructural_variants%2Cgistic&case_set_id=all&gene_list=CDKN2A%2520MDM2&geneset_list=%20&tab_index=tab_visualize&Action=Submit`; - goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); - waitForNetworkQuiet(); + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL + url); + await waitForNetworkQuiet(); - browser.execute(() => { + await browser.execute(() => { window.globalStores.appStore.serverConfig.enable_cross_study_expression = undefined; }); - $('.Select-arrow-zone').click(); - $('.Select-option=Mutation').waitForExist(); - assert.equal($('.Select-option=mRNA').isExisting(), false); + await clickElement('.Select-arrow-zone'); + await (await getElement('.Select-option=Mutation')).waitForExist(); + assert.equal( + await (await getElement('.Select-option=mRNA')).isExisting(), + false + ); - $( - 'div=Expression data cannot be compared across the selected studies.' + await ( + await getElement( + 'div=Expression data cannot be compared across the selected studies.' + ) ).isExisting(); }); }); describe('expression data in query form', function() { - beforeEach(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); setServerConfiguration({ enable_cross_study_expression: ` @@ -126,105 +135,90 @@ describe('expression data in query form', function() { `, }); - waitForNetworkQuiet(); + await waitForNetworkQuiet(); }); after(() => { setServerConfiguration({}); }); - it('For single study with expression data, we can see expression data', () => { - $('.studyItem_sarc_tcga_pub').click(); - getElementByTestHandle('queryByGeneButton').click(); - assert.equal(expressionDataAvailable(), true); + it('For single study with expression data, we can see expression data', async () => { + await clickElement('.studyItem_sarc_tcga_pub'); + await clickElement('[data-test="queryByGeneButton"]'); + assert.equal(await expressionDataAvailable(), true); }); - it("For single study without expression data, we AREN'T offered expression data", () => { - $('.studyItem_chol_nccs_2013').click(); - - getElementByTestHandle('queryByGeneButton').click(); - assert.equal(expressionDataAvailable(), false); + it("For single study without expression data, we AREN'T offered expression data", async () => { + await clickElement('.studyItem_chol_nccs_2013'); + await clickElement('[data-test="queryByGeneButton"]'); + assert.equal(await expressionDataAvailable(), false); }); - it("For two studies with expression data (only one pancan) we AREN'T offered expression data", () => { - $('.studyItem_sarc_tcga_pub').click(); - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), false); + it("For two studies with expression data (only one pancan) we AREN'T offered expression data", async () => { + await clickElement('.studyItem_sarc_tcga_pub'); + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await clickElement('[data-test="queryByGeneButton"]'); + assert.equal(await expressionDataAvailable(), false); }); - it('For two studies (both pan can) with expression data we ARE offered expression data', () => { - $('.studyItem_brca_tcga_pan_can_atlas_2018').click(); - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), true); + it('For two studies (both pan can) with expression data we ARE offered expression data', async () => { + await clickElement('.studyItem_brca_tcga_pan_can_atlas_2018'); + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), true); }); }); describe('cross study expression data without configuration rule', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); - browser.execute(() => { + await browser.execute(() => { window.globalStores.appStore.serverConfig.enable_cross_study_expression = undefined; }); }); - it('without configuration rule, no multi study expression', () => { - $('.studyItem_brca_tcga_pan_can_atlas_2018').click(); - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), false); + it('without configuration rule, no multi study expression', async () => { + await clickElement('.studyItem_brca_tcga_pan_can_atlas_2018'); + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), false); }); - it('without configuration rule, single study expression available', () => { - $('.studyItem_brca_tcga_pan_can_atlas_2018').click(); - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), false); + it('without configuration rule, single study expression available', async () => { + await clickElement('.studyItem_brca_tcga_pan_can_atlas_2018'); + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), false); }); }); describe('custom expression comparison rule', () => { - beforeEach(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); + beforeEach(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); setServerConfiguration({ enable_cross_study_expression: '(studies)=>studies.filter(s=>/gbm_cptac_2021/.test(s.studyId)).length > 0', }); }); - it('with all pancan, expression NOT available', () => { - $('.studyItem_brca_tcga_pan_can_atlas_2018').click(); - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), false); + it('with all pancan, expression NOT available', async () => { + await clickElement('.studyItem_brca_tcga_pan_can_atlas_2018'); + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), false); }); - it('configuration rule is satisfied and expression available across study', () => { - $('.studyItem_chol_tcga').click(); - $('.studyItem_gbm_cptac_2021').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), true); + it('configuration rule is satisfied and expression available across study', async () => { + await clickElement('.studyItem_chol_tcga'); + await clickElement('.studyItem_gbm_cptac_2021'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), true); }); - it('single study still has expression despite rule', () => { - $('.studyItem_chol_tcga_pan_can_atlas_2018').click(); - - getElementByTestHandle('queryByGeneButton').click(); - - assert.equal(expressionDataAvailable(), true); + it('single study still has expression despite rule', async () => { + await clickElement('.studyItem_chol_tcga_pan_can_atlas_2018'); + await (await getElementByTestHandle('queryByGeneButton')).click(); + assert.equal(await expressionDataAvailable(), true); }); }); diff --git a/end-to-end-test/remote/specs/core/genomicEvolution.spec.js b/end-to-end-test/remote/specs/core/genomicEvolution.spec.js index a3fec01b55d..b743ef544fa 100644 --- a/end-to-end-test/remote/specs/core/genomicEvolution.spec.js +++ b/end-to-end-test/remote/specs/core/genomicEvolution.spec.js @@ -1,66 +1,73 @@ -var assert = require('assert'); -const { getElementByTestHandle } = require('../../../shared/specUtils'); -var expect = require('chai').expect; -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var checkOncoprintElement = require('../../../shared/specUtils') - .checkOncoprintElement; -var waitForNetworkQuiet = require('../../../shared/specUtils') - .waitForNetworkQuiet; -var assertScreenShotMatch = require('../../../shared/lib/testUtils') - .assertScreenShotMatch; +const assert = require('assert'); +const { + goToUrlAndSetLocalStorage, + getElementByTestHandle, + waitForNetworkQuiet, + getElement, + getText, + clickElement, +} = require('../../../shared/specUtils_Async'); + const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('Patient View Genomic Evolution tab', function() { describe('mutation table', () => { - it('shows only highlighted, or all mutations, depending on setting', () => { - goToUrlAndSetLocalStorage( + it('shows only highlighted, or all mutations, depending on setting', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/patient/genomicEvolution?caseId=P04&studyId=lgg_ucsf_2014` ); - waitForNetworkQuiet(10000); + await waitForNetworkQuiet(10000); // at first, showing all mutations - $('input[data-test="TableShowOnlyHighlighted"]').waitForExist({ + await getElement('input[data-test="TableShowOnlyHighlighted"]', { timeout: 3000, }); assert( - !$('input[data-test="TableShowOnlyHighlighted"]').isSelected() + !(await ( + await getElement( + 'input[data-test="TableShowOnlyHighlighted"]' + ) + ).isSelected()) ); // at first, more than 2 mutations (making this ambiguous to be unaffected by data changes - $( - 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' + await ( + await getElement( + 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' + ) ).waitForExist(); - let numMutationsText = $( + let numMutationsText = await getText( 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' - ).getText(); + ); let numMutations = parseInt(numMutationsText, 10); assert(numMutations > 2); // now select two mutations - $( + await clickElement( 'div[data-test="GenomicEvolutionMutationTable"] table tbody > tr:nth-child(1)' - ).click(); - $( + ); + await clickElement( 'div[data-test="GenomicEvolutionMutationTable"] table tbody > tr:nth-child(4)' - ).click(); + ); // should still show all - $( - 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' + await ( + await getElement( + 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' + ) ).waitForExist(); - numMutationsText = $( + numMutationsText = await getText( 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' - ).getText(); + ); numMutations = parseInt(numMutationsText, 10); assert(numMutations > 2); // now select "show only highlighted" - $('input[data-test="TableShowOnlyHighlighted"]').click(); - browser.waitUntil( - () => { - numMutationsText = $( + await clickElement('input[data-test="TableShowOnlyHighlighted"]'); + await browser.waitUntil( + async () => { + numMutationsText = await getText( 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' - ).getText(); + ); numMutations = parseInt(numMutationsText, 10); return numMutations === 2; }, @@ -69,14 +76,14 @@ describe('Patient View Genomic Evolution tab', function() { ); // now click on one of the 2 mutations - $( + await clickElement( 'div[data-test="GenomicEvolutionMutationTable"] table tbody > tr:nth-child(1)' - ).click(); - browser.waitUntil( - () => { - numMutationsText = $( + ); + await browser.waitUntil( + async () => { + numMutationsText = await getText( 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' - ).getText(); + ); numMutations = parseInt(numMutationsText, 10); return numMutations === 1; }, @@ -85,14 +92,14 @@ describe('Patient View Genomic Evolution tab', function() { ); // now click on the last remaining mutation - $( + await clickElement( 'div[data-test="GenomicEvolutionMutationTable"] table tbody > tr:nth-child(1)' - ).click(); - browser.waitUntil( - () => { - numMutationsText = $( + ); + await browser.waitUntil( + async () => { + numMutationsText = await getText( 'div[data-test="GenomicEvolutionMutationTable"] span[data-test="LazyMobXTable_CountHeader"]' - ).getText(); + ); numMutations = parseInt(numMutationsText, 10); return numMutations > 2; }, @@ -101,14 +108,15 @@ describe('Patient View Genomic Evolution tab', function() { ); }); - it('force sequential mode when samples have no equivalent clincal events', () => { - goToUrlAndSetLocalStorage( + it('force sequential mode when samples have no equivalent clincal events', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/patient/genomicEvolution?studyId=nsclc_ctdx_msk_2022&caseId=P-0016223` ); - getElementByTestHandle('VAFChartControls').waitForExist(); assert.equal( - getElementByTestHandle('VAFSequentialMode').isExisting(), + await ( + await getElementByTestHandle('VAFSequentialMode') + ).isExisting(), false, 'SequentialModel Check Box should not exists if not possible.' ); diff --git a/end-to-end-test/remote/specs/core/groupComparison.spec.js b/end-to-end-test/remote/specs/core/groupComparison.spec.js index 98cf7a77c47..ac0378b3063 100644 --- a/end-to-end-test/remote/specs/core/groupComparison.spec.js +++ b/end-to-end-test/remote/specs/core/groupComparison.spec.js @@ -1,7 +1,10 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var { jsApiClick } = require('../../../shared/specUtils'); +const assert = require('assert'); +const { + jsApiClick, + goToUrlAndSetLocalStorage, + getElementByTestHandle, + getElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const SampleCreateGroupButton = @@ -9,118 +12,164 @@ const SampleCreateGroupButton = const PatientCreateGroupButton = 'button[data-test="patientGroupComparisonCreateGroupButton"]'; -describe('group comparison venn diagram tests', function() { - describe('create new group tests', function() { - before(function() { - goToUrlAndSetLocalStorage( +describe('group comparison venn diagram tests', () => { + describe('create new group tests', () => { + before(async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/comparison/overlap?sessionId=5cf6bcf0e4b0ab413787430c` ); - $('div[data-test="ComparisonPageOverlapTabDiv"]').waitForExist({ + await getElement('div[data-test="ComparisonPageOverlapTabDiv"]', { timeout: 20000, }); }); - it('create group button disabled as default', function() { - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('create group button disabled as default', async () => { + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + false + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + false + ); }); - it('select from sample venn diagram', function() { - jsApiClick('rect[data-test="sample0,1VennRegion"]'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('select from sample venn diagram', async () => { + await jsApiClick('rect[data-test="sample0,1VennRegion"]'); + await browser.pause(100); + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + true + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + false + ); }); - it('click sample venn diagram create group button', function() { - $(SampleCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); - browser.pause(100); + it('click sample venn diagram create group button', async () => { + await (await getElement(SampleCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('sample venn diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue( - 'GARS mutant' - ); - browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + it('sample venn diagram: group name exists, should disable submit button', async () => { + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).setValue('GARS mutant'); + await browser.pause(100); + await getElementByTestHandle('sampleDuplicateGroupNameMessage', { timeout: 20000, }); assert.equal( - $('[data-test="sampleDuplicateGroupNameMessage"]').getText(), + await ( + await getElementByTestHandle( + 'sampleDuplicateGroupNameMessage' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('sample venn diagram: new group name, should enable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue('new group'); - browser.pause(100); + it('sample venn diagram: new group name, should enable submit button', async () => { + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), true ); }); - it('select from patient venn diagram', function() { + it('select from patient venn diagram', async () => { // unselect sample venn diagram first - jsApiClick('rect[data-test="sample0,1VennRegion"]'); - jsApiClick('rect[data-test="patient0VennRegion"]'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), true); + await jsApiClick('rect[data-test="sample0,1VennRegion"]'); + await jsApiClick('rect[data-test="patient0VennRegion"]'); + await browser.pause(100); + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + false + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + true + ); }); - it('click patient venn diagram create group button', function() { - $(PatientCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); - browser.pause(100); + it('click patient venn diagram create group button', async () => { + await (await getElement(PatientCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(100); assert.equal( - $('[data-test="patientGroupNameInputField"]').isDisplayed(), + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('patient venn diagram: group name exists, should disable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue( - 'GARS mutant' - ); - browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + it('patient venn diagram: group name exists, should disable submit button', async () => { + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('GARS mutant'); + await browser.pause(100); + await getElementByTestHandle('patientDuplicateGroupNameMessage', { timeout: 20000, }); assert.equal( - $('[data-test="patientDuplicateGroupNameMessage"]').getText(), + await ( + await getElementByTestHandle( + 'patientDuplicateGroupNameMessage' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('patient venn diagram: new group name, should enable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue('new group'); - browser.pause(100); + it('patient venn diagram: new group name, should enable submit button', async () => { + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), true ); }); @@ -129,114 +178,166 @@ describe('group comparison venn diagram tests', function() { describe('group comparison upset diagram tests', function() { describe('create new group tests', function() { - before(function() { - goToUrlAndSetLocalStorage( + before(async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/comparison?sessionId=5d0bc0c5e4b0ab4137876bc3` ); - $('div[data-test="ComparisonPageOverlapTabDiv"]').waitForExist({ + await getElement('div[data-test="ComparisonPageOverlapTabDiv"]', { timeout: 20000, }); }); - it('create group button disabled as default', function() { - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('create group button disabled as default', async () => { + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + false + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + false + ); }); - it('select from sample upset diagram', function() { - jsApiClick('.sample_testGroup2_testGroup3_bar'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('select from sample upset diagram', async () => { + await jsApiClick('.sample_testGroup2_testGroup3_bar'); + await browser.pause(100); + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + true + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + false + ); }); - it('click sample upset diagram create group button', function() { - $(SampleCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); - browser.pause(100); + it('click sample upset diagram create group button', async () => { + await (await getElement(SampleCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('sample upset diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue('testGroup5'); - browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + it('sample upset diagram: group name exists, should disable submit button', async () => { + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).setValue('testGroup5'); + await browser.pause(100); + await getElementByTestHandle('sampleDuplicateGroupNameMessage', { timeout: 20000, }); assert.equal( - $('[data-test="sampleDuplicateGroupNameMessage"]').getText(), + await ( + await getElementByTestHandle( + 'sampleDuplicateGroupNameMessage' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('sample upset diagram: new group name, should enable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue('new group'); - browser.pause(100); + it('sample upset diagram: new group name, should enable submit button', async () => { + await ( + await getElementByTestHandle('sampleGroupNameInputField') + ).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), true ); }); - it('select from patient upset diagram', function() { + it('select from patient upset diagram', async () => { // unselect sample venn diagram first - $('path.sample_testGroup2_testGroup3_bar').click(); - $('path.patient_testGroup3_testGroup4_bar').click(); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), true); + await ( + await getElement('path.sample_testGroup2_testGroup3_bar') + ).click(); + await ( + await getElement('path.patient_testGroup3_testGroup4_bar') + ).click(); + await browser.pause(100); + assert.equal( + await (await getElement(SampleCreateGroupButton)).isEnabled(), + false + ); + assert.equal( + await (await getElement(PatientCreateGroupButton)).isEnabled(), + true + ); }); - it('click patient upset diagram create group button', function() { - $(PatientCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); - browser.pause(100); + it('click patient upset diagram create group button', async () => { + await (await getElement(PatientCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(100); assert.equal( - $('[data-test="patientGroupNameInputField"]').isDisplayed(), + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('patient upset diagram: group name exists, should disable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue( - 'testGroup3' - ); - browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + it('patient upset diagram: group name exists, should disable submit button', async () => { + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('testGroup3'); + await browser.pause(100); + await getElementByTestHandle('patientDuplicateGroupNameMessage', { timeout: 20000, }); assert.equal( - $('[data-test="patientDuplicateGroupNameMessage"]').getText(), + await ( + await getElementByTestHandle( + 'patientDuplicateGroupNameMessage' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('patient upset diagram: new group name, should enable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue('new group'); - browser.pause(100); + it('patient upset diagram: new group name, should enable submit button', async () => { + await ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), true ); }); diff --git a/end-to-end-test/remote/specs/core/oncoprinter.spec.js b/end-to-end-test/remote/specs/core/oncoprinter.spec.js index 50015512f91..f1c95876d54 100644 --- a/end-to-end-test/remote/specs/core/oncoprinter.spec.js +++ b/end-to-end-test/remote/specs/core/oncoprinter.spec.js @@ -1,60 +1,67 @@ -var assert = require('assert'); -var { +const assert = require('assert'); +const { waitForOncoprint, setOncoprintMutationsMenuOpen, goToUrlAndSetLocalStorage, - setInputText, -} = require('../../../shared/specUtils'); + getElement, + isSelected, + clickElement, +} = require('../../../shared/specUtils_Async'); const TIMEOUT = 6000; - -const ONCOPRINT_TIMEOUT = 60000; - const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -describe('oncoprinter tests', function() { +describe('oncoprinter tests', () => { describe('custom driver annotation', () => { - function doTestWithCustomDriver() { - $('.oncoprinterGeneticExampleData').waitForExist(); - $('.oncoprinterGeneticExampleData').click(); - $('.oncoprinterSubmit').click(); - waitForOncoprint(TIMEOUT); + const doTestWithCustomDriver = async () => { + await ( + await getElement('.oncoprinterGeneticExampleData') + ).waitForExist(); + await clickElement('.oncoprinterGeneticExampleData'); + await clickElement('.oncoprinterSubmit'); + await waitForOncoprint(TIMEOUT); - setOncoprintMutationsMenuOpen(true); - assert(!$('input[data-test="annotateOncoKb"]').isSelected()); - assert($('input[data-test="annotateCustomBinary"]').isSelected()); - } + await setOncoprintMutationsMenuOpen(true); + assert(!(await isSelected('input[data-test="annotateOncoKb"]'))); + assert(await isSelected('input[data-test="annotateCustomBinary"]')); + }; - function doTestWithoutCustomDriver() { - $('.oncoprinterGeneticExampleData').waitForExist(); - browser.execute(function(text) { + const doTestWithoutCustomDriver = async () => { + await ( + await getElement('.oncoprinterGeneticExampleData') + ).waitForExist(); + await browser.execute(text => { oncoprinterTool.onGeneticDataInputChange({ currentTarget: { value: text, }, }); }, 'TCGA-25-2392-01 TP53 FUSION FUSION\nTCGA-04-1357-01 BRCA1 Q1538A MISSENSE'); - $('.oncoprinterSubmit').click(); - waitForOncoprint(TIMEOUT); + await clickElement('.oncoprinterSubmit'); + await waitForOncoprint(TIMEOUT); - setOncoprintMutationsMenuOpen(true); - assert($('input[data-test="annotateOncoKb"]').isSelected()); - assert(!$('input[data-test="annotateCustomBinary"]').isExisting()); - } + await setOncoprintMutationsMenuOpen(true); + assert(await isSelected('input[data-test="annotateOncoKb"]')); + assert( + !(await ( + await getElement('input[data-test="annotateCustomBinary"]') + ).isExisting()) + ); + }; - it('only custom driver annotation is selected when input data includes a custom driver', () => { - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); - doTestWithCustomDriver(); + it('only custom driver annotation is selected when input data includes a custom driver', async () => { + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); + await doTestWithCustomDriver(); }); - it('oncokb is selected, and custom driver button hidden, when input data does not include a custom driver', () => { - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); - doTestWithoutCustomDriver(); + it('oncokb is selected, and custom driver button hidden, when input data does not include a custom driver', async () => { + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); + await doTestWithoutCustomDriver(); }); - it('mutation annotation settings reset whenever oncoprint is submitted', () => { - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); - doTestWithCustomDriver(); - $('.oncoprinterModifyInput').click(); - doTestWithoutCustomDriver(); + it('mutation annotation settings reset whenever oncoprint is submitted', async () => { + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/oncoprinter`); + await doTestWithCustomDriver(); + await clickElement('.oncoprinterModifyInput'); + await doTestWithoutCustomDriver(); }); }); }); diff --git a/end-to-end-test/remote/specs/core/patient.logic.spec.js b/end-to-end-test/remote/specs/core/patient.logic.spec.js index 7ef0ed035f0..19ad9327ce5 100644 --- a/end-to-end-test/remote/specs/core/patient.logic.spec.js +++ b/end-to-end-test/remote/specs/core/patient.logic.spec.js @@ -1,31 +1,32 @@ -var assert = require('assert'); - -var { +const { goToUrlAndSetLocalStorage, getElementByTestHandle, -} = require('../../../shared/specUtils'); + getElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -describe('patient page', function() { - before(() => { - goToUrlAndSetLocalStorage(CBIOPORTAL_URL); +describe('patient page', () => { + before(async () => { + await goToUrlAndSetLocalStorage(CBIOPORTAL_URL); }); - it('should show "all samples button" for single sample view of multi sample patient', function() { - goToUrlAndSetLocalStorage( + it('should show "all samples button" for single sample view of multi sample patient', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/patient?studyId=lgg_ucsf_2014&tab=summaryTab&sampleId=P04_Pri` ); - $('button=Show all 4 samples').waitForExist(); + await (await getElement('button=Show all 4 samples')).waitForExist(); }); - it('show appropriate messaging when a patient has only some profiled samples', () => { - goToUrlAndSetLocalStorage( + it('show appropriate messaging when a patient has only some profiled samples', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/patient?studyId=mpcproject_broad_2021&caseId=MPCPROJECT_0013` ); // there is one partial profile message for CNA and sample 2 - getElementByTestHandle('patientview-mutation-table').waitForDisplayed(); + await ( + await getElementByTestHandle('patientview-mutation-table') + ).waitForDisplayed(); }); }); diff --git a/end-to-end-test/remote/specs/core/plots.spec.js b/end-to-end-test/remote/specs/core/plots.spec.js index 2c90c1d4038..a767c3e6466 100644 --- a/end-to-end-test/remote/specs/core/plots.spec.js +++ b/end-to-end-test/remote/specs/core/plots.spec.js @@ -1,67 +1,78 @@ -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var assert = require('assert'); +const assert = require('assert'); const { getElementByTestHandle, waitForPlotsTab, getTextFromElement, -} = require('../../../shared/specUtils'); + goToUrlAndSetLocalStorage, + getElement, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const METHYLATION_OPTION_SELECTION_BOX = 'div.genericAssaySelectBox'; describe('plots tab tests', function() { - it('shows data availability alert tooltip for plots tab multiple studies', () => { - goToUrlAndSetLocalStorage( + it('shows data availability alert tooltip for plots tab multiple studies', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=lgg_ucsf_2014%2Cbrca_tcga&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&plots_coloring_selection=%7B%7D&plots_horz_selection=%7B"selectedGeneOption"%3A7157%2C"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"CANCER_TYPE_DETAILED"%7D&plots_vert_selection=%7B"selectedGeneOption"%3A7157%2C"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"CANCER_TYPE"%7D&profileFilter=0&tab_index=tab_visualize` ); - $('div[data-test="PlotsTabPlotDiv"]').waitForDisplayed({ + await ( + await getElement('div[data-test="PlotsTabPlotDiv"]') + ).waitForDisplayed({ timeout: 20000, }); // Tooltip elements are created when hovering the data availability alert info icon. // Control logic below is needed to access the last one after it // was created. - var curNumToolTips = $$('div.rc-tooltip-inner').length; - $("[data-test='dataAvailabilityAlertInfoIcon']").moveTo(); - browser.waitUntil( - () => $$('div.rc-tooltip-inner').length > curNumToolTips + const curNumToolTips = (await $$('div.rc-tooltip-inner')).length; + await ( + await getElementByTestHandle('dataAvailabilityAlertInfoIcon') + ).moveTo(); + await browser.waitUntil( + async () => + (await $$('div.rc-tooltip-inner')).length > curNumToolTips ); - var toolTips = $$('div.rc-tooltip-inner'); - var text = toolTips[toolTips.length - 1].getText(); + const toolTips = await $$('div.rc-tooltip-inner'); + const text = await toolTips[toolTips.length - 1].getText(); assert.equal( text, 'Data availability per profile/axis:\nHorizontal Axis: 1164 samples from 2 studies\nVertical Axis: 1164 samples from 2 studies\nIntersection of the two axes: 1164 samples from 2 studies' ); }); - it('logscale available for all raw data types that are number', () => { - goToUrlAndSetLocalStorage( + it('logscale available for all raw data types that are number', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/plots?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=lgg_ucsf_2014%2Cbrca_tcga&case_set_id=all&data_priority=0&gene_list=TP53&geneset_list=%20&plots_coloring_selection=%7B%7D&plots_horz_selection=%7B"selectedGeneOption"%3A7157%2C"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"TMB_NONSYNONYMOUS"%2C"logScale"%3A"false"%7D&plots_vert_selection=%7B"selectedGeneOption"%3A7157%2C"dataType"%3A"clinical_attribute"%2C"selectedDataSourceOption"%3A"CANCER_TYPE"%7D&profileFilter=0&tab_index=tab_visualize` ); - $('div[data-test="PlotsTabPlotDiv"]').waitForDisplayed({ + await getElement('div[data-test="PlotsTabPlotDiv"]', { timeout: 20000, }); assert.equal( - getElementByTestHandle('HorizontalLogCheckbox').isExisting(), + await ( + await getElementByTestHandle('HorizontalLogCheckbox') + ).isExisting(), true ); assert.equal( - getElementByTestHandle('VerticalLogCheckbox').isExisting(), + await ( + await getElementByTestHandle('VerticalLogCheckbox') + ).isExisting(), false, 'Log Scale Checkbox should not be availble raw data type is not number' ); }); - it('plots tab select gene related generic assay default option', () => { - goToUrlAndSetLocalStorage( + it('plots tab select gene related generic assay default option', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/plots?cancer_study_list=acc_tcga_pan_can_atlas_2018&tab_index=tab_visualize&case_set_id=acc_tcga_pan_can_atlas_2018_all&Action=Submit&gene_list=TP53&plots_horz_selection=%7B%22dataType%22%3A%22METHYLATION%22%7D&plots_vert_selection=%7B%22selectedGeneOption%22%3A7157%7D&plots_coloring_selection=%7B%7D` ); - waitForPlotsTab(); - $(METHYLATION_OPTION_SELECTION_BOX).waitForDisplayed({ + await waitForPlotsTab(); + await ( + await getElement(METHYLATION_OPTION_SELECTION_BOX) + ).waitForDisplayed({ timeout: 20000, }); assert( - getTextFromElement(METHYLATION_OPTION_SELECTION_BOX) === + (await getTextFromElement(METHYLATION_OPTION_SELECTION_BOX)) === "TP53;WRAP53 (cg06587969): TSS1500;5'UTR;1stExon" ); }); diff --git a/end-to-end-test/remote/specs/core/quickSearch.spec.js b/end-to-end-test/remote/specs/core/quickSearch.spec.js index b27e3d24ae8..d92eb08e254 100644 --- a/end-to-end-test/remote/specs/core/quickSearch.spec.js +++ b/end-to-end-test/remote/specs/core/quickSearch.spec.js @@ -1,70 +1,89 @@ -var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; +const assert = require('assert'); +const { + clickElement, + getElement, + goToUrlAndSetLocalStorage, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); describe('Quick Search', () => { - before(function() { - goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`); + before(async () => { + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`); }); - beforeEach(() => { - var url = `${CBIOPORTAL_URL}`; - goToUrlAndSetLocalStorage(url); - $('strong=Beta!').click(); - $('div=e.g. Lung, EGFR, TCGA-OR-A5J2').waitForExist(); - $('div=e.g. Lung, EGFR, TCGA-OR-A5J2').click(); + beforeEach(async () => { + const url = `${CBIOPORTAL_URL}`; + await goToUrlAndSetLocalStorage(url); + await clickElement('strong=Beta!'); + await ( + await getElement('div=e.g. Lung, EGFR, TCGA-OR-A5J2') + ).waitForExist(); + await clickElement('div=e.g. Lung, EGFR, TCGA-OR-A5J2'); // "BRAF" is nice because it matches studies, genes, patients, and samples - $('input').setValue('Ad'); - $('div=Click on a study to open its summary').waitForExist(); - $('div=Click on a patient to see a summary').waitForExist(); - $('div=Click on a sample to open its summary').waitForExist(); + await (await getElement('input')).setValue('Ad'); + await ( + await getElement('div=Click on a study to open its summary') + ).waitForExist(); + await ( + await getElement('div=Click on a patient to see a summary') + ).waitForExist(); + await ( + await getElement('div=Click on a sample to open its summary') + ).waitForExist(); }); - it('should give results for studies', () => { - $('strong=Adrenocortical Carcinoma (TCGA, Firehose Legacy)').click(); - $('h3=Adrenocortical Carcinoma (TCGA, Firehose Legacy)').waitForExist(); + it('should give results for studies', async () => { + await clickElement( + 'strong=Adrenocortical Carcinoma (TCGA, Firehose Legacy)' + ); + await ( + await getElement( + 'h3=Adrenocortical Carcinoma (TCGA, Firehose Legacy)' + ) + ).waitForExist(); assert.equal( - $( - 'h3=Adrenocortical Carcinoma (TCGA, Firehose Legacy)' + await ( + await getElement( + 'h3=Adrenocortical Carcinoma (TCGA, Firehose Legacy)' + ) ).isDisplayed(), true, 'modal is visible' ); }); - it('should give results for genes', () => { - $('strong=454 more genes (click to load 20 more)').click(); - $('strong=ADAM12').waitForExist(); - $('strong=ADAM15').click(); - $('a=ADAM15').waitForExist({ timeout: 60000 }); + it('should give results for genes', async () => { + await clickElement('strong=454 more genes (click to load 20 more)'); + await (await getElement('strong=ADAM12')).waitForExist(); + await clickElement('strong=ADAM15'); + await (await getElement('a=ADAM15')).waitForExist({ timeout: 60000 }); assert.equal( - $('a=ADAM15').isDisplayed(), + await (await getElement('a=ADAM15')).isDisplayed(), true, 'we navigated successfully to gene query' ); }); - it('should give results for patients', () => { - $('strong=AdCC11T').click(); - $('a=AdCC11T').waitForExist(); + it('should give results for patients', async () => { + await clickElement('strong=AdCC11T'); + await (await getElement('a=AdCC11T')).waitForExist(); assert.equal( - $('a=AdCC11T').isDisplayed(), + await (await getElement('a=AdCC11T')).isDisplayed(), true, 'navigated to patient' ); }); - it('should give results for samples', () => { - $('strong=AdCC11T').click(); - $('a=AdCC11T').waitForExist(); + it('should give results for samples', async () => { + await clickElement('strong=AdCC11T'); + await (await getElement('a=AdCC11T')).waitForExist(); assert.equal( - $('a=AdCC11T').isDisplayed(), + await (await getElement('a=AdCC11T')).isDisplayed(), true, 'navigated to patient' ); diff --git a/end-to-end-test/remote/specs/core/redirect.spec.js b/end-to-end-test/remote/specs/core/redirect.spec.js index 0c3f9963f5b..c12c494f638 100644 --- a/end-to-end-test/remote/specs/core/redirect.spec.js +++ b/end-to-end-test/remote/specs/core/redirect.spec.js @@ -1,7 +1,7 @@ const { waitForOncoprint, goToUrlAndSetLocalStorage, -} = require('../../../shared/specUtils'); +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); @@ -9,10 +9,10 @@ describe('/encodedRedirect', () => { // TODO: for the reslts view gene comparison groups PR, lets add a test // that this handles encoded square brackets - it('correctly redirects to a results view page URL', () => { - goToUrlAndSetLocalStorage( + it('correctly redirects to a results view page URL', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/encodedRedirect?encodedURL=aHR0cHM6Ly93d3cuY2Jpb3BvcnRhbC5vcmcvcmVzdWx0cy9vbmNvcHJpbnQ/Wl9TQ09SRV9USFJFU0hPTEQ9Mi4wJmNhbmNlcl9zdHVkeV9pZD1jb2FkcmVhZF90Y2dhX3B1YiZjYW5jZXJfc3R1ZHlfbGlzdD1jb2FkcmVhZF90Y2dhX3B1YiZjYXNlX3NldF9pZD1jb2FkcmVhZF90Y2dhX3B1Yl9ub25oeXBlcm11dCZnZW5lX2xpc3Q9S1JBUyUyME5SQVMlMjBCUkFGJmdlbmVfc2V0X2Nob2ljZT11c2VyLWRlZmluZWQtbGlzdCZnZW5ldGljX3Byb2ZpbGVfaWRzX1BST0ZJTEVfQ09QWV9OVU1CRVJfQUxURVJBVElPTj1jb2FkcmVhZF90Y2dhX3B1Yl9naXN0aWMmZ2VuZXRpY19wcm9maWxlX2lkc19QUk9GSUxFX01VVEFUSU9OX0VYVEVOREVEPWNvYWRyZWFkX3RjZ2FfcHViX211dGF0aW9ucw%3D%3D` ); - waitForOncoprint(); + await waitForOncoprint(); }); }); diff --git a/end-to-end-test/remote/specs/core/results.logic.spec.js b/end-to-end-test/remote/specs/core/results.logic.spec.js index d2ba2ebabf0..76120a25b71 100644 --- a/end-to-end-test/remote/specs/core/results.logic.spec.js +++ b/end-to-end-test/remote/specs/core/results.logic.spec.js @@ -1,7 +1,4 @@ -var assert = require('assert'); -var expect = require('chai').expect; - -const asyncUtils = require('../../../shared/specUtils_Async'); +const assert = require('assert'); const { clickQueryByGeneButton, @@ -9,44 +6,56 @@ const { waitForOncoprint, goToUrlAndSetLocalStorage, getElementByTestHandle, -} = require('../../../shared/specUtils'); + getElement, + clickElement, + getText, + isSelected, + isUnselected, + setInputText, + waitForNetworkQuiet, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -const ONCOPRINT_TIMEOUT = 15000; - const ALL_CASE_SET_REGEXP = /^All \(\d+\)$/; describe('Invalid query handling', () => { - it('shows query form if no genes are submitted', () => { + it('shows query form if no genes are submitted', async () => { const url = `${CBIOPORTAL_URL}/results/oncoprint?cancer_study_list=metastatic_solid_tumors_mich_2017`; - goToUrlAndSetLocalStorage(url); - $('[data-test="studyList"]').waitForDisplayed(); + await goToUrlAndSetLocalStorage(url); + await (await getElementByTestHandle('studyList')).waitForDisplayed(); - assert($('[data-test="studyList"]').isDisplayed()); + assert(await (await getElementByTestHandle('studyList')).isDisplayed()); - const elem = $('.studyItem_metastatic_solid_tumors_mich_2017'); // or $(() => document.getElementById('elem')) - const checkbox = elem.$(function() { + const elem = await getElement( + '.studyItem_metastatic_solid_tumors_mich_2017' + ); // or $(() => document.getElementById('elem')) + const checkbox = await elem.$(function() { return this.previousSibling; }); - assert(checkbox.isSelected(), 'study in url is selected in query form'); + assert( + await checkbox.isSelected(), + 'study in url is selected in query form' + ); }); }); describe('cross cancer query', function() { it('should show cross cancer bar chart be defai;t with TP53 in title when selecting multiple studies and querying for single gene TP53', async function() { - await asyncUtils.goToUrlAndSetLocalStorage( + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/cancerTypesSummary?cancer_study_list=chol_tcga%2Cblca_tcga_pub%2Ccoadread_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&profileFilter=0&case_set_id=all&gene_list=TP53&geneset_list=%20&tab_index=tab_visualize&Action=Submit` ); + await waitForNetworkQuiet(); + // wait for cancer types summary to appear - await asyncUtils.getElementByTestHandle('cancerTypeSummaryChart', { + await getElementByTestHandle('cancerTypeSummaryChart', { timeout: 60000, }); // check if TP53 is in the navigation above the plots - await browser.waitUntil(() => { - return $('.nav-pills*=TP53').isDisplayed(); + await browser.waitUntil(async () => { + return await (await getElement('.nav-pills*=TP53')).isDisplayed(); }); }); }); @@ -56,43 +65,45 @@ describe('single study query', async function() { describe('mutation mapper ', async function() { it('should show somatic and germline mutation rate', async () => { - await asyncUtils.goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`); + await goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}`); - const input = await $('[data-test=study-search] input[type=text]'); + const input = await getElement( + '[data-test=study-search] input[type=text]' + ); await input.waitForExist({ timeout: 10000 }); await input.setValue('ovarian nature 2011'); - await asyncUtils.waitForNumberOfStudyCheckboxes(1); + await waitForNumberOfStudyCheckboxes(1); - await asyncUtils.clickElement('[data-test="StudySelect"] input'); + await clickElement('[data-test="StudySelect"] input'); - await asyncUtils.clickQueryByGeneButton(); + await clickQueryByGeneButton(); // query BRCA1 and BRCA2 - const geneInput = await $('[data-test="geneSet"]'); - geneInput.setValue('BRCA1 BRCA2'); + // const geneInput = await getElementByTestHandle('geneSet'); + // await geneInput.setValue('BRCA1 BRCA2'); - await (await $('[data-test="queryButton"]')).waitForEnabled({ + await setInputText('[data-test="geneSet"]', 'BRCA1 BRCA2'); + + await (await getElementByTestHandle('queryButton')).waitForEnabled({ timeout: 10000, }); - await asyncUtils.clickElement('handle=queryButton', { + await clickElement('handle=queryButton', { timeout: 10000, }); - await asyncUtils.clickElement('a.tabAnchor_mutations', { + await clickElement('a.tabAnchor_mutations', { timeout: 10000, }); - await asyncUtils.clickElement('handle=mutation-rate-summary', { + await clickElement('handle=mutation-rate-summary', { timeout: 6000, }); - const text = await asyncUtils.getText( - '[data-test="mutation-rate-summary"]' - ); + const text = await getText('[data-test="mutation-rate-summary"]'); // check germline mutation rate assert(text.search('8.2%') > -1); @@ -101,15 +112,17 @@ describe('single study query', async function() { }); it('should show lollipop for MUC2', async function() { - await asyncUtils.goToUrlAndSetLocalStorage( + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=cellline_nci60&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=cellline_nci60_cnaseq&gene_list=MUC2&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=cellline_nci60_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=cellline_nci60_cna` ); - await asyncUtils.clickElement('a.tabAnchor_mutations', { + await waitForNetworkQuiet(); + + await clickElement('a.tabAnchor_mutations', { timeout: 10000, }); - await asyncUtils.getElementByTestHandle('LollipopPlot', { + await getElementByTestHandle('LollipopPlot', { timeout: 6000, }); }); @@ -118,12 +131,14 @@ describe('single study query', async function() { describe('enrichments', function() { //this.retries(3) - it('should show mutations plot', function() { - goToUrlAndSetLocalStorage( + it('should show mutations plot', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?cancer_study_id=ov_tcga_pub&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&case_set_id=ov_tcga_pub_cna_seq&gene_list=BRCA1+BRCA2&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ov_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ov_tcga_pub_gistic` ); - $('.comparisonTabSubTabs .tabAnchor_alterations').waitForExist(); + await ( + await getElement('.comparisonTabSubTabs .tabAnchor_alterations') + ).waitForExist(); }); }); }); @@ -132,172 +147,219 @@ describe('results page', function() { this.retries(0); describe('tab hiding', function() { - it('should hide coexpression and cn segment tabs in a query without any data for those tabs', () => { - goToUrlAndSetLocalStorage( + it('should hide coexpression and cn segment tabs in a query without any data for those tabs', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?session_id=5bc64b48498eb8b3d5685af7` ); - waitForOncoprint(); - assert(!$('a.tabAnchor_coexpression').isDisplayed()); - assert(!$('a.tabAnchor_cnSegments').isDisplayed()); + await waitForOncoprint(); + assert( + !(await ( + await getElement('a.tabAnchor_coexpression') + ).isDisplayed()) + ); + assert( + !(await ( + await getElement('a.tabAnchor_cnSegments') + ).isDisplayed()) + ); }); - it('should hide survival tab in a query without any survival data', () => { - goToUrlAndSetLocalStorage( + it('should hide survival tab in a query without any survival data', async () => { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?session_id=5bc64bb5498eb8b3d5685afb` ); - $('div[data-test="ComparisonPageOverlapTabDiv"]').waitForDisplayed({ + await getElement('div[data-test="ComparisonPageOverlapTabDiv"]', { timeout: 20000, }); - assert(!$('a.tabAnchor_survival').isDisplayed()); + assert( + !(await ( + await getElement('a.tabAnchor_survival') + ).isDisplayed()) + ); }); }); describe('mutual exclusivity tab', function() { - it('should appear in a single study query with multiple genes', function() { - goToUrlAndSetLocalStorage( + it('should appear in a single study query with multiple genes', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%2520NRAS%2520BRAF%250APTEN%253A%2520MUT&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic` ); - $('a.tabAnchor_mutualExclusivity').waitForExist({ timeout: 10000 }); + await getElement('a.tabAnchor_mutualExclusivity', { + timeout: 10000, + }); - assert($('a.tabAnchor_mutualExclusivity').isDisplayed()); + assert( + await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed() + ); }); - it('should appear in a multiple study with multiple genes', function() { - goToUrlAndSetLocalStorage( + it('should appear in a multiple study with multiple genes', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=all&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=all&gene_list=KRAS%2520NRAS%2520BRAF%250APTEN%253A%2520MUT&geneset_list=+&tab_index=tab_visualize&Action=Submit&cancer_study_list=coadread_tcga_pub%2Ccellline_nci60%2Cacc_tcga` ); - $('a.tabAnchor_mutualExclusivity').waitForExist({ timeout: 10000 }); + await getElement('a.tabAnchor_mutualExclusivity', { + timeout: 10000, + }); - assert($('a.tabAnchor_mutualExclusivity').isDisplayed()); + assert( + await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed() + ); }); - it('should not appear in a single study query with one gene', function() { - goToUrlAndSetLocalStorage( + it('should not appear in a single study query with one gene', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%253A%2520MUT&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic` ); - waitForOncoprint(); - assert(!$('a.tabAnchor_mutualExclusivity').isDisplayed()); + await waitForOncoprint(); + assert( + !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()) + ); - goToUrlAndSetLocalStorage( + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic` ); - waitForOncoprint(); - assert(!$('a.tabAnchor_mutualExclusivity').isDisplayed()); + await waitForOncoprint(); + assert( + !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()) + ); }); - it('should not appear in a multiple study query with one gene', function() { - goToUrlAndSetLocalStorage( + it('should not appear in a multiple study query with one gene', async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=all&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=all&gene_list=KRAS&geneset_list=+&tab_index=tab_visualize&Action=Submit&cancer_study_list=coadread_tcga_pub%2Ccellline_nci60%2Cacc_tcga` ); - $('a.tabAnchor_oncoprint').waitForExist({ timeout: 10000 }); - browser.waitUntil(function() { - return !$('a.tabAnchor_mutualExclusivity').isDisplayed(); + await getElement('a.tabAnchor_oncoprint', { timeout: 10000 }); + await browser.waitUntil(async function() { + return !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()); }); - assert(!$('a.tabAnchor_mutualExclusivity').isDisplayed()); - goToUrlAndSetLocalStorage( + assert( + !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()) + ); + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/index.do?cancer_study_id=all&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=all&gene_list=KRAS%253A%2520MUT&geneset_list=+&tab_index=tab_visualize&Action=Submit&cancer_study_list=coadread_tcga_pub%2Ccellline_nci60%2Cacc_tcga` ); - $('a.tabAnchor_oncoprint').waitForExist({ timeout: 10000 }); - browser.waitUntil(function() { - return !$('a.tabAnchor_mutualExclusivity').isDisplayed(); + await getElement('a.tabAnchor_oncoprint', { timeout: 10000 }); + await browser.waitUntil(async function() { + return !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()); }); - assert(!$('a.tabAnchor_mutualExclusivity').isDisplayed()); + assert( + !(await ( + await getElement('a.tabAnchor_mutualExclusivity') + ).isDisplayed()) + ); }); }); }); describe('case set selection in modify query form', function() { - var selectedCaseSet_sel = + const selectedCaseSet_sel = 'div[data-test="CaseSetSelector"] span.Select-value-label[aria-selected="true"]'; this.retries(2); - beforeEach(function() { - var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_rppa&gene_list=KRAS%2520NRAS%2520BRAF&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic`; - goToUrlAndSetLocalStorage(url); - $('#modifyQueryBtn').waitForExist({ timeout: 60000 }); + beforeEach(async function() { + const url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_rppa&gene_list=KRAS%2520NRAS%2520BRAF&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic`; + await goToUrlAndSetLocalStorage(url); + await getElement('#modifyQueryBtn', { timeout: 60000 }); }); - it('contains correct selected case set through a certain use flow involving two selected studies', () => { + it('contains correct selected case set through a certain use flow involving two selected studies', async () => { //populates case set selector with selected case set in current query, then selects "All" when more studies are selected, then selects default when only one is selected again // open query form - $('#modifyQueryBtn').click(); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); + await clickElement('#modifyQueryBtn'); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); assert.equal( - $(selectedCaseSet_sel).getText(), + await getText(selectedCaseSet_sel), 'Samples with protein data (RPPA) (196)', 'Initially selected case set should be as specified from URL' ); // Select a different study - var input = $('div[data-test=study-search] input[type=text]'); - input.waitForExist({ timeout: 10000 }); - input.setValue('adrenocortical carcinoma tcga firehose legacy'); - waitForNumberOfStudyCheckboxes(1); - var checkBox = $('[data-test="StudySelect"]'); - checkBox.waitForExist({ timeout: 10000 }); - $('[data-test="StudySelect"] input').click(); - browser.pause(100); - - getElementByTestHandle('COPY_NUMBER_ALTERATION').waitForExist({ + const input = await getElement( + 'div[data-test=study-search] input[type=text]', + { timeout: 10000 } + ); + await input.setValue('adrenocortical carcinoma tcga firehose legacy'); + await waitForNumberOfStudyCheckboxes(1); + await getElementByTestHandle('StudySelect', { timeout: 10000 }); + await clickElement('[data-test="StudySelect"] input'); + await browser.pause(100); + + await getElementByTestHandle('COPY_NUMBER_ALTERATION', { timeout: 10000, }); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); assert( - ALL_CASE_SET_REGEXP.test($(selectedCaseSet_sel).getText()), + ALL_CASE_SET_REGEXP.test(await getText(selectedCaseSet_sel)), "'All' case set" ); // Uncheck study - $('[data-test="StudySelect"] input').click(); - browser.pause(100); + await clickElement('[data-test="StudySelect"] input'); + await browser.pause(100); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); assert.equal( - $(selectedCaseSet_sel).getText(), + await getText(selectedCaseSet_sel), 'Samples with mutation and CNA data (212)', 'Now we should be back to default selected case set for this study' ); }); - it('contains correct selected case set through a certain use flow involving the "select all filtered studies" checkbox', () => { + it('contains correct selected case set through a certain use flow involving the "select all filtered studies" checkbox', async () => { //populates case set selector with selected case set in current query, then selects "All" when more studies are selected, then selects default when only one is selected again // open query form - $('#modifyQueryBtn').click(); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); + await clickElement('#modifyQueryBtn'); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); assert.equal( - $(selectedCaseSet_sel).getText(), + await getText(selectedCaseSet_sel), 'Samples with protein data (RPPA) (196)', 'Initially selected case set should be as specified from URL' ); // Select all impact studies - var input = $('div[data-test=study-search] input[type=text]'); - input.waitForExist({ timeout: 10000 }); - input.setValue('glioblastoma'); - browser.pause(500); + const input = await getElement( + 'div[data-test=study-search] input[type=text]', + { timeout: 10000 } + ); + await input.setValue('glioblastoma'); + await browser.pause(500); - $( + await clickElement( 'div[data-test="cancerTypeListContainer"] input[data-test="selectAllStudies"]' - ).click(); + ); - getElementByTestHandle('MUTATION_EXTENDED').waitForExist({ + await getElementByTestHandle('MUTATION_EXTENDED', { timeout: 10000, }); - getElementByTestHandle('COPY_NUMBER_ALTERATION').waitForExist({ + await getElementByTestHandle('COPY_NUMBER_ALTERATION', { timeout: 10000, }); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); - browser.waitUntil(() => { - return ALL_CASE_SET_REGEXP.test($(selectedCaseSet_sel).getText()); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); + await browser.waitUntil(async () => { + return ALL_CASE_SET_REGEXP.test(await getText(selectedCaseSet_sel)); }, 5000); // Deselect all filtered studies - $( + await clickElement( 'div[data-test="cancerTypeListContainer"] input[data-test="selectAllStudies"]' - ).click(); - browser.pause(100); + ); + await browser.pause(100); - $(selectedCaseSet_sel).waitForExist({ timeout: 10000 }); + await getElement(selectedCaseSet_sel, { timeout: 10000 }); assert.equal( - $(selectedCaseSet_sel).getText(), + await getText(selectedCaseSet_sel), 'Samples with mutation and CNA data (212)', 'Now we should be back to default selected case set for this study' ); @@ -305,175 +367,187 @@ describe('case set selection in modify query form', function() { }); describe('gene list input', function() { - beforeEach(function() { - var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_rppa&gene_list=KRAS%2520NRAS%2520BRAF&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic`; - goToUrlAndSetLocalStorage(url); - $('#modifyQueryBtn').waitForExist({ timeout: 60000 }); + beforeEach(async function() { + const url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_rppa&gene_list=KRAS%2520NRAS%2520BRAF&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic`; + await goToUrlAndSetLocalStorage(url); + await getElement('#modifyQueryBtn', { timeout: 60000 }); }); // we're testing this because it was broken - it('allows gene textarea update', () => { - $('#modifyQueryBtn').click(); - const textarea = getElementByTestHandle('geneSet'); - textarea.waitForDisplayed(); - textarea.setValue('TP53 BRAF'); + it('allows gene textarea update', async () => { + await clickElement('#modifyQueryBtn'); + const textarea = await getElementByTestHandle('geneSet'); + await textarea.waitForDisplayed(); + await textarea.setValue('TP53 BRAF'); - assert(textarea.getValue() === 'TP53 BRAF'); + assert((await textarea.getValue()) === 'TP53 BRAF'); }); }); -describe('genetic profile selection in modify query form', function() { - beforeEach(function() { - var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=chol_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&case_set_id=chol_tcga_all&gene_list=EGFR&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=chol_tcga_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=chol_tcga_gistic&genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION=chol_tcga_rppa_Zscores`; - goToUrlAndSetLocalStorage(url); - $('#modifyQueryBtn').waitForExist({ timeout: 20000 }); +describe('genetic profile selection in modify query form', () => { + beforeEach(async () => { + const url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=chol_tcga&Z_SCORE_THRESHOLD=2.0&RPPA_SCORE_THRESHOLD=2.0&data_priority=0&case_set_id=chol_tcga_all&gene_list=EGFR&geneset_list=+&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=chol_tcga_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=chol_tcga_gistic&genetic_profile_ids_PROFILE_PROTEIN_EXPRESSION=chol_tcga_rppa_Zscores`; + await goToUrlAndSetLocalStorage(url); + await getElement('#modifyQueryBtn', { timeout: 20000 }); }); it('contains correct selected genetic profiles through a certain use flow involving two studies', async () => { //populates selected genetic profiles from current query, then goes back to defaults if another study is selected then deselected // open modify query form - $('#modifyQueryBtn').click(); + await clickElement('#modifyQueryBtn'); - browser.waitUntil(() => { - return $( - 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MUTATION_EXTENDED"]' - ).isSelected(); - }); + await browser.waitUntil( + async () => + await isSelected( + 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MUTATION_EXTENDED"]' + ) + ); - await asyncUtils.isSelected( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MUTATION_EXTENDED"]' ); - await asyncUtils.isSelected( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="COPY_NUMBER_ALTERATION"]' ); - await asyncUtils.isSelected( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MRNA_EXPRESSION"]' ); - await asyncUtils.isSelected( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="PROTEIN_LEVEL"]' ); // select another study - var input = await $('div[data-test=study-search] input[type=text]'); - await input.waitForExist({ timeout: 10000 }); + const input = await getElement( + 'div[data-test=study-search] input[type=text]', + { timeout: 10000 } + ); await input.setValue('ampullary baylor'); - await asyncUtils.waitForNumberOfStudyCheckboxes(1); - const checkBox = await $('[data-test="StudySelect"]'); - await checkBox.waitForExist({ timeout: 10000 }); - - await asyncUtils.clickElement(`[data-test="StudySelect"] input`); + await waitForNumberOfStudyCheckboxes(1); + await getElement('[data-test="StudySelect"]', { timeout: 10000 }); + await clickElement(`[data-test="StudySelect"] input`); - await asyncUtils.isSelected('handle=MUTATION_EXTENDED'); + await isSelected('handle=MUTATION_EXTENDED'); - await asyncUtils.isSelected('handle=COPY_NUMBER_ALTERATION'); + await isSelected('handle=COPY_NUMBER_ALTERATION'); - await asyncUtils.isSelected('handle=COPY_NUMBER_ALTERATION'); + await isSelected('handle=COPY_NUMBER_ALTERATION'); //deselect other study so that available profile types will change - await asyncUtils.clickElement(`[data-test="StudySelect"] input`); + await clickElement(`[data-test="StudySelect"] input`); - await asyncUtils.isSelected('handle=MUTATION_EXTENDED'); + await isSelected('handle=MUTATION_EXTENDED'); - await asyncUtils.isSelected('handle=COPY_NUMBER_ALTERATION'); + await isSelected('handle=COPY_NUMBER_ALTERATION'); - await asyncUtils.isUnselected('handle=MRNA_EXPRESSION'); + await isUnselected('handle=MRNA_EXPRESSION'); - await asyncUtils.isUnselected('handle=PROTEIN_LEVEL'); + await isUnselected('handle=PROTEIN_LEVEL'); }); - it('contains correct selected genetic profiles through a certain use flow involving the "select all filtered studies" checkbox', () => { + it('contains correct selected genetic profiles through a certain use flow involving the "select all filtered studies" checkbox', async () => { //populates selected genetic profiles from current query, then goes back to defaults if a lot of studies are selected then deselected // open modify query form - $('#modifyQueryBtn').click(); + await clickElement('#modifyQueryBtn'); // wait for profiles selector to load - getElementByTestHandle('MUTATION_EXTENDED', { + await getElementByTestHandle('MUTATION_EXTENDED', { timeout: 10000, }); // mutations, CNA, and protein should be selected assert( - getElementByTestHandle('COPY_NUMBER_ALTERATION').isSelected(), + await ( + await getElementByTestHandle('COPY_NUMBER_ALTERATION') + ).isSelected(), 'mutation profile should be selected' ); assert( - getElementByTestHandle('MUTATION_EXTENDED').isSelected(), + await ( + await getElementByTestHandle('MUTATION_EXTENDED') + ).isSelected(), 'cna profile should be selected' ); assert( - !$( + !(await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MRNA_EXPRESSION"]' - ).isSelected(), + )), 'mrna profile not selected' ); assert( - $( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="PROTEIN_LEVEL"]' - ).isSelected(), + ), 'protein level should be selected' ); // select all TCGA non-firehose studies - var input = $('div[data-test=study-search] input[type=text]'); - input.waitForExist({ timeout: 10000 }); - input.setValue('tcga -firehose'); - browser.pause(500); + const input = await getElement( + 'div[data-test=study-search] input[type=text]', + { timeout: 10000 } + ); + await input.setValue('tcga -firehose'); + await browser.pause(500); - $( + await clickElement( 'div[data-test="cancerTypeListContainer"] input[data-test="selectAllStudies"]' - ).click(); + ); // wait for data type priority selector to load // getElementByTestHandle('MUTATION_EXTENDED').waitForExist({ // timeout: 10000, // }); - browser.waitUntil(() => { - return getElementByTestHandle('MUTATION_EXTENDED').isSelected(); + await browser.waitUntil(async () => { + return await ( + await getElementByTestHandle('MUTATION_EXTENDED') + ).isSelected(); }); //browser.debug(); assert( - getElementByTestHandle('COPY_NUMBER_ALTERATION').isSelected(), + await ( + await getElementByTestHandle('COPY_NUMBER_ALTERATION') + ).isSelected(), "'Copy number alterations' should be selected" ); // Deselect all TCGA non-firehose studies - $( + await clickElement( 'div[data-test="cancerTypeListContainer"] input[data-test="selectAllStudies"]' - ).click(); - browser.pause(100); + ); + await browser.pause(100); // wait for profiles selector to load - $( - 'div[data-test="molecularProfileSelector"] input[type="checkbox"]' - ).waitForExist({ timeout: 3000 }); + await getElement( + 'div[data-test="molecularProfileSelector"] input[type="checkbox"]', + { timeout: 3000 } + ); // mutations, CNA should be selected assert( - $( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MUTATION_EXTENDED"]' - ).isSelected(), + ), 'mutation profile should be selected' ); assert( - $( + await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="COPY_NUMBER_ALTERATION"]' - ).isSelected(), + ), 'cna profile should be selected' ); assert( - !$( + !(await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="MRNA_EXPRESSION"]' - ).isSelected(), + )), 'mrna profile not selected' ); assert( - !$( + !(await isSelected( 'div[data-test="molecularProfileSelector"] input[type="checkbox"][data-test="PROTEIN_LEVEL"]' - ).isSelected(), + )), 'protein level not selected' ); }); @@ -482,30 +556,31 @@ describe('genetic profile selection in modify query form', function() { describe('invalid query from url', function() { this.retries(1); - it('show invalid query alert when url contains invalid gene', () => { + it('show invalid query alert when url contains invalid gene', async () => { //go to cbioportal with a url that contains an invalid gene symbol RB: - var url = `${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=mixed_pipseq_2017&case_set_id=mixed_pipseq_2017_sequenced&clinicallist=NUM_SAMPLES_PER_PATIENT&data_priority=0&gene_list=RB&geneset_list=%20&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=mixed_pipseq_2017_mutations&show_samples=false&tab_index=tab_visualize`; - goToUrlAndSetLocalStorage(url); + const url = `${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=mixed_pipseq_2017&case_set_id=mixed_pipseq_2017_sequenced&clinicallist=NUM_SAMPLES_PER_PATIENT&data_priority=0&gene_list=RB&geneset_list=%20&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=mixed_pipseq_2017_mutations&show_samples=false&tab_index=tab_visualize`; + await goToUrlAndSetLocalStorage(url); // check alert message - $('[data-test="invalidQueryAlert"]').waitForExist({ timeout: 60000 }); - var text = $('[data-test="invalidQueryAlert"]') - .getText() - .trim(); + await getElement('[data-test="invalidQueryAlert"]', { timeout: 60000 }); + const text = (await getText('[data-test="invalidQueryAlert"]')).trim(); assert.equal( text, 'Your query has invalid or out-dated gene symbols. Please correct below.' ); }); - it('show result view page after correct the invalid gene', () => { + it('show result view page after correct the invalid gene', async () => { // correct to valid gene symbol RB1 - $('[data-test="geneSet"]').setValue('RB1'); + await (await getElement('[data-test="geneSet"]')).setValue('RB1'); - $('[data-test="queryButton"]').waitForEnabled({ timeout: 15000 }); - $('[data-test="queryButton"]').click(); + await getElement('[data-test="queryButton"]', { timeout: 15000 }); + await clickElement('[data-test="queryButton"]'); + await browser.pause(2000); - $('#modifyQueryBtn').waitForExist({ timeout: 3000 }); - waitForOncoprint(); + await (await getElement('#modifyQueryBtn')).waitForExist({ + timeout: 6000, + }); + await waitForOncoprint(); }); }); diff --git a/end-to-end-test/shared/specUtils_Async.js b/end-to-end-test/shared/specUtils_Async.js index f22053923e1..59a708a1b13 100644 --- a/end-to-end-test/shared/specUtils_Async.js +++ b/end-to-end-test/shared/specUtils_Async.js @@ -20,8 +20,10 @@ function waitForGeneQueryPage(timeout) { }); } -function waitForPlotsTab(timeout) { - $('div.axisBlock').waitForDisplayed({ timeout: timeout || 20000 }); +async function waitForPlotsTab(timeout) { + await (await $('div.axisBlock')).waitForDisplayed({ + timeout: timeout || 20000, + }); } function waitForAndCheckPlotsTab() { @@ -49,19 +51,19 @@ function waitForPatientView(timeout) { }); } -function waitForOncoprint(timeout) { - browser.pause(200); // give oncoprint time to disappear - browser.waitUntil( - () => { +async function waitForOncoprint(timeout) { + await browser.pause(200); // give oncoprint time to disappear + await browser.waitUntil( + async () => { return ( - !$('.oncoprintLoadingIndicator').isExisting() && // wait for loading indicator to hide, and - $('#oncoprintDiv svg rect').isExisting() && // as a proxy for oncoprint being rendered, wait for an svg rectangle to appear in the legend - $('.oncoprint__controls').isExisting() + !(await (await $('.oncoprintLoadingIndicator')).isExisting()) && // wait for loading indicator to hide, and + (await (await $('#oncoprintDiv svg rect')).isExisting()) && // as a proxy for oncoprint being rendered, wait for an svg rectangle to appear in the legend + (await (await $('.oncoprint__controls')).isExisting()) ); // oncoprint controls are showing }, { timeout } ); - browser.pause(200); + await browser.pause(200); } function waitForComparisonTab() { @@ -76,17 +78,17 @@ function getTextInOncoprintLegend() { .join(' '); } -function setSettingsMenuOpen(open, buttonId = 'GlobalSettingsButton') { +async function setSettingsMenuOpen(open, buttonId = 'GlobalSettingsButton') { const button = 'button[data-test="' + buttonId + '"]'; const dropdown = 'div[data-test="GlobalSettingsDropdown"]'; - $(button).waitForDisplayed(); - browser.waitUntil( - () => { - if (open === $(dropdown).isDisplayedInViewport()) { + await (await $(button)).waitForDisplayed(); + await browser.waitUntil( + async () => { + if (open === (await (await $(dropdown)).isDisplayedInViewport())) { return true; } else { - $(button).click(); - $(dropdown).waitForDisplayed({ + await (await $(button)).click(); + await (await $(dropdown)).waitForDisplayed({ timeout: 6000, reverse: !open, }); @@ -112,18 +114,46 @@ async function getElementByTestHandle(handle, options) { return await $(`[data-test="${handle}"]`); } -function setOncoprintMutationsMenuOpen(open) { +/** + * @param {string} testHandle the data-test handle of the element + * @param {string} type the type of color to get background-color, border-color , default is 'color' + * @returns {Promise} `hex` color of the element + */ +async function getColorByTestHandle(testHandle, type = 'color') { + const element = await getElementByTestHandle(testHandle); + const color = await element.getCSSProperty(type); + return color.parsed.hex; +} + +/** + * @param {string} selector + * @param {number} index + * @param {string} type border-color, background-color, color + * @returns {Promise} `hex` color of the element + */ +async function getColorOfNthElement(selector, index, type = 'color') { + const element = await getNthElements(selector, index); + const color = await element.getCSSProperty(type); + return color.parsed.hex; +} + +async function setOncoprintMutationsMenuOpen(open) { const mutationColorMenuButton = '#mutationColorDropdown'; const mutationColorMenuDropdown = 'div.oncoprint__controls__mutation_color_menu'; - $('div.oncoprint__controls').moveTo(); - $(mutationColorMenuButton).waitForDisplayed(); - browser.waitUntil( - () => { - if (open === $(mutationColorMenuDropdown).isDisplayedInViewport()) { + await (await getElement('div.oncoprint__controls')).moveTo(); + await (await getElement(mutationColorMenuButton)).waitForDisplayed(); + await browser.waitUntil( + async () => { + if ( + open === + (await ( + await getElement(mutationColorMenuDropdown) + ).isDisplayedInViewport()) + ) { return true; } else { - $(mutationColorMenuButton).click(); + await clickElement(mutationColorMenuButton); return false; } }, @@ -238,24 +268,21 @@ async function goToUrlAndSetLocalStorage(url, authenticated = false) { if (needToLogin) keycloakLogin(10000); } +const setServerConfiguration = serverConfig => { + browser.execute(function(_serverConfig) { + this.localStorage.setItem( + 'frontendConfig', + JSON.stringify({ serverConfig: _serverConfig }) + ); + }, serverConfig); +}; + const goToUrlAndSetLocalStorageWithProperty = (url, authenticated, props) => { goToUrlAndSetLocalStorage(url, authenticated); setServerConfiguration(props); goToUrlAndSetLocalStorage(url, authenticated); }; -function setServerConfiguration(props) { - browser.execute( - function(frontendConf) { - this.localStorage.setItem( - 'frontendConfig', - JSON.stringify(frontendConf) - ); - }, - { serverConfig: props } - ); -} - function sessionServiceIsEnabled() { return browser.execute(function() { return window.getServerConfig().sessionServiceEnabled; @@ -297,13 +324,13 @@ const useExternalFrontend = !process.env const useLocalDist = process.env.FRONTEND_TEST_USE_LOCAL_DIST; -function waitForNetworkQuiet(timeout) { - browser.waitUntil( - () => { +async function waitForNetworkQuiet(timeout) { + await browser.waitUntil( + async () => { return ( - browser.execute(function() { + (await browser.execute(function() { return window.ajaxQuiet === true; - }) == true + })) == true ); }, { timeout } @@ -359,25 +386,23 @@ function waitForGroupComparisonTabOpen(timeout) { }); } -function getTextFromElement(element) { - return $(element) - .getText() - .trim(); +async function getTextFromElement(element) { + return (await (await $(element)).getText()).trim(); } function getNumberOfStudyViewCharts() { return $$('div.react-grid-item').length; } -function setInputText(selector, text) { +async function setInputText(selector, text) { // backspace to delete current contents - webdriver is supposed to clear it but it doesnt always work - $(selector).click(); + // await (await $(selector)).click(); //browser.keys('\uE003'.repeat($(selector).getValue().length)); - $(selector).clearValue(); + await (await $(selector)).clearValue(); //browser.pause(1000); - $(selector).setValue(text); + await (await $(selector)).setValue(text); } function getReactSelectOptions(parent) { @@ -422,9 +447,9 @@ function pasteToElement(elementSelector, text) { browser.keys(['Shift', 'Insert']); } -function checkOncoprintElement(selector, viewports) { +async function checkOncoprintElement(selector, viewports) { //browser.moveToObject('body', 0, 0); - browser.execute(function() { + await browser.execute(() => { frontendOnc.clearMouseOverEffects(); // clear mouse hover effects for uniform screenshot }); return checkElementWithMouseDisabled(selector || '#oncoprintDiv', 0, { @@ -446,8 +471,8 @@ async function jsApiHover(selector) { }, selector); } -function jsApiClick(selector) { - browser.execute(function(_selector) { +async function jsApiClick(selector) { + await browser.execute(function(_selector) { $(_selector)[0].dispatchEvent( new MouseEvent('click', { bubbles: true }) ); @@ -458,23 +483,23 @@ function executeInBrowser(callback) { return browser.execute(callback); } -function checkElementWithTemporaryClass( +async function checkElementWithTemporaryClass( selectorForChecking, selectorForTemporaryClass, temporaryClass, pauseTime, options ) { - browser.execute( - function(selectorForTemporaryClass, temporaryClass) { + await browser.execute( + (selectorForTemporaryClass, temporaryClass) => { $(selectorForTemporaryClass).addClass(temporaryClass); }, selectorForTemporaryClass, temporaryClass ); - browser.pause(pauseTime); - var res = browser.checkElement(selectorForChecking, '', options); - browser.execute( + await browser.pause(pauseTime); + var res = await browser.checkElement(selectorForChecking, '', options); + await browser.execute( function(selectorForTemporaryClass, temporaryClass) { $(selectorForTemporaryClass).removeClass(temporaryClass); }, @@ -484,17 +509,17 @@ function checkElementWithTemporaryClass( return res; } -function checkElementWithMouseDisabled(selector, pauseTime, options) { - browser.execute(function() { +async function checkElementWithMouseDisabled(selector, pauseTime, options) { + await browser.execute(() => { const style = 'display:block !important;visibility:visible !important;'; $(`
`).appendTo( 'body' ); }); - $(selector).waitForExist({ timeout: 5000 }); + await getElement(selector, { timeout: 5000 }); - const ret = checkElementWithTemporaryClass( + const ret = await checkElementWithTemporaryClass( selector, selector, 'disablePointerEvents', @@ -502,7 +527,7 @@ function checkElementWithMouseDisabled(selector, pauseTime, options) { options ); - browser.execute(function() { + await browser.execute(() => { $('#blockUIToDisableMouse').remove(); }); @@ -685,15 +710,6 @@ async function jq(selector) { }, selector); } -function setServerConfiguration(serverConfig) { - browser.execute(function(_serverConfig) { - this.localStorage.setItem( - 'frontendConfig', - JSON.stringify({ serverConfig: _serverConfig }) - ); - }, serverConfig); -} - var openAlterationTypeSelectionMenu = () => { $('[data-test=AlterationEnrichmentTypeSelectorButton]').waitForExist(); $('[data-test=AlterationEnrichmentTypeSelectorButton]').click(); @@ -733,6 +749,24 @@ async function getElement(selector, options = {}) { } return el; } +/** + * @param {string} selector css selector + * @param {number} index index of the element + * @param {object} options options for the element + * @returns {Promise} + */ +async function getNthElements(selector, index, options) { + let els; + if (/^handle=/.test(selector)) { + els = await $$(selector.replace(/^handle=/, '')); + } else { + els = await $$(selector); + } + if (options?.timeout) { + await els.waitForExist(options); + } + return els[index]; +} async function getText(selector, option) { const el = await getElement(...arguments); @@ -819,6 +853,9 @@ module.exports = { setCheckboxChecked, openAlterationTypeSelectionMenu, strIsNumeric, + getNthElements, + getColorByTestHandle, + getColorOfNthElement, jq, setServerConfiguration, selectClinicalTabPlotType,