added test for replace and transform (#4196)

Added test for replace and transform
This commit is contained in:
Ritesh Soni 2021-10-13 13:31:27 +05:30 committed by GitHub
parent a1090bfa19
commit e22ead56a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 216 additions and 0 deletions

View File

@ -0,0 +1,146 @@
describe(__filename, function () {
it('Ensure cells are replaced', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'Change', '1c'],
['2a', 'Change', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type("change");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("a");
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 1 cell');
cy.assertCellEquals(0, 'b', 'a');
cy.assertCellEquals(1, 'b', 'Change');
cy.assertCellEquals(2, 'b', 'Change');
});
it('Ensure cells are replaced case insensitively', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'Change', '1c'],
['2a', 'Change', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type("change");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("a");
cy.get('label[bind="or_views_find_case_insensitive"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 3 cells');
cy.assertCellEquals(0, 'b', 'a');
cy.assertCellEquals(1, 'b', 'a');
cy.assertCellEquals(2, 'b', 'a');
});
it('Ensure cells are replaced with whole word', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'change1', '1c'],
['2a', 'change2', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type("change");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("a");
cy.get('label[bind="or_views_find_whole_word"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 1 cells');
cy.assertCellEquals(0, 'b', 'a');
cy.assertCellEquals(1, 'b', 'change1');
cy.assertCellEquals(2, 'b', 'change2');
});
it('Ensure cells are replaced with regular expression', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'hat', '0c'],
['1a', 'cat', '1c'],
['2a', 'bat', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type("[hc]at");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("a");
cy.get('label[bind="or_views_find_regExp"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 2 cells');
cy.assertCellEquals(0, 'b', 'a');
cy.assertCellEquals(1, 'b', 'a');
cy.assertCellEquals(2, 'b', 'bat');
});
it('Ensure cells are replaced with line ', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'first_name second_name', '0c'],
['1a', 'first_name second_name', '1c'],
['2a', 'first_name', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type(" ");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("\\n");
cy.get('label[bind="or_views_replace_dont_escape"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 2 cells');
cy.assertCellEquals(0, 'b', 'first_name\nsecond_name');
cy.assertCellEquals(1, 'b', 'first_name\nsecond_name');
cy.assertCellEquals(2, 'b', 'first_name');
});
it('Ensure cells are replaced with \\n', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'first_name second_name', '0c'],
['1a', 'first_name second_name', '1c'],
['2a', 'first_name', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Replace']);
cy.get('.dialog-container input[bind="text_to_findInput"]').type(" ");
cy.get('.dialog-container input[bind="replacement_textInput"]').type("\\\\n");
cy.get('label[bind="or_views_replace_dont_escape"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 2 cells');
cy.assertCellEquals(0, 'b', 'first_name\\nsecond_name');
cy.assertCellEquals(1, 'b', 'first_name\\nsecond_name');
cy.assertCellEquals(2, 'b', 'first_name');
});
});

View File

@ -0,0 +1,70 @@
describe(__filename, function () {
it('Ensure cells are transformed', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'change', '1c'],
['2a', 'change', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Transform']);
cy.typeExpression('replace(value,"change","a")');
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 3 cells');
cy.assertCellEquals(0, 'b', 'a');
cy.assertCellEquals(1, 'b', 'a');
cy.assertCellEquals(2, 'b', 'a');
});
it('Ensure cells are set to blank when error occurs', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'change', '1c'],
['2a', 'change', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Transform']);
cy.typeExpression('value.replace()');;
cy.get('label[bind="or_views_setBlank"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 3 cells');
cy.assertCellEquals(0, 'b', '');
cy.assertCellEquals(1, 'b', '');
cy.assertCellEquals(2, 'b', '');
});
it('Ensure cells cells contains error message when error occurs', function () {
const fixture = [
['a', 'b', 'c'],
['0a', 'change', '0c'],
['1a', 'change', '1c'],
['2a', 'change', '2c'],
];
cy.loadAndVisitProject(fixture);
cy.columnActionClick('b', ['Edit cells', 'Transform']);
cy.typeExpression('value.replace()');
cy.get('label[bind="or_views_storeErr"]').click();
cy.confirmDialogPanel();
cy.assertNotificationContainingText('Text transform on 3 cells');
cy.assertCellEquals(0, 'b', 'replace expects 3 strings, or 1 string, 1 regex, and 1 string');
cy.assertCellEquals(1, 'b', 'replace expects 3 strings, or 1 string, 1 regex, and 1 string');
cy.assertCellEquals(2, 'b', 'replace expects 3 strings, or 1 string, 1 regex, and 1 string');
});
});