Skip to content

Commit

Permalink
move sync to async for all remote tests (#4920)
Browse files Browse the repository at this point in the history
* migrate all remote e2e tests from sync to async style

---------

Co-authored-by: lismana <lismanBusiness@gmail.com>
  • Loading branch information
bemijonathan and alisman authored Jul 17, 2024
1 parent 5da378a commit 534daad
Show file tree
Hide file tree
Showing 11 changed files with 1,079 additions and 764 deletions.
256 changes: 159 additions & 97 deletions end-to-end-test/remote/specs/core/customTabs.spec.js

Large diffs are not rendered by default.

236 changes: 115 additions & 121 deletions end-to-end-test/remote/specs/core/expressionComparison.spec.js
Original file line number Diff line number Diff line change
@@ -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: `
Expand All @@ -38,193 +30,195 @@ 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
);
});
});

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: `
(studies)=>studies.filter(s=>/pan_can_atlas/.test(s.studyId) === false).length === 0
`,
});

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);
});
});
Loading

0 comments on commit 534daad

Please sign in to comment.