<commit_before>﻿import CatalogPage = require("../PageObjects/it-system/Catalog/ItSystemCatalog.po");
import SystemPage = require("../PageObjects/It-system/Tabs/ItSystemFrontpage.po");
import CSSLocator = require("../object-wrappers/CSSLocatorHelper");
import Constants = require("../Utility/Constants");
import WaitTimers = require("../Utility/WaitTimers");

class CatalogHelper {
    private static consts = new Constants();
    private static cssHelper = new CSSLocator();
    private static pageObject = new CatalogPage();
    private static systemPage = new SystemPage();
    private static waitUpTo = new WaitTimers();

    public static createCatalog(name: string) {
        return this.pageObject.getPage()
            .then(() => {
                return this.pageObject.kendoToolbarWrapper.headerButtons().systemCatalogCreate.click();
            })
            .then(() => {
                return browser.wait(this.pageObject.isCreateCatalogAvailable(), this.waitUpTo.twentySeconds);
            })
            .then(() => {
                return element(this.cssHelper.byDataElementType(this.consts.nameOfSystemInput)).sendKeys(name);
            })
            .then(() => {
                return element(this.cssHelper.byDataElementType(this.consts.saveCatalogButton)).click();
            });
    }

    public static deleteCatalog(name: string) {
        return this.pageObject.getPage()
            .then(() => {
                return this.waitForKendoGrid();
            })
            .then(() => {
                return this.findCatalogColumnsFor(name).first().click();
            })
            .then(() => {
                return browser.wait(this.systemPage.isDeleteButtonLoaded(), this.waitUpTo.twentySeconds);
            })
            .then(() => {
                return this.systemPage.getDeleteButton().click();
            })
            .then(() => {
                return browser.switchTo().alert().accept();
            });
    }

    public static findCatalogColumnsFor(name: string) {
        return this.pageObject.kendoToolbarWrapper.getFilteredColumnElement(this.pageObject.kendoToolbarWrapper.columnObjects().catalogName, name);
    }

    public static waitForKendoGrid() {
        console.log("Waiting for kendo grid to be ready");
        return browser.wait(this.pageObject.waitForKendoGrid(), this.waitUpTo.twentySeconds);
    }
}

export = CatalogHelper;<commit_msg>fix catalog helper<commit_after>﻿import CatalogPage = require("../PageObjects/it-system/Catalog/ItSystemCatalog.po");
import SystemPage = require("../PageObjects/It-system/Tabs/ItSystemFrontpage.po");
import CSSLocator = require("../object-wrappers/CSSLocatorHelper");
import Constants = require("../Utility/Constants");
import WaitTimers = require("../Utility/WaitTimers");

class CatalogHelper {
    private static consts = new Constants();
    private static cssHelper = new CSSLocator();
    private static pageObject = new CatalogPage();
    private static systemPage = new SystemPage();
    private static waitUpTo = new WaitTimers();

    public static createCatalog(name: string) {
        return CatalogHelper.pageObject.getPage()
            .then(() => {
                return CatalogHelper.pageObject.kendoToolbarWrapper.headerButtons().systemCatalogCreate.click();
            })
            .then(() => {
                return browser.wait(CatalogHelper.pageObject.isCreateCatalogAvailable(), CatalogHelper.waitUpTo.twentySeconds);
            })
            .then(() => {
                return element(CatalogHelper.cssHelper.byDataElementType(CatalogHelper.consts.nameOfSystemInput)).sendKeys(name);
            })
            .then(() => {
                return element(CatalogHelper.cssHelper.byDataElementType(CatalogHelper.consts.saveCatalogButton)).click();
            });
    }

    public static deleteCatalog(name: string) {
        return CatalogHelper.pageObject.getPage()
            .then(() => {
                return CatalogHelper.waitForKendoGrid();
            })
            .then(() => {
                return CatalogHelper.findCatalogColumnsFor(name).first().click();
            })
            .then(() => {
                return browser.wait(CatalogHelper.systemPage.isDeleteButtonLoaded(), CatalogHelper.waitUpTo.twentySeconds);
            })
            .then(() => {
                return CatalogHelper.systemPage.getDeleteButton().click();
            })
            .then(() => {
                return browser.switchTo().alert().accept();
            });
    }

    public static findCatalogColumnsFor(name: string) {
        return CatalogHelper.pageObject.kendoToolbarWrapper.getFilteredColumnElement(CatalogHelper.pageObject.kendoToolbarWrapper.columnObjects().catalogName, name);
    }

    public static waitForKendoGrid() {
        console.log("Waiting for kendo grid to be ready");
        return browser.wait(CatalogHelper.pageObject.waitForKendoGrid(), CatalogHelper.waitUpTo.twentySeconds);
    }
}

export = CatalogHelper;
{'fraction_non_alphanumeric': 0.1258741258741259, 'fraction_numerical': 0.0, 'mean_word_length': 2.5680684248039913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '5892396', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1287, 'n_words': 211}