<commit_before>var assert = require('assert');
var goToUrlAndSetLocalStorage = require('../../../shared/specUtils')
    .goToUrlAndSetLocalStorage;
var postDataToUrl = require('../../../shared/specUtils').postDataToUrl;
var _ = require('lodash');

var {
    useExternalFrontend,
    waitForOncoprint,
} = require('../../../shared/specUtils');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

describe('posting query parameters (instead of GET) to query page', function() {
    it('reads posted data (written by backend) and successfully passes params into URL, resulting in oncoprint display', function() {
        const url = `${CBIOPORTAL_URL}/results`;
        goToUrlAndSetLocalStorage(url);

        let query = {
            gene_list: 'CDKN2A MDM2 MDM4 TP53',
            cancer_study_list: 'study_es_0',
            case_set_id: 'study_es_0_cnaseq',
            profileFilter: '0',
            RPPA_SCORE_THRESHOLD: '2.0',
            Z_SCORE_THRESHOLD: '2.0',
            genetic_profile_ids_PROFILE_MUTATION_EXTENDED:
                'study_es_0_mutations',
            genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION:
                'study_es_0_gistic',
        };

        postDataToUrl(url, query);

        // the following could only occur if code passes data written above into url
        browser.waitUntil(() => {
            var url = browser.getUrl();

            // make sure param in query is passed to url and encoded
            return _.every(query, (item, key) => {
                if (key === 'gene_list') {
                    return url.includes(
                        `${key}=${encodeURIComponent(encodeURIComponent(item))}`
                    );
                } else {
                    return url.includes(`${key}=${encodeURIComponent(item)}`);
                }
            });
        });

        const postData = browser.execute(() => {
            return window.postData;
        });

        assert(postData === null, 'postData has been set to null after read');

        waitForOncoprint();
    });
});
<commit_msg>Fix posted query localdb test<commit_after>var assert = require('assert');
var goToUrlAndSetLocalStorage = require('../../../shared/specUtils')
    .goToUrlAndSetLocalStorage;
var postDataToUrl = require('../../../shared/specUtils').postDataToUrl;
var _ = require('lodash');

var {
    useExternalFrontend,
    waitForOncoprint,
} = require('../../../shared/specUtils');

const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, '');

describe('posting query parameters (instead of GET) to query page', function() {
    it('reads posted data (written by backend) and successfully passes params into URL, resulting in oncoprint display', function() {
        const url = `${CBIOPORTAL_URL}`;
        goToUrlAndSetLocalStorage(url, true);

        let query = {
            gene_list: 'CDKN2A MDM2 MDM4 TP53',
            cancer_study_list: 'study_es_0',
            case_set_id: 'study_es_0_cnaseq',
            profileFilter: '0',
            RPPA_SCORE_THRESHOLD: '2.0',
            Z_SCORE_THRESHOLD: '2.0',
            genetic_profile_ids_PROFILE_MUTATION_EXTENDED:
                'study_es_0_mutations',
            genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION:
                'study_es_0_gistic',
        };

        postDataToUrl(`${url}/results`, query);

        // the following could only occur if code passes data written above into url
        browser.waitUntil(() => {
            var url = browser.getUrl();

            // make sure param in query is passed to url and encoded
            return _.every(query, (item, key) => {
                if (key === 'gene_list') {
                    return url.includes(
                        `${key}=${encodeURIComponent(encodeURIComponent(item))}`
                    );
                } else {
                    return url.includes(`${key}=${encodeURIComponent(item)}`);
                }
            });
        });

        const postData = browser.execute(() => {
            return window.postData;
        });

        assert(postData === null, 'postData has been set to null after read');

        waitForOncoprint();
    });
});

{'fraction_non_alphanumeric': 0.12556480380499405, 'fraction_numerical': 0.006658739595719381, 'mean_word_length': 2.138805970149254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6434603', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1219, 'n_words': 265}