<commit_before>'use strict';

module.exports = function () {
    this.World = require('../support/world.js').World;

    this.When(/^я увижу в таблице "([^"]*)" строку под номером "([^"]*)" со значением "([^"]*)"$/, function (dataGridName, rowIndex, values) {
        var selector = this.selectors.XPATH.DataGrid.body(dataGridName);
        var xpath = this.by.xpath(selector);
        var that = this;

        rowIndex = parseInt(rowIndex);
        values = values.split('|');
        values.splice(0, 1);
        values.splice(values.length - 1, 1);

        this.assert.isNumber(rowIndex);

        return this.currentView.findElement(xpath).then(function (dataGrid) {
            selector = that.selectors.XPATH.DataGrid.rows();
            xpath = that.by.xpath(selector);

            return dataGrid.findElements(xpath).then(function (rows) {
                selector = that.selectors.XPATH.DataGrid.cells();
                xpath = that.by.xpath(selector);

                if(rows.length < rowIndex + 1) {
                    throw new Error('Требуется ' + (rowIndex + 1) + ' строка, всего строк - ' + rows.length);
                }

                return rows[rowIndex].findElements(xpath).then(function (cells) {
                    cells.forEach(function (cell, i) {
                        var expected = values[i].replace(/''/g, '"');
                        cell.getText().then(function (text) {
                            text = text.trim();
                            if (expected != '***') {
                                that.assert.equal(text, expected);
                            }
                        });
                    });
                });
            });
        });
    });

    this.When(/^я отмечу в таблице "([^"]*)" строку под номером "([^"]*)"$/, function (dataGridName, rowIndex) {
        var selector = this.selectors.XPATH.DataGrid.body(dataGridName);
        var xpath = this.by.xpath(selector);
        var that = this;

        rowIndex = parseInt(rowIndex);

        this.assert.isNumber(rowIndex);

        return this.currentView.findElement(xpath)
            .then(function (dataGrid) {
                selector = that.selectors.XPATH.DataGrid.rows();
                xpath = that.by.xpath(selector);

                return dataGrid.findElements(xpath);
            })
            .then(function (rows) {
                selector = that.selectors.XPATH.DataGrid.toggle();
                xpath = that.by.xpath(selector);

                if(rows.length < rowIndex + 1) {
                    throw new Error('Требуется ' + (rowIndex + 1) + ' строка, всего строк - ' + rows.length);
                }

                return rows[rowIndex].findElement(xpath);
            })
            .then(function (toggleCell) {
                return toggleCell.click();
            });
    });
};<commit_msg>UI-2210: Конструкция " Я увижу пустую таблицу" #resolved<commit_after>'use strict';

module.exports = function () {
    this.World = require('../support/world.js').World;

    this.When(/^я увижу в таблице "([^"]*)" строку под номером "([^"]*)" со значением "([^"]*)"$/, function (dataGridName, rowIndex, values) {
        var selector = this.selectors.XPATH.DataGrid.body(dataGridName);
        var xpath = this.by.xpath(selector);
        var that = this;

        rowIndex = parseInt(rowIndex);
        values = values.split('|');
        values.splice(0, 1);
        values.splice(values.length - 1, 1);

        this.assert.isNumber(rowIndex);

        return this.currentView.findElement(xpath).then(function (dataGrid) {
            selector = that.selectors.XPATH.DataGrid.rows();
            xpath = that.by.xpath(selector);

            return dataGrid.findElements(xpath).then(function (rows) {
                selector = that.selectors.XPATH.DataGrid.cells();
                xpath = that.by.xpath(selector);

                if (rows.length < rowIndex + 1) {
                    throw new Error('Требуется ' + (rowIndex + 1) + ' строка, всего строк - ' + rows.length);
                }

                return rows[rowIndex].findElements(xpath).then(function (cells) {
                    cells.forEach(function (cell, i) {
                        var expected = values[i].replace(/''/g, '"');
                        cell.getText().then(function (text) {
                            text = text.trim();
                            if (expected != '***') {
                                that.assert.equal(text, expected);
                            }
                        });
                    });
                });
            });
        });
    });

    this.When(/^я отмечу в таблице "([^"]*)" строку под номером "([^"]*)"$/, function (dataGridName, rowIndex) {
        var selector = this.selectors.XPATH.DataGrid.body(dataGridName);
        var xpath = this.by.xpath(selector);
        var that = this;

        rowIndex = parseInt(rowIndex);

        this.assert.isNumber(rowIndex);

        return this.currentView.findElement(xpath)
            .then(function (dataGrid) {
                selector = that.selectors.XPATH.DataGrid.rows();
                xpath = that.by.xpath(selector);

                return dataGrid.findElements(xpath);
            })
            .then(function (rows) {
                selector = that.selectors.XPATH.DataGrid.toggle();
                xpath = that.by.xpath(selector);

                if (rows.length < rowIndex + 1) {
                    throw new Error('Требуется ' + (rowIndex + 1) + ' строка, всего строк - ' + rows.length);
                }

                return rows[rowIndex].findElement(xpath);
            })
            .then(function (toggleCell) {
                return toggleCell.click();
            });
    });

    this.When(/^я увижу пустую таблицу "([^"]*)"$/, function (tableName) {
        var selector = this.selectors.XPATH.DataGrid.body(tableName);
        var xpath = this.by.xpath(selector);
        var that = this;

        return this.currentView.findElement(xpath)
            .then(function (table) {
                selector = that.selectors.XPATH.DataGrid.rows();
                xpath = that.by.xpath(selector);

                return table.findElements(xpath);
            })
            .then(function (rows) {
                that.assert.equal(rows.length, 0);
            });
    });
};
{'fraction_non_alphanumeric': 0.14101556359063042, 'fraction_numerical': 0.0033013677094796416, 'mean_word_length': 1.6289256198347108, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '7585833', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1819, 'n_words': 311}