<commit_before>﻿import Login = require("../Helpers/LoginHelper");
import DataProcessing = require("../PageObjects/Local-admin/LocalDataProcessing.po");
import TestFixtureWrapper = require("../Utility/TestFixtureWrapper");
import NavigationBarHelper = require("../object-wrappers/navigationBarWrapper");
import SystemCatalogHelper = require("../Helpers/SystemCatalogHelper");
import SystemUsageHelper = require("../Helpers/SystemUsageHelper");
import LocalItSystemNavigation = require("../Helpers/SideNavigation/LocalItSystemNavigation");
import SystemTabGDPR = require("../PageObjects/it-system/Usage/Tabs/ItSystemUsageGDPR.po");

describe("Local admin is able to toggle DataProcessing", () => {

    var loginHelper = new Login();
    var dpPageHelper = new DataProcessing();
    var testFixture = new TestFixtureWrapper();
    var naviHelper = new NavigationBarHelper();
    var systemName = createItSystemName(1);

    beforeAll(() => {
        testFixture.enableLongRunningTest();
        loginHelper.loginAsGlobalAdmin();
        SystemCatalogHelper.createSystem(systemName);
        SystemCatalogHelper.createLocalSystem(systemName);
        loginHelper.logout();
        loginHelper.loginAsLocalAdmin();
    });

    afterAll(() => {
        testFixture.cleanupState();
        testFixture.disableLongRunningTest();
    });

    it("Option to toggle DataProcessing is visible", () => {
        dpPageHelper.getPage()
            .then(() => expect((dpPageHelper.getToggleDataProcessingCheckbox()).isPresent()).toBe(true));
    });

    it("Is able to toggle DataProcessing checkbox", () => {
        var isDataProcessingEnabled;
        dpPageHelper.getPage()
            .then(async () => isDataProcessingEnabled = await dpPageHelper.getToggleDataProcessingCheckbox().isSelected())
            .then(() => checkSystemGdprPageDataProcessingVisibility(isDataProcessingEnabled, systemName))
            .then(() => dpPageHelper.getPage())
            .then(() => expectCheckboxValueToBe(isDataProcessingEnabled))
            .then(() => expectSystemGdprDataProcessingViewToBe(isDataProcessingEnabled))
            .then(() => dpPageHelper.getToggleDataProcessingCheckbox().click())
            .then(() => browser.waitForAngular())
            .then(() => browser.refresh())
            .then(() => expectCheckboxValueToBe(!isDataProcessingEnabled))
            .then(() => expectSystemGdprDataProcessingViewToBe(!isDataProcessingEnabled) )
            .then(() => checkSystemGdprPageDataProcessingVisibility(!isDataProcessingEnabled, systemName));

    });

    function checkSystemGdprPageDataProcessingVisibility(visibility: boolean, sysName: string) {
        SystemUsageHelper.openLocalSystem(sysName)
            .then(() => LocalItSystemNavigation.openGDPRPage())
            .then(() => expect((SystemTabGDPR.getDataProcessingAgreementView()).isPresent()).toBe(visibility));
    }<commit_msg>Removed not neccesary refresh<commit_after>﻿import Login = require("../Helpers/LoginHelper");
import DataProcessing = require("../PageObjects/Local-admin/LocalDataProcessing.po");
import TestFixtureWrapper = require("../Utility/TestFixtureWrapper");
import NavigationBarHelper = require("../object-wrappers/navigationBarWrapper");
import SystemCatalogHelper = require("../Helpers/SystemCatalogHelper");
import SystemUsageHelper = require("../Helpers/SystemUsageHelper");
import LocalItSystemNavigation = require("../Helpers/SideNavigation/LocalItSystemNavigation");
import SystemTabGDPR = require("../PageObjects/it-system/Usage/Tabs/ItSystemUsageGDPR.po");

describe("Local admin is able to toggle DataProcessing", () => {

    var loginHelper = new Login();
    var dpPageHelper = new DataProcessing();
    var testFixture = new TestFixtureWrapper();
    var naviHelper = new NavigationBarHelper();
    var systemName = createItSystemName(1);

    beforeAll(() => {
        testFixture.enableLongRunningTest();
        loginHelper.loginAsGlobalAdmin();
        SystemCatalogHelper.createSystem(systemName);
        SystemCatalogHelper.createLocalSystem(systemName);
        loginHelper.logout();
        loginHelper.loginAsLocalAdmin();
    });

    afterAll(() => {
        testFixture.cleanupState();
        testFixture.disableLongRunningTest();
    });

    it("Option to toggle DataProcessing is visible", () => {
        dpPageHelper.getPage()
            .then(() => expect((dpPageHelper.getToggleDataProcessingCheckbox()).isPresent()).toBe(true));
    });

    it("Is able to toggle DataProcessing checkbox", () => {
        var isDataProcessingEnabled;
        dpPageHelper.getPage()
            .then(async () => isDataProcessingEnabled = await dpPageHelper.getToggleDataProcessingCheckbox().isSelected())
            .then(() => checkSystemGdprPageDataProcessingVisibility(isDataProcessingEnabled, systemName))
            .then(() => dpPageHelper.getPage())
            .then(() => expectCheckboxValueToBe(isDataProcessingEnabled))
            .then(() => expectSystemGdprDataProcessingViewToBe(isDataProcessingEnabled))
            .then(() => dpPageHelper.getToggleDataProcessingCheckbox().click())
            .then(() => browser.waitForAngular())
            .then(() => expectCheckboxValueToBe(!isDataProcessingEnabled))
            .then(() => expectSystemGdprDataProcessingViewToBe(!isDataProcessingEnabled) )
            .then(() => checkSystemGdprPageDataProcessingVisibility(!isDataProcessingEnabled, systemName));

    });

    function checkSystemGdprPageDataProcessingVisibility(visibility: boolean, sysName: string) {
        SystemUsageHelper.openLocalSystem(sysName)
            .then(() => LocalItSystemNavigation.openGDPRPage())
            .then(() => expect((SystemTabGDPR.getDataProcessingAgreementView()).isPresent()).toBe(visibility));
    }
{'fraction_non_alphanumeric': 0.13072799584990488, 'fraction_numerical': 0.0003458412588621823, 'mean_word_length': 4.087071240105541, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 40, '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': '5833264', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1448, 'n_words': 229}