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..940ada6bbb2 100644 --- a/end-to-end-test/remote/specs/core/comparisonTab.spec.js +++ b/end-to-end-test/remote/specs/core/comparisonTab.spec.js @@ -1,135 +1,179 @@ var assert = require('assert'); -var goToUrlAndSetLocalStorage = require('../../../shared/specUtils') - .goToUrlAndSetLocalStorage; -var { jsApiClick } = require('../../../shared/specUtils'); +const asyncUtils = require('../../../shared/specUtils_Async'); + +const { jsApiClick, getElementByTestHandle, getElement } = asyncUtils; const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ''); -const SampleCreateGroupButton = - 'button[data-test="sampleGroupComparisonCreateGroupButton"]'; -const PatientCreateGroupButton = - 'button[data-test="patientGroupComparisonCreateGroupButton"]'; +const getSampleCreateGroupButton = async function() { + return getElementByTestHandle('sampleGroupComparisonCreateGroupButton'); +}; +const getPatientCreateGroupButton = async function() { + return getElementByTestHandle('patientGroupComparisonCreateGroupButton'); +}; +const dataTestPatientGroupNameSubmitButton = async function() { + return getElement('[data-test="patientGroupNameSubmitButton"]'); +}; +const dataTestPatientGroupNameInputField = async function() { + return getElement('[data-test="patientGroupNameInputField"]'); +}; +const getSampleGroupNameInputField = async function() { + return getElementByTestHandle('sampleGroupNameInputField'); +}; +const getSampleGroupNameSubmitButton = async function() { + return getElementByTestHandle('sampleGroupNameSubmitButton'); +}; describe('results view comparison tab venn diagram tests', function() { - describe('create new group tests', function() { - before(function() { - goToUrlAndSetLocalStorage( + describe.only('create new group tests', function() { + before(async function() { + await asyncUtils.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({ - timeout: 20000, - }); + await asyncUtils.getElementByTestHandle( + '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 getSampleCreateGroupButton()).isEnabled(), + false + ); + assert.equal( + (await getPatientCreateGroupButton()).isEnabled(), + false + ); }); - it('select from sample venn diagram', function() { - jsApiClick('rect[data-test="sample0VennRegion"]'); + it('select from sample venn diagram', async function() { + await jsApiClick('rect[data-test="sample0VennRegion"]'); browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + assert.equal( + (await getSampleCreateGroupButton()).isEnabled(), + true + ); + assert.equal( + (await getPatientCreateGroupButton()).isEnabled(), + false + ); }); - it('click sample venn diagram create group button', function() { - $(SampleCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); + it('click sample venn diagram create group button', async function() { + (await getSampleCreateGroupButton()).click(); + await getElement('div.rc-tooltip-inner', { timeout: 20000 }); browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), + (await getSampleGroupNameInputField()).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); }); - it('sample venn diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue( - 'Altered group' - ); + it.only('sample venn diagram: group name exists, should disable submit button', async function() { + (await getSampleGroupNameInputField()).setValue('Altered group'); browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ + await getElementByTestHandle('sampleDuplicateGroupNameMessage', { timeout: 20000, }); + assert.equal( - $('[data-test="sampleDuplicateGroupNameMessage"]').getText(), - 'Another group already has this name.' + await getElementByTestHandle( + 'sampleDuplicateGroupNameMessage*=Another group already has this name' + ) ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + ( + await getElementByTestHandle('sampleGroupNameSubmitButton') + ).isEnabled(), false ); - $('[data-test="sampleGroupNameInputField"]').setValue('KRAS'); + (await getSampleGroupNameInputField()).setValue('KRAS'); browser.pause(100); - $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ - timeout: 20000, - }); + await asyncUtils.getElementByTestHandle( + 'sampleDuplicateGroupNameMessage', + { + timeout: 20000, + } + ); assert.equal( - $('[data-test="sampleDuplicateGroupNameMessage"]').getText(), + ( + await asyncUtils.getElementByTestHandle( + 'sampleDuplicateGroupNameMessage' + ) + ).getText(), 'Another group already has this name.' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + $(await getSampleGroupNameSubmitButton()).isEnabled(), false ); }); - it('sample venn diagram: new group name, should enable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue('new group'); + it('sample venn diagram: new group name, should enable submit button', async function() { + await getSampleGroupNameInputField().setValue('new group'); browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + $(await getSampleGroupNameSubmitButton()).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"]'); + await jsApiClick('rect[data-test="sample0VennRegion"]'); + await jsApiClick('rect[data-test="patient0VennRegion"]'); browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), false); - assert.equal($(PatientCreateGroupButton).isEnabled(), true); + assert.equal( + (await getSampleCreateGroupButton()).isEnabled(), + false + ); + assert.equal( + (await getPatientCreateGroupButton()).isEnabled(), + true + ); }); - it('click patient venn diagram create group button', function() { + it('click patient venn diagram create group button', async function() { $(PatientCreateGroupButton).click(); $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); browser.pause(100); assert.equal( - $('[data-test="patientGroupNameInputField"]').isDisplayed(), + $(dataTestPatientGroupNameInputField).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + (await dataTestPatientGroupNameSubmitButton()).isEnabled(), false ); }); - it('patient venn diagram: group name exists, should disable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue( - 'Unaltered group' - ); + it.only('patient venn diagram: group name exists, should disable submit button', async function() { + $(dataTestPatientGroupNameInputField).setValue('Unaltered group'); browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ - timeout: 20000, - }); - assert.equal( - $('[data-test="patientDuplicateGroupNameMessage"]').getText(), - 'Another group already has this name.' + const el = await asyncUtils.getElementByTestHandle( + 'patientDuplicateGroupNameMessage', + { + timeout: 20000, + } ); + assert.equal(el.getText(), 'Another group already has this name.'); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + (await dataTestPatientGroupNameSubmitButton()).isEnabled(), false ); - $('[data-test="patientGroupNameInputField"]').setValue('BRAF'); + $(dataTestPatientGroupNameInputField).setValue('BRAF'); browser.pause(100); $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ timeout: 20000, @@ -139,16 +183,16 @@ describe('results view comparison tab venn diagram tests', function() { 'Another group already has this name.' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + $(dataTestPatientGroupNameSubmitButton()).isEnabled(), false ); }); - it('patient venn diagram: new group name, should enable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue('new group'); + it.skip('patient venn diagram: new group name, should enable submit button', function() { + $(dataTestPatientGroupNameInputField).setValue('new group'); browser.pause(100); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + $(dataTestPatientGroupNameSubmitButton()).isEnabled(), true ); }); @@ -166,37 +210,37 @@ describe('results view comparison tab upset diagram tests', function() { }); }); - 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 getSampleCreateGroupButton().isEnabled(), false); + assert.equal( + await getPatientCreateGroupButton().isEnabled(), + false + ); }); - it('select from sample upset diagram', function() { + it('select from sample upset diagram', async function() { jsApiClick('.sample_Altered_group_KRAS_bar'); browser.pause(100); - assert.equal($(SampleCreateGroupButton).isEnabled(), true); - assert.equal($(PatientCreateGroupButton).isEnabled(), false); + assert.equal((await getSampleCreateGroupButton).isEnabled(), true); + assert.equal( + (await getPatientCreateGroupButton).isEnabled(), + false + ); }); - it('click sample upset diagram create group button', function() { + it('click sample upset diagram create group button', async function() { $(SampleCreateGroupButton).click(); $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); browser.pause(100); + assert.equal($().isDisplayed(), true, 'group name input exists'); assert.equal( - $('[data-test="sampleGroupNameInputField"]').isDisplayed(), - true, - 'group name input exists' - ); - assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + $(await getSampleGroupNameSubmitButton()).isEnabled(), false ); }); - it('sample upset diagram: group name exists, should disable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue( - 'Altered group' - ); + it('sample upset diagram: group name exists, should disable submit button', async function() { + $().setValue('Altered group'); browser.pause(100); $('[data-test="sampleDuplicateGroupNameMessage"]').waitForExist({ timeout: 20000, @@ -206,65 +250,69 @@ describe('results view comparison tab upset diagram tests', function() { 'Another group already has this name.' ); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + $(await getSampleGroupNameSubmitButton()).isEnabled(), false ); }); - it('sample upset diagram: new group name, should enable submit button', function() { - $('[data-test="sampleGroupNameInputField"]').setValue('new group'); + it('sample upset diagram: new group name, should enable submit button', async function() { + $().setValue('new group'); browser.pause(100); assert.equal( - $('[data-test="sampleGroupNameSubmitButton"]').isEnabled(), + $(await getSampleGroupNameSubmitButton()).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); + assert.equal((await SampleCreateGroupButton()).isEnabled(), false); + assert.equal( + (await getPatientCreateGroupButton()).isEnabled(), + true + ); }); - it('click patient upset diagram create group button', function() { - $(PatientCreateGroupButton).click(); - $('div.rc-tooltip-inner').waitForExist({ timeout: 20000 }); + it('click patient upset diagram create group button', async function() { + $(await getPatientCreateGroupButton()).click(); + asyncUtils.getElement('div.rc-tooltip-inner', { timeout: 20000 }); browser.pause(100); assert.equal( - $('[data-test="patientGroupNameInputField"]').isDisplayed(), + $(await dataTestPatientGroupNameInputField()).isDisplayed(), true, 'group name input exists' ); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + $(await dataTestPatientGroupNameSubmitButton()).isEnabled(), false ); }); - it('patient upset diagram: group name exists, should disable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue('BRAF'); + it('patient upset diagram: group name exists, should disable submit button', async function() { + $(await dataTestPatientGroupNameInputField()).setValue('BRAF'); browser.pause(100); - $('[data-test="patientDuplicateGroupNameMessage"]').waitForExist({ + const patientDuplicateGroupNameMessage = + '[data-test="patientDuplicateGroupNameMessage"]'; + const el = asyncUtils.getElement(patientDuplicateGroupNameMessage, { timeout: 20000, }); + assert.equal(el.getText(), 'Another group already has this name.'); assert.equal( - $('[data-test="patientDuplicateGroupNameMessage"]').getText(), - 'Another group already has this name.' - ); - assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + $(dataTestPatientGroupNameSubmitButton).isEnabled(), false ); }); - it('patient upset diagram: new group name, should enable submit button', function() { - $('[data-test="patientGroupNameInputField"]').setValue('new group'); + it('patient upset diagram: new group name, should enable submit button', async function() { + await asyncUtils + .getElementByTestHandle('patientGroupNameInputField') + .setValue('new group'); browser.pause(100); assert.equal( - $('[data-test="patientGroupNameSubmitButton"]').isEnabled(), + (await dataTestPatientGroupNameSubmitButton()).isEnabled(), true ); });