From 9760380150dc9e74c55940e7fa08545c6f1b72a5 Mon Sep 17 00:00:00 2001 From: S-Harshit <65359506+S-Harshit@users.noreply.github.com> Date: Thu, 4 Mar 2021 18:21:03 +0530 Subject: [PATCH] Added UX Tests for column / Edit cells / Common transforms (#3683) * added tests for common-transforms * Update Replace-Smart-quotes-with-ascii.spec.js * changed spec name convert the column to the number and then test the conversion to text * Used cy.castColumnTo() to cast to-number before testing to-text Co-authored-by: Antonin Delpeuch --- .../Replace-Smart-quotes-with-ascii.spec.js | 37 +++++++++++++++++++ .../common-transforms/to-empty-string.spec.js | 18 +++++++++ .../common-transforms/to-lowercase.spec.js | 18 +++++++++ .../common-transforms/to-null.spec.js | 18 +++++++++ .../common-transforms/to-text.spec.js | 21 +++++++++++ .../common-transforms/to-titlecase.spec.js | 18 +++++++++ .../common-transforms/to-uppercase.spec.js | 18 +++++++++ 7 files changed, 148 insertions(+) create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/Replace-Smart-quotes-with-ascii.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-empty-string.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-lowercase.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-null.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-text.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-titlecase.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-uppercase.spec.js diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/Replace-Smart-quotes-with-ascii.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/Replace-Smart-quotes-with-ascii.spec.js new file mode 100644 index 000000000..fdd56487d --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/Replace-Smart-quotes-with-ascii.spec.js @@ -0,0 +1,37 @@ +describe(__filename, function () { + it('Ensures Smart quotes are replaced by ascii', function () { + const fixture = [ + ['Smartquotes', 'ascii', 'noquote'], + ['“0a”', "'0b'", '0c'], + ['‘1a’', "'1b'", '1c'], + ]; + + cy.loadAndVisitProject(fixture); + + cy.columnActionClick('Smartquotes', [ + 'Edit cells', + 'Common transforms', + 'Replace Smart quotes with ascii', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column Smartquotes' + ); + cy.assertCellEquals(0, 'Smartquotes', '"0a"'); + cy.assertCellEquals(1, 'Smartquotes', "'1a'"); + + cy.columnActionClick('ascii', [ + 'Edit cells', + 'Common transforms', + 'Replace Smart quotes with ascii', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 0 cells in column ascii' + ); + cy.assertCellEquals(0, 'ascii', "'0b'"); + cy.assertCellEquals(1, 'ascii', "'1b'"); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-empty-string.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-empty-string.spec.js new file mode 100644 index 000000000..b6b63d768 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-empty-string.spec.js @@ -0,0 +1,18 @@ +describe(__filename, function () { + it('Ensures value in cells changes to empty string', function () { + cy.loadAndVisitProject('food.mini'); + + cy.columnActionClick('Shrt_Desc', [ + 'Edit cells', + 'Common transforms', + 'To empty string', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column Shrt_Desc: ""' + ); + cy.assertCellEquals(0, 'Shrt_Desc', ''); + cy.assertCellEquals(1, 'Shrt_Desc', ''); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-lowercase.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-lowercase.spec.js new file mode 100644 index 000000000..5c2825fa5 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-lowercase.spec.js @@ -0,0 +1,18 @@ +describe(__filename, function () { + it('Ensure values in cells are converted to lowercase', function () { + cy.loadAndVisitProject('food.mini'); + + cy.columnActionClick('Shrt_Desc', [ + 'Edit cells', + 'Common transforms', + 'To lowercase', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column Shrt_Desc: value.toLowercase()' + ); + cy.assertCellEquals(0, 'Shrt_Desc', 'butter,with salt'); + cy.assertCellEquals(1, 'Shrt_Desc', 'butter,whipped,with salt'); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-null.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-null.spec.js new file mode 100644 index 000000000..78077f2a9 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-null.spec.js @@ -0,0 +1,18 @@ +describe(__filename, function () { + it('Ensure values in cells are converted to null ', function () { + cy.loadAndVisitProject('food.mini'); + + cy.columnActionClick('Shrt_Desc', [ + 'Edit cells', + 'Common transforms', + 'To null', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column Shrt_Desc: null' + ); + cy.assertCellEquals(0, 'Shrt_Desc', null); + cy.assertCellEquals(1, 'Shrt_Desc', null); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-text.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-text.spec.js new file mode 100644 index 000000000..eadaa6e36 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-text.spec.js @@ -0,0 +1,21 @@ +describe(__filename, function () { + it('Ensure number is converted to text', function () { + cy.loadAndVisitProject('food.mini'); + + cy.castColumnTo('NDB_No', 'number'); + + cy.columnActionClick('NDB_No', [ + 'Edit cells', + 'Common transforms', + 'To text', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column NDB_No: value.toString()' + ); + + cy.assertCellEquals(0, 'NDB_No', '1001'); + cy.assertCellEquals(1, 'NDB_No', '1002'); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-titlecase.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-titlecase.spec.js new file mode 100644 index 000000000..35c650818 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-titlecase.spec.js @@ -0,0 +1,18 @@ +describe(__filename, function () { + it('Ensure text conversion to titlecase', function () { + cy.loadAndVisitProject('food.mini'); + + cy.columnActionClick('Shrt_Desc', [ + 'Edit cells', + 'Common transforms', + 'To titlecase', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 2 cells in column Shrt_Desc: value.toTitlecase() ' + ); + cy.assertCellEquals(0, 'Shrt_Desc', 'Butter,with Salt'); + cy.assertCellEquals(1, 'Shrt_Desc', 'Butter,whipped,with Salt'); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-uppercase.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-uppercase.spec.js new file mode 100644 index 000000000..c384d2b1e --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/common-transforms/to-uppercase.spec.js @@ -0,0 +1,18 @@ +describe(__filename, function () { + it('Ensure text conversion to Uppercase', function () { + cy.loadAndVisitProject('food.mini'); + + cy.columnActionClick('Shrt_Desc', [ + 'Edit cells', + 'Common transforms', + 'To uppercase', + ]); + + // Check notification and cell content + cy.assertNotificationContainingText( + 'Text transform on 0 cells in column Shrt_Desc: value.toUppercase()' + ); + cy.assertCellEquals(0, 'Shrt_Desc', 'BUTTER,WITH SALT'); + cy.assertCellEquals(1, 'Shrt_Desc', 'BUTTER,WHIPPED,WITH SALT'); + }); +});