From 907534d9cdba9f8b13411efaed990dfa8f9cab20 Mon Sep 17 00:00:00 2001 From: Aref Shafaei Date: Tue, 12 Sep 2023 19:28:48 -0700 Subject: [PATCH] add skeleton for testing multi-form-input feature --- Makefile | 4 +- .../parallel-configs/default-config.dev.json | 2 +- .../config/recordedit/add-multi.config.json | 15 -- .../config/recordedit/add-multi.dev.json | 9 - .../recordedit/multi-form-input.config.json | 15 ++ .../recordedit/multi-form-input.dev.json | 9 + test/e2e/data_setup/data/multi-add/f1.json | 5 - .../main.json} | 0 .../schema/recordedit/multi-add.json | 171 ------------------ .../schema/recordedit/multi-form-input.json | 25 +++ .../recordedit/add.spec.js | 2 +- .../recordedit/immutable-inputs.spec.js | 4 +- .../recordedit/multi-form-input.conf.js | 15 ++ .../recordedit/multi-form-input.spec.js | 84 +++++++++ test/e2e/utils/chaise.page.js | 4 +- test/e2e/utils/recordedit-helpers.js | 4 +- 16 files changed, 158 insertions(+), 210 deletions(-) delete mode 100644 test/e2e/data_setup/config/recordedit/add-multi.config.json delete mode 100644 test/e2e/data_setup/config/recordedit/add-multi.dev.json create mode 100644 test/e2e/data_setup/config/recordedit/multi-form-input.config.json create mode 100644 test/e2e/data_setup/config/recordedit/multi-form-input.dev.json delete mode 100644 test/e2e/data_setup/data/multi-add/f1.json rename test/e2e/data_setup/data/{multi-add/multi-add-table.json => multi-form-input/main.json} (100%) delete mode 100644 test/e2e/data_setup/schema/recordedit/multi-add.json create mode 100644 test/e2e/data_setup/schema/recordedit/multi-form-input.json create mode 100644 test/e2e/specs/default-config/recordedit/multi-form-input.conf.js create mode 100644 test/e2e/specs/default-config/recordedit/multi-form-input.spec.js diff --git a/Makefile b/Makefile index 19cb15b38..945b40df5 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ E2EDIrecordImmutable=test/e2e/specs/default-config/recordedit/immutable-inputs.c E2EDIrecordEdit=test/e2e/specs/all-features-confirmation/recordedit/edit-delete.conf.js # not part of the make recordedit command anymore # E2ErecordEditNoDeleteBtn=test/e2e/specs/delete-prohibited/recordedit/no-delete-btn.conf.js -E2EDIrecordMultiAdd=test/e2e/specs/default-config/recordedit/add-x-forms.conf.js +E2EDIrecordMultiFormInput=test/e2e/specs/default-config/recordedit/multi-form-input.conf.js E2EDIrecordMultiEdit=test/e2e/specs/default-config/recordedit/multi-edit.conf.js E2EDrecordEditCompositeKey=test/e2e/specs/default-config/recordedit/composite-key.conf.js E2EDrecordEditDomainFilter=test/e2e/specs/default-config/recordedit/domain-filter.conf.js @@ -92,7 +92,7 @@ Manualrecordset=test/manual/specs/recordset.conf.js NAVBAR_TESTS=$(E2Enavbar) $(E2EnavbarHeadTitle) $(E2EnavbarCatalogConfig) RECORD_TESTS=$(E2EDrecord) $(E2ErecordNoDeleteBtn) $(E2EDrecordRelatedTable) $(E2EDrecordCopy) $(E2EDrecordLinks) RECORDSET_TESTS=$(E2EDrecordset) $(E2ErecordsetAdd) $(E2EDrecordsetEdit) $(E2EDrecordsetIndFacet) $(E2EDrecordsetHistFacet) $(E2ErecordsetSavedQuery) -RECORDADD_TESTS=$(E2EDIrecordAdd) $(E2EDIrecordMultiAdd) $(E2EDIrecordImmutable) $(E2ErecordEditForeignKeyDropdown) +RECORDADD_TESTS=$(E2EDIrecordAdd) $(E2EDIrecordMultiFormInput) $(E2EDIrecordImmutable) $(E2ErecordEditForeignKeyDropdown) RECORDEDIT_TESTS=$(E2EDIrecordEdit) $(E2EDIrecordMultiEdit) $(E2EDrecordEditCompositeKey) $(E2EDrecordEditSubmissionDisabled) $(E2EDIrecordEditMultiColTypes) $(E2EDrecordEditDomainFilter) $(E2ErecordEditInputIframe) PERMISSIONS_TESTS=$(E2EmultiPermissionsVisibility) FOOTER_TESTS=$(E2Efooter) diff --git a/test/e2e/data_setup/config/parallel-configs/default-config.dev.json b/test/e2e/data_setup/config/parallel-configs/default-config.dev.json index a394de63f..204dc36da 100644 --- a/test/e2e/data_setup/config/parallel-configs/default-config.dev.json +++ b/test/e2e/data_setup/config/parallel-configs/default-config.dev.json @@ -4,7 +4,7 @@ "record/links.config.json", "recordedit/immutable-inputs.config.json", - "recordedit/add-multi.config.json", + "recordedit/multi-form-input.config.json", "recordedit/composite-key.config.json", "recordedit/domain-filter.config.json", "recordedit/foreign-key-dropdown.config.json", diff --git a/test/e2e/data_setup/config/recordedit/add-multi.config.json b/test/e2e/data_setup/config/recordedit/add-multi.config.json deleted file mode 100644 index 324862e37..000000000 --- a/test/e2e/data_setup/config/recordedit/add-multi.config.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "catalog": {}, - "schema": { - "name": "multi-add", - "createNew": true, - "path": "test/e2e/data_setup/schema/recordedit/multi-add.json" - }, - "tables": { - "createNew": true - }, - "entities": { - "createNew": true, - "path": "test/e2e/data_setup/data/multi-add" - } -} diff --git a/test/e2e/data_setup/config/recordedit/add-multi.dev.json b/test/e2e/data_setup/config/recordedit/add-multi.dev.json deleted file mode 100644 index 9eea04b66..000000000 --- a/test/e2e/data_setup/config/recordedit/add-multi.dev.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "setup": { - "schemaConfigurations": [ - "recordedit/add-multi.config.json" - ], - "schema": "multi-add" - }, - "cleanup" : true -} diff --git a/test/e2e/data_setup/config/recordedit/multi-form-input.config.json b/test/e2e/data_setup/config/recordedit/multi-form-input.config.json new file mode 100644 index 000000000..05c46c9ad --- /dev/null +++ b/test/e2e/data_setup/config/recordedit/multi-form-input.config.json @@ -0,0 +1,15 @@ +{ + "catalog": {}, + "schema": { + "name": "multi-form-input", + "createNew": true, + "path": "test/e2e/data_setup/schema/recordedit/multi-form-input.json" + }, + "tables": { + "createNew": true + }, + "entities": { + "createNew": true, + "path": "test/e2e/data_setup/data/multi-form-input" + } +} diff --git a/test/e2e/data_setup/config/recordedit/multi-form-input.dev.json b/test/e2e/data_setup/config/recordedit/multi-form-input.dev.json new file mode 100644 index 000000000..ae8800093 --- /dev/null +++ b/test/e2e/data_setup/config/recordedit/multi-form-input.dev.json @@ -0,0 +1,9 @@ +{ + "setup": { + "schemaConfigurations": [ + "recordedit/multi-form-input.config.json" + ], + "schema": "multi-form-input" + }, + "cleanup" : true +} diff --git a/test/e2e/data_setup/data/multi-add/f1.json b/test/e2e/data_setup/data/multi-add/f1.json deleted file mode 100644 index 8ac956fac..000000000 --- a/test/e2e/data_setup/data/multi-add/f1.json +++ /dev/null @@ -1,5 +0,0 @@ -[{"id": 1, "term": "one"}, - {"id": 2, "term": "two"}, - {"id": 3, "term": "three"}, - {"id": 4, "term": "four"}, - {"id": 5, "term": "five"}] diff --git a/test/e2e/data_setup/data/multi-add/multi-add-table.json b/test/e2e/data_setup/data/multi-form-input/main.json similarity index 100% rename from test/e2e/data_setup/data/multi-add/multi-add-table.json rename to test/e2e/data_setup/data/multi-form-input/main.json diff --git a/test/e2e/data_setup/schema/recordedit/multi-add.json b/test/e2e/data_setup/schema/recordedit/multi-add.json deleted file mode 100644 index 1eb0f2a04..000000000 --- a/test/e2e/data_setup/schema/recordedit/multi-add.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "schema_name": "multi-add", - "tables": { - "multi-add-table": { - "comment": "Table to represent adding multiple entities", - "kind": "table", - "keys": [ - { - "comment": null, - "annotations": {}, - "unique_columns": [ - "id" - ] - } - ], - "foreign_keys": [ - { - "names": [["multi-add", "fk1"]], - "foreign_key_columns": [ - { - "column_name": "fk_to_f1", - "table_name": "multi-add-table", - "schema_name": "multi-add" - } - ], - "referenced_columns": [ - { - "column_name": "id", - "table_name": "f1", - "schema_name": "multi-add" - } - ] - } - ], - "table_name": "multi-add-table", - "schema_name": "multi-add", - "column_definitions": [ - { - "name": "id", - "default": null, - "nullok": false, - "type": { - "typename": "serial4" - }, - "annotations": { - "comment": [ - "hidden" - ], - "tag:isrd.isi.edu,2016:generated": null, - "tag:isrd.isi.edu,2016:immutable": null - } - }, { - "name": "text", - "nullok": true, - "type": { - "typename": "text" - } - }, { - "name": "int", - "nullok": true, - "type": { - "typename": "int" - } - }, { - "name": "date", - "type": { - "typename": "date" - } - }, { - "name": "timestamp", - "type": { - "typename": "timestamp" - } - }, { - "name": "fk_to_f1", - "type": { - "typename": "int4" - } - }, { - "name": "uri", - "default": null, - "nullok": true, - "type": { - "typename": "text" - }, - "annotations": { - "tag:isrd.isi.edu,2017:asset": { - "url_pattern":"/hatrac/js/chaise/{{{_int}}}/{{{_uri.md5_hex}}}", - "filename_column" : "filename", - "byte_count_column": "bytes", - "md5": "md5" - } - } - }, - { - "comment": null, - "name": "filename", - "default": null, - "nullok": true, - "type": { - "typename": "text" - } - }, - { - "comment": null, - "name": "bytes", - "default": null, - "nullok": true, - "type": { - "typename": "int8" - } - }, - { - "comment": null, - "name": "md5", - "default": null, - "nullok": true, - "type": { - "typename": "text" - } - }, - { - "name": "int_array", - "type": { - "is_array": true, - "typename": "int4[]", - "base_type": { - "typename": "int4" - } - } - } - ], - "annotations": { - "tag:isrd.isi.edu,2016:visible-columns" : { - "*": ["id", "text", "int", "date", "timestamp", ["multi-add", "fk1"], "uri", "int_array"] - } - } - }, - "f1": { - "kind": "table", - "table_name": "f1", - "schema_name": "multi-add", - "keys": [ - {"unique_columns": ["id"]}, - {"unique_columns": ["term"]} - ], - "foreign_keys": [], - "column_definitions": [ - { - "name": "id", - "nullok": false, - "type": { - "typename": "serial4" - } - }, - { - "name": "term", - "type": { - "typename": "text" - } - } - ] - } - }, - "table_names": [ - "multi-add-table", - "f1" - ], - "comment": null, - "annotations": {} -} diff --git a/test/e2e/data_setup/schema/recordedit/multi-form-input.json b/test/e2e/data_setup/schema/recordedit/multi-form-input.json new file mode 100644 index 000000000..e490f2289 --- /dev/null +++ b/test/e2e/data_setup/schema/recordedit/multi-form-input.json @@ -0,0 +1,25 @@ +{ + "schema_name": "multi-form-input", + "tables": { + "main": { + "table_name": "main", + "schema_name": "multi-form-input", + "kind": "table", + "keys": [{"unique_columns": ["id"]}], + "column_definitions": [ + { + "name": "id", + "nullok": false, + "type": { "typename": "serial4" } + }, + { + "name": "text_col", + "nullok": true, + "type": { + "typename": "text" + } + } + ] + } + } +} diff --git a/test/e2e/specs/all-features-confirmation/recordedit/add.spec.js b/test/e2e/specs/all-features-confirmation/recordedit/add.spec.js index cbcb5d75c..caf1270b0 100644 --- a/test/e2e/specs/all-features-confirmation/recordedit/add.spec.js +++ b/test/e2e/specs/all-features-confirmation/recordedit/add.spec.js @@ -258,7 +258,7 @@ describe('Record Add', function() { if (tableParams.files.length == 0) { it("should click and add an extra record.", function(done) { - chaisePage.clickButton(chaisePage.recordEditPage.getMultiFormInputSubmitButton()).then(function () { + chaisePage.clickButton(chaisePage.recordEditPage.getCloneFormInputSubmitButton()).then(function () { done(); }).catch(chaisePage.catchTestError(done)); }); diff --git a/test/e2e/specs/default-config/recordedit/immutable-inputs.spec.js b/test/e2e/specs/default-config/recordedit/immutable-inputs.spec.js index e0ecc1e1f..8f6b20eee 100644 --- a/test/e2e/specs/default-config/recordedit/immutable-inputs.spec.js +++ b/test/e2e/specs/default-config/recordedit/immutable-inputs.spec.js @@ -259,7 +259,7 @@ describe('Record Add with defaults', function() { // Foreign key columns it("should initialize foreign key inputs with their default value.", function() { // the clone will be disabled while data is loading. - browser.wait(EC.elementToBeClickable(chaisePage.recordEditPage.getMultiFormInputSubmitButton())); + browser.wait(EC.elementToBeClickable(chaisePage.recordEditPage.getCloneFormInputSubmitButton())); foreignKeyInput = chaisePage.recordEditPage.getForeignKeyInputDisplay("foreign_key", 1); foreignKeyDropdownInput = chaisePage.recordEditPage.getForeignKeyInputDisplay("foreign_key_dropdown", 1); @@ -273,7 +273,7 @@ describe('Record Add with defaults', function() { // Asset columns it("should initialize asset column inputs with their default value.", function() { // the clone btn will be disabled while data is loading. - browser.wait(EC.elementToBeClickable(chaisePage.recordEditPage.getMultiFormInputSubmitButton())); + browser.wait(EC.elementToBeClickable(chaisePage.recordEditPage.getCloneFormInputSubmitButton())); const assetTextInput = chaisePage.recordEditPage.getTextFileInputForAColumn("asset", 1) expect(assetTextInput.getText()).toBe(values.asset_value, "Asset input default is incorrect"); diff --git a/test/e2e/specs/default-config/recordedit/multi-form-input.conf.js b/test/e2e/specs/default-config/recordedit/multi-form-input.conf.js new file mode 100644 index 000000000..0cf713989 --- /dev/null +++ b/test/e2e/specs/default-config/recordedit/multi-form-input.conf.js @@ -0,0 +1,15 @@ +var pConfig = require('./../../../utils/protractor.configuration.js'); + +var config = pConfig.getConfig({ + configFileName: 'recordedit/multi-form-input.dev.json', + chaiseConfigFilePath: 'test/e2e/specs/default-config/chaise-config.js', + specs: [ + "multi-form-input.spec.js" + ], + setBaseUrl: function(browser, data) { + browser.params.url = process.env.CHAISE_BASE_URL; + return browser.params.url; + } +}); + +exports.config = config; diff --git a/test/e2e/specs/default-config/recordedit/multi-form-input.spec.js b/test/e2e/specs/default-config/recordedit/multi-form-input.spec.js new file mode 100644 index 000000000..ee9ad7d0f --- /dev/null +++ b/test/e2e/specs/default-config/recordedit/multi-form-input.spec.js @@ -0,0 +1,84 @@ +const chaisePage = require('../../../utils/chaise.page.js'); +const recordEditPage = chaisePage.recordEditPage; +const recordEditHelpers = require('../../../utils/recordedit-helpers.js'); + +const testParams = { + schema_table: 'multi-form-input:main', + max_input_rows: 200, +}; + +describe('Regarding multi form input and clone button', () => { + describe('Regarding multi form input,', () => { + // TODO + }); + + describe('Regarding clone button, in create mode,', () => { + let cloneFormInput, cloneFormSubmitButton; + + beforeAll((done) => { + chaisePage.navigate(`${browser.params.url}/recordedit/#${browser.params.catalogId}/${testParams.schema_table}`); + chaisePage.recordeditPageReady().then(() => { + cloneFormInput = chaisePage.recordEditPage.getCloneFormInput(); + cloneFormSubmitButton = chaisePage.recordEditPage.getCloneFormInputSubmitButton(); + done(); + }).catch(chaisePage.catchTestError(done)); + }); + + it('it should be visible.', () => { + expect(cloneFormInput.isDisplayed()).toBeTruthy(); + }); + + it('should alert the user when they try to add more forms than the limit allows.', (done) => { + const numberGreaterThanMax = testParams.max_input_rows + 1; + const errorMessage = `Cannot add ${numberGreaterThanMax} records. Please input a value between 1 and ${testParams.max_input_rows}, inclusive.`; + + cloneFormInput.clear().then(() => { + return cloneFormInput.sendKeys(numberGreaterThanMax); + }).then(() => { + return chaisePage.clickButton(cloneFormSubmitButton); + }).then(() => { + return chaisePage.recordEditPage.getAlertError(); + }).then(function (err) { + return err.getText(); + }).then(function (text) { + expect(text.indexOf(errorMessage)).toBeGreaterThan(-1); + done(); + }).catch(chaisePage.catchTestError(done)); + }); + + it('should allow users to add the maximum amount of forms.', (done) => { + cloneFormInput.clear().then(() => { + return cloneFormInput.sendKeys(testParams.max_input_rows); + }).then(() => { + return chaisePage.clickButton(cloneFormSubmitButton); + }).then(() => { + // wait for dom to finish rendering the forms + return browser.wait(() => { + return chaisePage.recordEditPage.getRecordeditForms().count().then(function (ct) { + return (ct == testParams.max_input_rows + 1); + }); + }, browser.params.defaultTimeout); + }).then(() => { + + return chaisePage.recordEditPage.submitForm(); + }).then(() => { + return browser.driver.getCurrentUrl(); + }).then((url) => { + expect(url.startsWith(process.env.CHAISE_BASE_URL + "/recordedit/")).toBe(true); + + // so DOM can render table + return browser.wait(() => { + return chaisePage.recordsetPage.getRows().count().then((ct) => { + return (ct == testParams.max_input_rows + 1); + }); + }, browser.params.defaultTimeout); + }).then(() => { + return chaisePage.recordsetPage.getRows().count(); + }).then((ct) => { + expect(ct).toBe(testParams.max_input_rows + 1); + done(); + }).catch(chaisePage.catchTestError(done)); + }); + }); + +}) diff --git a/test/e2e/utils/chaise.page.js b/test/e2e/utils/chaise.page.js index a65a2dec1..295ed37b5 100644 --- a/test/e2e/utils/chaise.page.js +++ b/test/e2e/utils/chaise.page.js @@ -47,11 +47,11 @@ var recordEditPage = function() { return element.all(by.css('.recordedit-form .form-header')) } - this.getMultiFormInput = function () { + this.getCloneFormInput = function () { return element(by.id("copy-rows-input")); }; - this.getMultiFormInputSubmitButton = function () { + this.getCloneFormInputSubmitButton = function () { return element(by.id("copy-rows-submit")); }; diff --git a/test/e2e/utils/recordedit-helpers.js b/test/e2e/utils/recordedit-helpers.js index 4f6daa536..fc2c20aa3 100644 --- a/test/e2e/utils/recordedit-helpers.js +++ b/test/e2e/utils/recordedit-helpers.js @@ -88,7 +88,7 @@ exports.testPresentationAndBasicValidation = function(tableParams, isEditMode) { }); it("should allow to add new rows/columns", function() { - expect(chaisePage.recordEditPage.getMultiFormInputSubmitButton().isDisplayed()).toBeTruthy("Add x rows is not visible in create mode"); + expect(chaisePage.recordEditPage.getCloneFormInputSubmitButton().isDisplayed()).toBeTruthy("Add x rows is not visible in create mode"); }); } @@ -259,7 +259,7 @@ exports.testPresentationAndBasicValidation = function(tableParams, isEditMode) { describe(title + ",",function() { if (recordIndex > 0) { it("should click add record button", function(done) { - chaisePage.clickButton(chaisePage.recordEditPage.getMultiFormInputSubmitButton()).then(function(button) { + chaisePage.clickButton(chaisePage.recordEditPage.getCloneFormInputSubmitButton()).then(function(button) { return browser.wait(function() { return chaisePage.recordEditPage.getRecordeditForms().count().then(function(ct) { return (ct == recordIndex + 1);