<commit_before>﻿import DataProcessingRegistrationOverviewPageObject = require("../PageObjects/Data-Processing/data-processing-registration.overview.po");
import WaitTimers = require("../Utility/WaitTimers");
import LocalDataProcessing = require("../PageObjects/Local-admin/LocalDataProcessing.po");
import KendoToolbarWrapper = require("../Object-wrappers/KendoToolbarWrapper");
import NavigationHelper = require("../Utility/NavigationHelper");
import Select2Helper = require("./Select2Helper");
import DataProcessingRegistrationEditMainPageObject =
    require("../PageObjects/Data-Processing/Tabs/data-processing-registration.edit.main.po");
import DataProcessingRegistrationEditOversightPageObject =
    require("../PageObjects/Data-Processing/Tabs/data-processing-registration.edit.oversight.po");

class DataProcessingRegistrationHelper {
    private static readonly selectBasisForTransferSelectionId: string = "s2id_basisForTransfer_config";
    private static readonly transferToThirdCountriesSelectionId: string = "s2id_transferToInsecureThirdCountries_config";
    private static pageObject = new DataProcessingRegistrationOverviewPageObject();
    private static waitUpTo = new WaitTimers();
    private static kendoToolbarWrapper = new KendoToolbarWrapper();
    private static navigation = new NavigationHelper();
    private static editMainPo = new DataProcessingRegistrationEditMainPageObject();
    private static editOversightPo = new DataProcessingRegistrationEditOversightPageObject();

    public static loadOverview() {
        return this.pageObject.getPage()
            .then(() => browser.waitForAngular())
            .then(() => this.waitForKendo());
    }

    public static createDataProcessingRegistration(name: string) {
        console.log(`Creating registration with name ${name}`);
        return this.pageObject.getPage()
            .then(() => browser.waitForAngular())
            .then(() => this.waitForKendo())
            .then(() => this.openNewDpaDialog())
            .then(() => this.enterDpaName(name))
            .then(() => {
                console.log(`clicking 'save'`);
                this.validateSaveDpaClickable(true);
            })
            .then(() => this.pageObject.getNewDpaSubmitButton().click())
            .then(() => browser.waitForAngular())
            .then(() => this.pageObject.waitForKendoGrid());
    }

    public static checkAndEnableDpaModule() {
        var localDpPo = new LocalDataProcessing();
        return localDpPo
            .getPage()
            .then(() => localDpPo.getToggleDataProcessingCheckbox().isSelected())
            .then((selected) => {
                if (!selected) {
                    return localDpPo.getToggleDataProcessingCheckbox().click();
                }
                return "nop";
            })
            .then(() => browser.waitForAngular());
    }

    public static goToSpecificDataProcessingRegistration(name: string) {
        console.log(`Finding registration: ${name}`);
        return this.pageObject.getPage()
            .then(() => this.pageObject.waitForKendoGrid())
            .then(() => this.findDataProcessingRegistrationColumnFor(name).first().click())
            .then(() => browser.waitForAngular());
    }

    public static goToItSystems() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.it-systems");
    }

    public static goToRoles() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.roles");
    }

    public static goToItContracts() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.contracts");
    }

    public static assignRole(role: string, user: string) {
        console.log("Assigning role: " + role + " to user: " + user);
        return Select2Helper.selectWithNoSearch(role, "s2id_add-role")
            .then(() => Select2Helper.searchFor(user, "s2id_add-user"))
            .then(() => Select2Helper.waitForDataAndSelect());
    }

    public static removeRole(roleName: string, userName: string) {
        console.log("Removing role: ${role} with user: ${user}");<commit_msg>Attempt to fix broken protractor test<commit_after>﻿import DataProcessingRegistrationOverviewPageObject = require("../PageObjects/Data-Processing/data-processing-registration.overview.po");
import WaitTimers = require("../Utility/WaitTimers");
import LocalDataProcessing = require("../PageObjects/Local-admin/LocalDataProcessing.po");
import KendoToolbarWrapper = require("../Object-wrappers/KendoToolbarWrapper");
import NavigationHelper = require("../Utility/NavigationHelper");
import Select2Helper = require("./Select2Helper");
import DataProcessingRegistrationEditMainPageObject =
    require("../PageObjects/Data-Processing/Tabs/data-processing-registration.edit.main.po");
import DataProcessingRegistrationEditOversightPageObject =
    require("../PageObjects/Data-Processing/Tabs/data-processing-registration.edit.oversight.po");

class DataProcessingRegistrationHelper {
    private static readonly selectBasisForTransferSelectionId: string = "s2id_basisForTransfer_config";
    private static readonly transferToThirdCountriesSelectionId: string = "s2id_transferToInsecureThirdCountries_config";
    private static pageObject = new DataProcessingRegistrationOverviewPageObject();
    private static waitUpTo = new WaitTimers();
    private static kendoToolbarWrapper = new KendoToolbarWrapper();
    private static navigation = new NavigationHelper();
    private static editMainPo = new DataProcessingRegistrationEditMainPageObject();
    private static editOversightPo = new DataProcessingRegistrationEditOversightPageObject();

    public static loadOverview() {
        return this.pageObject.getPage()
            .then(() => browser.waitForAngular())
            .then(() => this.waitForKendo());
    }

    public static createDataProcessingRegistration(name: string) {
        console.log(`Creating registration with name ${name}`);
        return this.pageObject.getPage()
            .then(() => browser.waitForAngular())
            .then(() => this.waitForKendo())
            .then(() => this.openNewDpaDialog())
            .then(() => this.enterDpaName(name))
            .then(() => {
                console.log(`clicking 'save'`);
                this.validateSaveDpaClickable(true);
            })
            .then(() => this.pageObject.getNewDpaSubmitButton().click())
            .then(() => browser.waitForAngular())
            .then(() => this.pageObject.waitForKendoGrid());
    }

    public static checkAndEnableDpaModule() {
        var localDpPo = new LocalDataProcessing();
        return localDpPo
            .getPage()
            .then(() => localDpPo.getToggleDataProcessingCheckbox().isSelected())
            .then((selected) => {
                if (!selected) {
                    return localDpPo.getToggleDataProcessingCheckbox().click();
                }
                return "nop";
            })
            .then(() => browser.waitForAngular());
    }

    public static goToSpecificDataProcessingRegistration(name: string) {
        console.log(`Finding registration: ${name}`);
        return this.pageObject.getPage()
            .then(() => this.pageObject.waitForKendoGrid())
            .then(() => this.findDataProcessingRegistrationColumnFor(name).first().click())
            .then(() => browser.waitForAngular());
    }

    public static goToItSystems() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.it-systems")
            .then(() => browser.waitForAngular());
    }

    public static goToRoles() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.roles")
            .then(() => browser.waitForAngular());
    }

    public static goToItContracts() {
        return DataProcessingRegistrationHelper.navigation.goToSubMenuElement("data-processing.edit-registration.contracts")
            .then(() => browser.waitForAngular());
    }

    public static assignRole(role: string, user: string) {
        console.log("Assigning role: " + role + " to user: " + user);
        return Select2Helper.selectWithNoSearch(role, "s2id_add-role")
            .then(() => Select2Helper.searchFor(user, "s2id_add-user"))
            .then(() => Select2Helper.waitForDataAndSelect());
    }

    public static removeRole(roleName: string, userName: string) {
        console.log("Removing role: ${role} with user: ${user}");
{'fraction_non_alphanumeric': 0.12378752886836028, 'fraction_numerical': 0.002078521939953811, 'mean_word_length': 3.3764527539161193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, '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': '2014934', 'n_tokens_mistral': 2242, 'n_tokens_neox': 2187, 'n_words': 388}