diff --git a/src/test/java/com/kingsrook/qqq/materialdashboard/tests/BulkEditTest.java b/src/test/java/com/kingsrook/qqq/materialdashboard/tests/BulkEditTest.java new file mode 100755 index 0000000..54ec041 --- /dev/null +++ b/src/test/java/com/kingsrook/qqq/materialdashboard/tests/BulkEditTest.java @@ -0,0 +1,114 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.kingsrook.qqq.materialdashboard.tests; + + +import com.kingsrook.qqq.materialdashboard.lib.QBaseSeleniumTest; +import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin; +import org.junit.jupiter.api.Test; + + +/******************************************************************************* + ** Test for the scripts table + *******************************************************************************/ +public class BulkEditTest extends QBaseSeleniumTest +{ + + /******************************************************************************* + ** + *******************************************************************************/ + @Override + protected void addJavalinRoutes(QSeleniumJavalin qSeleniumJavalin) + { + super.addJavalinRoutes(qSeleniumJavalin); + addCommonRoutesForThisTest(qSeleniumJavalin); + qSeleniumJavalin + .withRouteToFile("/metaData/process/person.bulkEdit", "metaData/process/person.bulkEdit.json") + .withRouteToFile("/processes/person.bulkEdit/init", "/processes/person.bulkEdit/init.json") + .withRouteToFile("/processes/person.bulkEdit/74a03a7d-2f53-4784-9911-3a21f7646c43/step/edit", "/processes/person.bulkEdit/step/edit.json") + .withRouteToFile("/processes/person.bulkEdit/74a03a7d-2f53-4784-9911-3a21f7646c43/step/review", "/processes/person.bulkEdit/step/review.json") + ; + } + + + + /******************************************************************************* + ** + *******************************************************************************/ + private void addCommonRoutesForThisTest(QSeleniumJavalin qSeleniumJavalin) + { + qSeleniumJavalin.withRouteToFile("/data/person/count", "data/person/count.json"); + qSeleniumJavalin.withRouteToFile("/data/person/query", "data/person/index.json"); + } + + + + /******************************************************************************* + ** + *******************************************************************************/ + @Test + // @RepeatedTest(100) + void test() + { + qSeleniumLib.gotoAndWaitForBreadcrumbHeader("/peopleApp/greetingsApp/person", "Person"); + qSeleniumLib.waitForSelectorContaining("button", "selection").click(); + qSeleniumLib.waitForSelectorContaining("li", "This page").click(); + qSeleniumLib.waitForSelectorContaining("div", "records on this page are selected"); + + qSeleniumLib.waitForSelectorContaining("button", "action").click(); + qSeleniumLib.waitForSelectorContaining("li", "bulk edit").click(); + + ///////////////// + // edit screen // + ///////////////// + qSeleniumLib.waitForSelector("#bulkEditSwitch-firstName").click(); + qSeleniumLib.waitForSelector("input[name=firstName]").click(); + qSeleniumLib.waitForSelector("input[name=firstName]").sendKeys("John"); + qSeleniumLib.waitForSelectorContaining("button", "next").click(); + + /////////////////////// + // validation screen // + /////////////////////// + qSeleniumLib.waitForSelectorContaining("span", "How would you like to proceed").click(); + qSeleniumLib.waitForSelectorContaining("button", "next").click(); + + ////////////////////////////////////////////////////////////// + // need to change the result of the 'review' step this time // + ////////////////////////////////////////////////////////////// + qSeleniumLib.waitForSelectorContaining("div", "Person Bulk Edit: Review").click(); + qSeleniumJavalin.clearRoutes(); + qSeleniumJavalin.stop(); + addCommonRoutesForThisTest(qSeleniumJavalin); + qSeleniumJavalin.withRouteToFile("/processes/person.bulkEdit/74a03a7d-2f53-4784-9911-3a21f7646c43/step/review", "/processes/person.bulkEdit/step/review-result.json"); + qSeleniumJavalin.restart(); + qSeleniumLib.waitForSelectorContaining("button", "submit").click(); + + /////////////////// + // result screen // + /////////////////// + qSeleniumLib.waitForSelectorContaining("div", "Person Bulk Edit: Result").click(); + qSeleniumLib.waitForSelectorContaining("button", "close").click(); + + // qSeleniumLib.waitForever(); + } + +} diff --git a/src/test/resources/fixtures/processes/person.bulkEdit/step/edit.json b/src/test/resources/fixtures/processes/person.bulkEdit/step/edit.json index b3e0fde..40a417b 100644 --- a/src/test/resources/fixtures/processes/person.bulkEdit/step/edit.json +++ b/src/test/resources/fixtures/processes/person.bulkEdit/step/edit.json @@ -1,12 +1,24 @@ { - "values": { - "firstName": "Kahhhhn", - "valuesBeingUpdated": "First Name will be set to: Kahhhhn", - "bulkEditEnabledFields": "firstName", - "recordsParam": "recordIds", - "recordIds": "1,2,3,4,5", - "queryFilterJSON": "{\"criteria\":[{\"fieldName\":\"id\",\"operator\":\"IN\",\"values\":[\"1\",\"2\",\"3\",\"4\",\"5\"]}]}" - }, - "processUUID": "74a03a7d-2f53-4784-9911-3a21f7646c43", - "nextStep": "review" -} + "values": { + "transactionLevel": "process", + "tableName": "person", + "recordsParam": "recordIds", + "supportsFullValidation": true, + "recordIds": "1,2,3,4,5", + "sourceTable": "person", + "extract": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep", + "codeType": "JAVA" + }, + "recordCount": 5, + "previewMessage": "This is a preview of the records that will be updated.", + "transform": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.bulk.edit.BulkEditTransformStep", + "codeType": "JAVA" + }, + "destinationTable": "person", + "bulkEditEnabledFields": "firstName" + }, + "processUUID": "74a03a7d-2f53-4784-9911-3a21f7646c43", + "nextStep": "review" +} \ No newline at end of file diff --git a/src/test/resources/fixtures/processes/person.bulkEdit/step/review-result.json b/src/test/resources/fixtures/processes/person.bulkEdit/step/review-result.json new file mode 100644 index 0000000..c7b2417 --- /dev/null +++ b/src/test/resources/fixtures/processes/person.bulkEdit/step/review-result.json @@ -0,0 +1,60 @@ +{ + "values": { + "transactionLevel": "process", + "tableName": "person", + "recordsParam": "recordIds", + "supportsFullValidation": true, + "doFullValidation": true, + "recordIds": "1,2,3,4,5", + "sourceTable": "person", + "extract": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep", + "codeType": "JAVA" + }, + "validationSummary": [ + { + "status": "OK", + "count": 5, + "message": "Person records will be edited.", + "singularFutureMessage": "Person record will be edited.", + "pluralFutureMessage": "Person records will be edited.", + "singularPastMessage": "Person record was edited.", + "pluralPastMessage": "Person records were edited." + }, + { + "status": "INFO", + "message": "First name will be set to John" + } + ], + "recordCount": 5, + "previewMessage": "This is a preview of the records that will be updated.", + "transform": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.bulk.edit.BulkEditTransformStep", + "codeType": "JAVA" + }, + "destinationTable": "person", + "bulkEditEnabledFields": "firstName", + "processResults": [ + { + "status": "OK", + "count": 5, + "message": "Person records were edited.", + "singularFutureMessage": "Person record will be edited.", + "pluralFutureMessage": "Person records will be edited.", + "singularPastMessage": "Person record was edited.", + "pluralPastMessage": "Person records were edited." + }, + { + "status": "INFO", + "message": "Mapping Exception Type was cleared out" + } + ], + "load": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.LoadViaUpdateStep", + "codeType": "JAVA" + }, + "basepullReadyToUpdateTimestamp": true + }, + "processUUID": "74a03a7d-2f53-4784-9911-3a21f7646c43", + "nextStep": "result" +} \ No newline at end of file diff --git a/src/test/resources/fixtures/processes/person.bulkEdit/step/review.json b/src/test/resources/fixtures/processes/person.bulkEdit/step/review.json new file mode 100644 index 0000000..3f34c35 --- /dev/null +++ b/src/test/resources/fixtures/processes/person.bulkEdit/step/review.json @@ -0,0 +1,40 @@ +{ + "values": { + "transactionLevel": "process", + "tableName": "person", + "recordsParam": "recordIds", + "supportsFullValidation": true, + "doFullValidation": true, + "recordIds": "1,2,3,4,5", + "sourceTable": "person", + "extract": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep", + "codeType": "JAVA" + }, + "validationSummary": [ + { + "status": "OK", + "count": 5, + "message": "Person records will be edited.", + "singularFutureMessage": "Person record will be edited.", + "pluralFutureMessage": "Person records will be edited.", + "singularPastMessage": "Person record was edited.", + "pluralPastMessage": "Person records were edited." + }, + { + "status": "INFO", + "message": "First name will be set to John" + } + ], + "recordCount": 5, + "previewMessage": "This is a preview of the records that will be updated.", + "transform": { + "name": "com.kingsrook.qqq.backend.core.processes.implementations.bulk.edit.BulkEditTransformStep", + "codeType": "JAVA" + }, + "destinationTable": "person", + "bulkEditEnabledFields": "firstName" + }, + "processUUID": "74a03a7d-2f53-4784-9911-3a21f7646c43", + "nextStep": "review" +} \ No newline at end of file