<commit_before>/**
 * Copyright 2015-2016 OpenCB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {login, randomString, checkResults} from "../plugins/utils.js";
import {TIMEOUT} from "../plugins/constants.js";


context("5 - Case Portal", () => {
    before(() => {
        login();
    });

    it("5.1 - check query results", () => {
        cy.get("a[data-id=clinicalAnalysisPortal]", {timeout: TIMEOUT}).click({force: true});
        cy.get("div.page-title h2", {timeout: TIMEOUT}).should("be.visible").and("contain", "Case Portal");

        checkResults("opencga-clinical-analysis-grid");

        // check if priority filter is enabled and visible first, then it tests the filter itself
        // TODO bugfix
        /* cy.get("div.lhs", {timeout: 5000})
            .should("satisfy", $els => {
                const priority = Cypress.$("div[data-cy='form-priority'] button");
                if (priority.length) {
                    cy.get("div[data-cy='form-priority'] button").click();
                    cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains("URGENT").click({force: true});
                    cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains("HIGH").click({force: true});
                    cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains("MEDIUM").click({force: true});
                    cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains("LOW").click({force: true});
                    cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains("UNKNOWN").click({force: true});
                    //waitTableResults("opencga-clinical-analysis-grid");
                    checkResults("opencga-clinical-analysis-grid");
                } else {
                    return true;
                }
            });*/


        // reading from the first row the case Id, the proband Id, and the Family Id and use them as filters
        cy.get("opencga-clinical-analysis-grid .bootstrap-table .fixed-table-container tr[data-index=0]", {timeout: TIMEOUT})
            .find("td:nth-child(1) a[data-cy='case-id']")
            .then($a => {
                const caseId = $a.text().trim();
                cy.get("div[data-cy='form-case'] button").click();
                cy.get("div[data-cy='form-case'] input").type(caseId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(2) p[data-cy='proband-sample-id']").first()
            .then($p => {
                const probandSampleId = $p.text().trim();
                console.log("probandSampleId", probandSampleId);
                cy.get("div[data-cy='form-sample'] button").click();
                cy.get("div[data-cy='form-sample'] input").type(probandSampleId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(2) span[data-cy='proband-id']")
            .then($span => {
                const probandId = $span.text().trim();
                console.log("probandId", probandId);
                cy.get("div[data-cy='form-proband'] button").click();
                cy.get("div[data-cy='form-proband'] input").type(probandId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(3) span[data-cy='family-id']")
            .then($span => {
                const familyId = $span.text().trim();
                console.log("familyId", familyId);
                cy.get("div[data-cy='form-family'] button").click();
                cy.get("div[data-cy='form-family'] input").type(familyId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(4) span[data-cy='disorder-name']")
            .then($span => {
                const disorderName = $span.text().trim();
                console.log("disorderName", disorderName);
                cy.get("div[data-cy='form-family'] button").click();
                cy.get("div[data-cy='form-family'] input").type(disorderName + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            });

        // cy.get("opencga-clinical-review-cases .rhs button", {timeout: TIMEOUT}).should("be.visible").and("contain", "Clear").click()
        cy.get("button[data-cy='filter-button']").click({force: true});
        cy.get(".saved-filter-wrapper a").contains("Clear").click({force: true});

    });

    it("5.2 - check Columns togglability", () => {
        cy.get("a[data-id=clinicalAnalysisPortal]", {timeout: TIMEOUT}).click({force: true});
        cy.get("div.page-title h2", {timeout: TIMEOUT}).should("be.visible").and("contain", "Case Portal");


        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper button").should("be.visible").and("contain", "Columns").click();
        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper ul li").should("have.length.gt", 1);


        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper ul li a").click({multiple: true, timeout: TIMEOUT}); // deactivate all the columns
        cy.get("opencga-clinical-analysis-grid .bootstrap-table .fixed-table-container tr[data-index=0]", {timeout: TIMEOUT}).find("td", {timeout: TIMEOUT}).should("have.lengthOf", 1);
<commit_msg>E2E Case Portal disorder, priority params added #219<commit_after>/**
 * Copyright 2015-2016 OpenCB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {login, randomString, checkResults} from "../plugins/utils.js";
import {TIMEOUT} from "../plugins/constants.js";


context("5 - Case Portal", () => {
    before(() => {
        login();
    });

    it("5.1 - check query results", () => {
        cy.get("a[data-id=clinicalAnalysisPortal]", {timeout: TIMEOUT}).click({force: true});
        cy.get("div.page-title h2", {timeout: TIMEOUT}).should("be.visible").and("contain", "Case Portal");

        checkResults("opencga-clinical-analysis-grid");

        // reading from the first row the case Id, the proband Id, and the Family Id and use them as filters
        cy.get("opencga-clinical-analysis-grid .bootstrap-table .fixed-table-container tr[data-index=0]", {timeout: TIMEOUT})
            .find("td:nth-child(1) a[data-cy='case-id']")
            .then($a => {
                const caseId = $a.text().trim();
                cy.get("div[data-cy='form-case'] button").click();
                cy.get("div[data-cy='form-case'] input").type(caseId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(2) p[data-cy='proband-sample-id']").first()
            .then($p => {
                const probandSampleId = $p.text().trim();
                console.log("probandSampleId", probandSampleId);
                cy.get("div[data-cy='form-sample'] button").click();
                cy.get("div[data-cy='form-sample'] input").type(probandSampleId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(2) span[data-cy='proband-id']")
            .then($span => {
                const probandId = $span.text().trim();
                console.log("probandId", probandId);
                cy.get("div[data-cy='form-proband'] button").click();
                cy.get("div[data-cy='form-proband'] input").type(probandId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(3) span[data-cy='family-id']")
            .then($span => {
                const familyId = $span.text().trim();
                console.log("familyId", familyId);
                cy.get("div[data-cy='form-family'] button").click();
                cy.get("div[data-cy='form-family'] input").type(familyId + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            })

            .find("td:nth-child(4) span[data-cy='disorder-name']")
            .then($span => {
                const disorderName = $span.text().trim();
                console.log("disorderName", disorderName);
                cy.get("div[data-cy='form-disorder'] button").click();
                cy.get("div[data-cy='form-disorder'] input").type(disorderName + "{enter}", {force: true});
                checkResults("opencga-clinical-analysis-grid");

            });

        // check whether priority filter is enabled and visible first, then it tests the filter itself
        cy.get("div.lhs", {timeout: 5000}).then($wc => {
            if (Cypress.$("div[data-cy='form-priority']", $wc).length) {
                cy.get("opencga-clinical-analysis-grid .bootstrap-table .fixed-table-container tr[data-index=0]", {timeout: TIMEOUT})
                    .find("td:nth-child(7) span.label").then($span => {
                        const priority = $span.text().trim();
                        console.error("priority", priority);
                        cy.get("div[data-cy='form-priority'] button").click();
                        cy.get("div[data-cy='form-priority'] ul.dropdown-menu li").contains(priority).click({force: true});
                        checkResults("opencga-clinical-analysis-grid");
                    });
            }
        });

        cy.get("button[data-cy='filter-button']").click({force: true});
        cy.get(".saved-filter-wrapper a").contains("Clear").click({force: true});

    });

    it("5.2 - check Columns togglability", () => {
        cy.get("a[data-id=clinicalAnalysisPortal]", {timeout: TIMEOUT}).click({force: true});
        cy.get("div.page-title h2", {timeout: TIMEOUT}).should("be.visible").and("contain", "Case Portal");


        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper button").should("be.visible").and("contain", "Columns").click();
        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper ul li").should("have.length.gt", 1);


        cy.get("opencga-clinical-analysis-grid .columns-toggle-wrapper ul li a").click({multiple: true, timeout: TIMEOUT}); // deactivate all the columns
        cy.get("opencga-clinical-analysis-grid .bootstrap-table .fixed-table-container tr[data-index=0]", {timeout: TIMEOUT}).find("td", {timeout: TIMEOUT}).should("have.lengthOf", 1);

{'fraction_non_alphanumeric': 0.17881944444444445, 'fraction_numerical': 0.006076388888888889, 'mean_word_length': 2.4785628019323673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4435480', 'n_tokens_mistral': 3445, 'n_tokens_neox': 3250, 'n_words': 639}