diff --git a/end-to-end-test/remote/specs/core/comparisonTab.spec.js b/end-to-end-test/remote/specs/core/comparisonTab.spec.js index 8c4228d5182..1000599debd 100644 --- a/end-to-end-test/remote/specs/core/comparisonTab.spec.js +++ b/end-to-end-test/remote/specs/core/comparisonTab.spec.js @@ -1,154 +1,222 @@ var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var { jsApiClick } = require('../../../shared/specUtils'); +const { + goToUrlAndSetLocalStorage, + jsApiClick, + getElement, + getElementByTestHandle, +} = require('../../../shared/specUtils_Async'); const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); const SampleCreateGroupButton = 'button[data-test="sampleGroupComparisonCreateGroupButton"]'; const PatientCreateGroupButton = 'button[data-test="patientGroupComparisonCreateGroupButton"]'; +const ComparisonPageOverlapTabDiv = + 'div[data-test="ComparisonPageOverlapTabDiv"]'; +const sampleGroupNameInputField = '[data-test="sampleGroupNameInputField"]'; +const dataTestSampleGroupNameSubmitButton = + '[data-test="sampleGroupNameSubmitButton"]'; describe('results view comparison tab venn diagram tests', function() { describe('create new group tests', function() { - before(function() { - goToUrlAndSetLocalStorage( + before(async function() { + // await browser.debug() + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?Z_SCORE_THRESHOLD=2.0&cancer_study_id=coadread_tcga_pub&cancer_study_list=coadread_tcga_pub&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&gene_set_choice=user-defined-list&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations` ); - $('div[data-test="ComparisonPageOverlapTabDiv"]').waitForExist({ + await getElement(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 function() { + 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="sample0VennRegion"]'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('select from sample venn diagram', async function() { + await jsApiClick('rect[data-test="sample0VennRegion"]'); + 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); - assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), - true, - 'group name input exists' + it('click sample venn diagram create group button', async function() { + (await getElement(SampleCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(200); + const el = await getElementByTestHandle( + 'sampleGroupNameInputField' ); + const isDisplayed = await el.isDisplayed(); + console.log('isDisplayed', isDisplayed); + assert.equal(isDisplayed, true, 'group name input exists'); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElement(dataTestSampleGroupNameSubmitButton) + ).isEnabled(), false ); }); - it('sample venn diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue( + it('sample venn diagram: group name exists, should disable submit button', async function() { + (await getElement(sampleGroupNameInputField)).setValue( 'Altered group' ); - browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + 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 getElement(dataTestSampleGroupNameSubmitButton) + ).isEnabled(), false ); - $('[data-test="sampleGroupNameInputField"]').setValue('KRAS'); - browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + (await getElement(sampleGroupNameInputField)).setValue('KRAS'); + 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 getElement(dataTestSampleGroupNameSubmitButton) + ).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 function() { + await (await getElement(sampleGroupNameInputField)).setValue( + 'new group' + ); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElement(dataTestSampleGroupNameSubmitButton) + ).isEnabled(), true ); }); - it('select from patient venn diagram', function() { + it('select from patient venn diagram', async function() { // unselect sample venn diagram first - jsApiClick('rect[data-test="sample0VennRegion"]'); - jsApiClick('rect[data-test="patient0VennRegion"]'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), true); + await jsApiClick('rect[data-test="sample0VennRegion"]'); + 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 function() { + (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( - 'Unaltered group' - ); - browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + it('patient venn diagram: group name exists, should disable submit button', async function() { + ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('Unaltered group'); + 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 ); - $('[data-test="patientGroupNameInputField"]').setValue('BRAF'); - browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('BRAF'); + 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 function() { + ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + await ( + await getElementByTestHandle('patientGroupNameSubmitButton') + ).isEnabled(), true ); }); @@ -157,114 +225,160 @@ describe('results view comparison tab venn diagram tests', function() { describe('results view comparison tab upset diagram tests', function() { describe('create new group tests', function() { - before(function() { - goToUrlAndSetLocalStorage( + before(async function() { + await goToUrlAndSetLocalStorage( `${CBIOPORTAL_URL}/results/comparison?Z_SCORE_THRESHOLD=2.0&cancer_study_id=coadread_tcga_pub&cancer_study_list=coadread_tcga_pub&case_set_id=coadread_tcga_pub_nonhypermut&comparison_selectedGroups=%5B%22Altered%20group%22%2C%22Unaltered%20group%22%2C%22KRAS%22%2C%22NRAS%22%5D&gene_list=KRAS%20NRAS%20BRAF&gene_set_choice=user-defined-list&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations` ); - $('div[data-test="ComparisonPageOverlapTabDiv"]').waitForExist({ + await getElement(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 function() { + 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_Altered_group_KRAS_bar'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + it('select from sample upset diagram', async function() { + await jsApiClick('.sample_Altered_group_KRAS_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 function() { + (await getElement(SampleCreateGroupButton)).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), + await ( + await getElement(sampleGroupNameInputField) + ).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElement(dataTestSampleGroupNameSubmitButton) + ).isEnabled(), false ); }); - it('sample upset diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue( + it('sample upset diagram: group name exists, should disable submit button', async function() { + (await getElement(sampleGroupNameInputField)).setValue( 'Altered group' ); - browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + await browser.pause(100); + await getElementByTestHandle('sampleDuplicateGroupNameMessage', { timeout: 20000, }); assert.equal( - $('[data-test="sampleDuplicateGroupNameMessage"]').getText(), + await ( + await getElement( + '[data-test="sampleDuplicateGroupNameMessage"]' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElement(dataTestSampleGroupNameSubmitButton) + ).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 function() { + (await getElement(sampleGroupNameInputField)).setValue('new group'); + await browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + await ( + await getElement(dataTestSampleGroupNameSubmitButton) + ).isEnabled(), true ); }); - it('select from patient upset diagram', function() { + it('select from patient upset diagram', async function() { // unselect sample venn diagram first - jsApiClick('.sample_Altered_group_KRAS_bar'); - jsApiClick('.patient_Unaltered_group_bar'); - browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), true); + await jsApiClick('.sample_Altered_group_KRAS_bar'); + await jsApiClick('.patient_Unaltered_group_bar'); + 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 function() { + (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('BRAF'); - browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + it('patient upset diagram: group name exists, should disable submit button', async function() { + ( + await getElementByTestHandle('patientGroupNameInputField') + ).setValue('BRAF'); + 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 function() { + ( + 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/shared/specUtils_Async.js b/end-to-end-test/shared/specUtils_Async.js index 4daf290c9d2..f22053923e1 100644 --- a/end-to-end-test/shared/specUtils_Async.js +++ b/end-to-end-test/shared/specUtils_Async.js @@ -438,8 +438,8 @@ function checkOncoprintElement(selector, viewports) { }); } -function jsApiHover(selector) { - browser.execute(function(_selector) { +async function jsApiHover(selector) { + await browser.execute(function(_selector) { $(_selector)[0].dispatchEvent( new MouseEvent('mouseover', { bubbles: true }) );