From c004c4c9c02d74959a5ae38d0fa6a5539a5a64f8 Mon Sep 17 00:00:00 2001 From: Benoit CIVEL Date: Thu, 15 Aug 2024 01:00:38 +0200 Subject: [PATCH] Add 6 conditions (if step, action and control have been executed or not) --- .../core/crud/entity/TestCaseExecution.java | 27 +++ .../entity/TestCaseStepActionExecution.java | 17 ++ .../crud/entity/TestCaseStepExecution.java | 27 +++ .../enums/ConditionOperatorEnum.java | 6 + .../execution/impl/ConditionService.java | 196 ++++++++++++++++++ .../cerberus/core/enums/MessageEventEnum.java | 18 ++ .../manageActionControlOptions.html | 4 + .../main/webapp/js/pages/TestCaseScript.js | 75 +++++++ .../src/main/webapp/js/testcase/condition.js | 12 ++ 9 files changed, 382 insertions(+) diff --git a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseExecution.java b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseExecution.java index 8c5fc09c03..0553f12fed 100644 --- a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseExecution.java +++ b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseExecution.java @@ -318,6 +318,33 @@ public void addcountryEnvApplicationParams(List co }); } + public TestCaseStepExecution getTestCaseStepExecutionBySortId(int sortID){ + for(TestCaseStepExecution tcse : this.testCaseStepExecutionList){ + if (sortID == tcse.getTestCaseStep().getSort()){ + return tcse; + } + } + return null; + } + + public TestCaseStepExecution getTestCaseStepExecutionByStepId(int stepId){ + for(TestCaseStepExecution tcse : this.testCaseStepExecutionList){ + if (stepId == tcse.getTestCaseStep().getStepId()){ + return tcse; + } + } + return null; + } + + public TestCaseStepExecution getTestCaseStepExecutionExecuting(){ + for(TestCaseStepExecution tcse : this.testCaseStepExecutionList){ + if ("PE".equals(tcse.getReturnCode())){ + return tcse; + } + } + return null; + } + /** * Convert the current TestCaseExecution into JSON format * diff --git a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepActionExecution.java b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepActionExecution.java index 72f3956a09..9f541c558d 100644 --- a/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepActionExecution.java +++ b/source/src/main/java/org/cerberus/core/crud/entity/TestCaseStepActionExecution.java @@ -449,6 +449,23 @@ public void addTestCaseStepActionExecutionList(List actionExecu } } + public TestCaseStepActionExecution getTestCaseStepActionExecutionBySortId(int sortID){ + for(TestCaseStepActionExecution tcsae : this.testCaseStepActionExecutionList){ + if (sortID == tcsae.getTestCaseStepAction().getSort()){ + return tcsae; + } + } + return null; + } + + public TestCaseStepActionExecution getTestCaseStepActionExecutionByActionId(int sortID){ + for(TestCaseStepActionExecution tcsae : this.testCaseStepActionExecutionList){ + if (sortID == tcsae.getTestCaseStepAction().getActionId()){ + return tcsae; + } + } + return null; + } + + public TestCaseStepActionExecution getTestCaseStepActionExecutionExecuting(){ + for(TestCaseStepActionExecution tcsae : this.testCaseStepActionExecutionList){ + if ("PE".equals(tcsae.getReturnCode())){ + return tcsae; + } + } + return null; + } + public String getDescription() { return description; } diff --git a/source/src/main/java/org/cerberus/core/engine/execution/enums/ConditionOperatorEnum.java b/source/src/main/java/org/cerberus/core/engine/execution/enums/ConditionOperatorEnum.java index a2a686dcca..61b292a844 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/enums/ConditionOperatorEnum.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/enums/ConditionOperatorEnum.java @@ -47,6 +47,12 @@ public enum ConditionOperatorEnum { CONDITIONOPERATOR_IFSTRINGNOTCONTAINS("ifStringNotContains", false), CONDITIONOPERATOR_IFTEXTINELEMENT("ifTextInElement", true), CONDITIONOPERATOR_IFTEXTNOTINELEMENT("ifTextNotInElement", true), + CONDITIONOPERATOR_IFSTEPSTATUSOK("ifStepStatusOK", false), + CONDITIONOPERATOR_IFSTEPSTATUSNE("ifStepStatusNE", false), + CONDITIONOPERATOR_IFACTIONSTATUSOK("ifActionStatusOK", false), + CONDITIONOPERATOR_IFACTIONSTATUSNE("ifActionStatusNE", false), + CONDITIONOPERATOR_IFCONTROLSTATUSOK("ifControlStatusOK", false), + CONDITIONOPERATOR_IFCONTROLSTATUSNE("ifControlStatusNE", false), CONDITIONOPERATOR_NEVER("never", false); private final String condition; diff --git a/source/src/main/java/org/cerberus/core/engine/execution/impl/ConditionService.java b/source/src/main/java/org/cerberus/core/engine/execution/impl/ConditionService.java index 50f303615f..837793a2b2 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/impl/ConditionService.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/impl/ConditionService.java @@ -200,6 +200,34 @@ public AnswerItem evaluateCondition(String conditionOperator, String co mes = ans.getResultMessage(); break; + case CONDITIONOPERATOR_IFSTEPSTATUSOK: + ans = evaluateCondition_ifStepStatusOK(conditionValue1, execution); + mes = ans.getResultMessage(); + break; + + case CONDITIONOPERATOR_IFSTEPSTATUSNE: + ans = evaluateCondition_ifStepStatusNE(conditionValue1, execution); + mes = ans.getResultMessage(); + break; + case CONDITIONOPERATOR_IFACTIONSTATUSOK: + ans = evaluateCondition_ifActionStatusOK(conditionValue1, conditionValue2, execution); + mes = ans.getResultMessage(); + break; + + case CONDITIONOPERATOR_IFACTIONSTATUSNE: + ans = evaluateCondition_ifActionStatusNE(conditionValue1, conditionValue2, execution); + mes = ans.getResultMessage(); + break; + case CONDITIONOPERATOR_IFCONTROLSTATUSOK: + ans = evaluateCondition_ifControlStatusOK(conditionValue1, conditionValue2, conditionValue3, execution); + mes = ans.getResultMessage(); + break; + + case CONDITIONOPERATOR_IFCONTROLSTATUSNE: + ans = evaluateCondition_ifControlStatusNE(conditionValue1, conditionValue2, conditionValue3, execution); + mes = ans.getResultMessage(); + break; + default: mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_UNKNOWNCONDITION); mes.setDescription(mes.getDescription().replace("%COND%", conditionToEvaluate.getCondition())); @@ -1059,6 +1087,174 @@ private AnswerItem evaluateCondition_ifNumericXXX(String conditionOpera return ans; } + private AnswerItem evaluateCondition_ifStepStatusOK(String conditionValue1, TestCaseExecution execution) { + LOG.debug("Checking if Step Status OK"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + try { + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode(); + + + if (status.equals("OK")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + ); + } + + } catch (Exception ex){ + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_STEPEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + ); + } + ans.setResultMessage(mes); + return ans; + } + + private AnswerItem evaluateCondition_ifStepStatusNE(String conditionValue1, TestCaseExecution execution) { + LOG.debug("Checking if Step Status NE"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)).getReturnCode(); + + + if (status.equals("NE")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_STEPEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_STEPEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + ); + } + ans.setResultMessage(mes); + return ans; + } + + private AnswerItem evaluateCondition_ifActionStatusOK(String conditionValue1, String conditionValue2, TestCaseExecution execution) { + LOG.debug("Checking if Action Status OK"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)) + .getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2)) + .getReturnCode(); + + + if (status.equals("OK")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + ); + } + ans.setResultMessage(mes); + return ans; + } + + private AnswerItem evaluateCondition_ifActionStatusNE(String conditionValue1, String conditionValue2, TestCaseExecution execution) { + LOG.debug("Checking if Action Status NE"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)) + .getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2)) + .getReturnCode(); + + + if (status.equals("NE")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_ACTIONEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_ACTIONEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + ); + } + ans.setResultMessage(mes); + return ans; + } + + private AnswerItem evaluateCondition_ifControlStatusOK(String conditionValue1, String conditionValue2, String conditionValue3, TestCaseExecution execution) { + LOG.debug("Checking if Control Status OK"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)) + .getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2)) + .getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3)) + .getReturnCode(); + + if (status.equals("OK")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + .replace("%STR3%", conditionValue3) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONOK); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + .replace("%STR3%", conditionValue3) + ); + } + ans.setResultMessage(mes); + return ans; + } + + private AnswerItem evaluateCondition_ifControlStatusNE(String conditionValue1, String conditionValue2, String conditionValue3, TestCaseExecution execution) { + LOG.debug("Checking if Control Status NE"); + AnswerItem ans = new AnswerItem<>(); + MessageEvent mes; + + String status = execution.getTestCaseStepExecutionByStepId(Integer.valueOf(conditionValue1)) + .getTestCaseStepActionExecutionByActionId(Integer.valueOf(conditionValue2)) + .getTestCaseStepActionControlExecutionByControlId(Integer.valueOf(conditionValue3)) + .getReturnCode(); + + + if (status.equals("NE")) { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_TRUE_CONTROLEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + .replace("%STR3%", conditionValue3) + ); + } else { + mes = new MessageEvent(MessageEventEnum.CONDITIONEVAL_FALSE_CONTROLEXECUTIONNE); + mes.setDescription(mes.getDescription() + .replace("%STR1%", conditionValue1) + .replace("%STR2%", conditionValue2) + .replace("%STR3%", conditionValue3) + ); + } + ans.setResultMessage(mes); + return ans; + } + private String caseSensitiveMessageValue(String isCaseSensitive) { if (ParameterParserUtil.parseBooleanParam(isCaseSensitive, false)) { diff --git a/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java b/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java index a0a922570d..89722b8554 100644 --- a/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java +++ b/source/src/main/java/org/cerberus/core/enums/MessageEventEnum.java @@ -504,6 +504,12 @@ public enum MessageEventEnum { CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_APPLICATION(1220, "FA", "Condition '%CONDITION%' is not supported for application type '%APPLICATIONTYPE%'.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), CONDITIONEVAL_FAILED_NOTSUPPORTED_FOR_MESSAGETYPE(1220, "FA", "Message type %TYPE% not supported for condition '%CONDITION%'.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), CONDITIONEVAL_FAILED_IFNUMERIC_GENERICCONVERSIONERROR(1230, "FA", "Cannot convert %STRINGVALUE% to numeric.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_STEPEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_ACTIONEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_CONTROLEXECUTIONOK(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_STEPEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_ACTIONEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' is missing or in a bad format (integer expected), or expected step doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), + CONDITIONEVAL_FAILED_CONTROLEXECUTIONNE(1210, "FA", "Mandatory parameter '%STR1%' or '%STR2%' is missing or in a bad format (integer expected), or expected step/action doesn't exist.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), CONDITIONEVAL_FAILED_SELENIUM_CONNECTIVITY(1230, "FA", "Lost connection to Selenium Server! Detailed error : %ERROR%.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), CONDITIONEVAL_FAILED_GENERIC(1230, "FA", "Failed to evaluate condition. Detailed error : %ERROR%.", false, false, false, MessageGeneralEnum.EXECUTION_FA_CONDITION), CONDITIONEVAL_FAILED_TEXTINELEMENT(1240, "FA", "%ERRORMESS%", true, true, true, MessageGeneralEnum.EXECUTION_KO), @@ -527,6 +533,12 @@ public enum MessageEventEnum { CONDITIONEVAL_FALSE_NUMERICGREATEROREQUAL(1210, "NA", "'%STR1%' is not greater or equal than '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_FALSE_NUMERICMINOR(1210, "NA", "'%STR1%' is not minor to '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_FALSE_NUMERICMINOROREQUAL(1210, "NA", "'%STR1%' is not minor or equal to '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_STEPEXECUTIONOK(1210, "NA", "Step '%STR1%' has not been executed but expected.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_ACTIONEXECUTIONOK(1210, "NA", "Action '%STR1%' from Step '%STR2%' has not been executed but expected.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_CONTROLEXECUTIONOK(1210, "NA", "Control '%STR1%' from Action '%STR2%' from Step '%STR3%' has not been executed but expected.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_STEPEXECUTIONNE(1210, "NA", "Step '%STR1%' has been executed but it should not.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_ACTIONEXECUTIONNE(1210, "NA", "Action '%STR1%' from Step '%STR2%' has been executed but it should not.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_FALSE_CONTROLEXECUTIONNE(1210, "NA", "Control '%STR1%' from Action '%STR2%' from Step '%STR3%' has been executed but it should not.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_FALSE_TEXTINELEMENT(1240, "NA", "%ERRORMESS%", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_FALSE_TEXTNOTINELEMENT(1240, "NA", "%ERRORMESS%", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUE_ALWAYS(1210, "OK", "", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), @@ -552,6 +564,12 @@ public enum MessageEventEnum { CONDITIONEVAL_TRUE_NUMERICGREATEROREQUAL(1210, "OK", "'%STR1%' is greater or equal than '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUE_NUMERICMINOR(1210, "OK", "'%STR1%' is minor to '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUE_NUMERICMINOROREQUAL(1210, "OK", "'%STR1%' is minor or equal to '%STR2%'", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_STEPEXECUTIONOK(1210, "OK", "Step '%STR1%' has been executed and returned OK.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_ACTIONEXECUTIONOK(1210, "OK", "Action '%STR1%' from Step '%STR2%' has been executed and returned OK.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_CONTROLEXECUTIONOK(1210, "OK", "Control '%STR1%' from Action '%STR2%' from Step '%STR3%' has been executed and returned OK.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_STEPEXECUTIONNE(1210, "OK", "Step '%STR1%' has not been executed.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_ACTIONEXECUTIONNE(1210, "OK", "Action '%STR1%' from Step '%STR2%' has not been executed.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), + CONDITIONEVAL_TRUE_CONTROLEXECUTIONNE(1210, "OK", "Control '%STR1%' from Action '%STR2%' from Step '%STR3%' has not been executed.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUE_TEXTINELEMENT(300, "OK", "Element '%STRING1%' with value '%STRING2%' is equal to %STRING3%, %STRING4%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUEMANUAL_TEXTINELEMENT(300, "OK", "Please evaluate if element '%STRING1%' does contain '%STRING2%', case sensitive : '%STRING3%'.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), CONDITIONEVAL_TRUE_TEXTNOTINELEMENT(300, "OK", "Element '%STRING1%' with value '%STRING2%' is different than %STRING3%, %STRING4%.", false, false, false, MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), diff --git a/source/src/main/webapp/include/pages/testcasescript/manageActionControlOptions.html b/source/src/main/webapp/include/pages/testcasescript/manageActionControlOptions.html index f49e960ea6..5d62205936 100644 --- a/source/src/main/webapp/include/pages/testcasescript/manageActionControlOptions.html +++ b/source/src/main/webapp/include/pages/testcasescript/manageActionControlOptions.html @@ -122,6 +122,10 @@ +
+ + +
diff --git a/source/src/main/webapp/js/pages/TestCaseScript.js b/source/src/main/webapp/js/pages/TestCaseScript.js index c4fc0ad64c..7ac9e1e683 100644 --- a/source/src/main/webapp/js/pages/TestCaseScript.js +++ b/source/src/main/webapp/js/pages/TestCaseScript.js @@ -1470,6 +1470,48 @@ function duplicateStep(event) { } +function appendActionsForConditionCombobox(combo, operator){ + + console.log(combo); + combo.empty(); + var steps = $("#steps li").data("item").steps; + for (s in steps) { + if (operator.startsWith("ifStepStatus")) { + if (steps[s].sort != undefined) { + combo.append($("") + .text("Step " + steps[s].sort + " - " + steps[s].description) + .attr("stepId", steps[s].stepId) + .val(steps[s].stepId)); + } + } else { + var actions = $("#steps li").data("item").steps[s].actions; + for (a in actions) { + if (operator.startsWith("ifActionStatus")) { + if (actions[a].sort != undefined) { + combo.append($("") + .text("Step " + steps[s].sort + " - Action " + actions[a].sort + " - " + actions[a].description) + .attr("actionId", actions[a].actionId) + .attr("stepId", steps[s].stepId) + .val(steps[s].stepId + "-" + actions[a].actionId)); + } + } else { + var controls = $("#steps li").data("item").steps[s].actions[a].controls; + for (c in controls) { + if (controls[c].sort != undefined) { + combo.append($("") + .text("Step " + steps[s].sort + " - Action " + actions[a].sort + " - Control " + controls[c].sort + " - " + controls[c].description) + .attr("actionId", actions[a].actionId) + .attr("stepId", steps[s].stepId) + .attr("controlId", controls[c].stepId) + .val(steps[s].stepId + "-" + actions[a].actionId+ "-" + controls[c].controlId)); + } + } + } + } + } + } +} + function createSteps(data, steps, stepIndex, canUpdate, hasPermissionsStepLibrary) { // If the testcase has no steps, we create an empty one. if (data.length === 0) { @@ -2595,10 +2637,25 @@ function displayOverrideOptionsModal(action, htmlElement) { $("#actionconditionval3").val(action.conditionValue3); setPlaceholderCondition($("#conditionSelect")); + if (conditionNewUIList[action.conditionOperator].type ==="combo") { + appendActionsForConditionCombobox($("#actionconditionval4"), action.conditionOperator); + if (conditionNewUIList[action.conditionOperator].level ==="step"){ + $("#actionconditionval4").val(action.conditionValue1); + } + if (conditionNewUIList[action.conditionOperator].level ==="action"){ + $("#actionconditionval4").val(action.conditionValue1+"-"+action.conditionValue2); + } + if (conditionNewUIList[action.conditionOperator].level ==="control"){ + $("#actionconditionval4").val(action.conditionValue1+"-"+action.conditionValue2+"-"+action.conditionValue3); + } + } + + $("#conditionSelect").off("change"); $("#conditionSelect").on("change", function () { setModif(true); setPlaceholderCondition($(this)); + appendActionsForConditionCombobox($("#actionconditionval4"), $(this).val()); }); $("#actionconditionval1").off("change"); $("#actionconditionval1").on("change", function () { @@ -2612,6 +2669,10 @@ function displayOverrideOptionsModal(action, htmlElement) { $("#actionconditionval3").on("change", function () { setModif(true); }); + $("#actionconditionval4").off("change"); + $("#actionconditionval4").on("change", function () { + setModif(true); + }); $("#screenshotBCheckbox").off("change"); $("#screenshotBCheckbox").on("change", function () { setModif(true); @@ -2718,6 +2779,12 @@ function displayOverrideOptionsModal(action, htmlElement) { action.conditionValue2 = $("#actionconditionval2").val(); action.conditionValue3 = $("#actionconditionval3").val(); + if (conditionNewUIList[action.conditionOperator].type === "combo") { + action.conditionValue1 = $("#actionconditionval4 option:selected").attr("stepId"); + action.conditionValue2 = $("#actionconditionval4 option:selected").attr("actionId") === undefined ? "":$("#actionconditionval4 option:selected").attr("actionId"); + action.conditionValue3 = $("#actionconditionval4 option:selected").attr("controlId")=== undefined ? "":$("#actionconditionval4 option:selected").attr("controlId"); + } + let newOpts = []; newOpts.push({ "act": $("#timeoutAct").prop("checked"), @@ -3996,6 +4063,14 @@ function setPlaceholderCondition(conditionElement) { $(conditionElement).parents("div[class*='conditions']").find("label[class='conditionVal3Label']").parent().hide(); } + if (typeof placeHolders.field4 !== 'undefined') { + $(conditionElement).parents("div[class*='conditions']").find("label[class='conditionVal4Label']").parent().show(); + $(conditionElement).parents("div[class*='conditions']").find("label[class='conditionVal4Label']").text(placeHolders.field4.label[user.language]); + + } else { + $(conditionElement).parents("div[class*='conditions']").find(".v4").hide(); + } + } function setPlaceholderControl(control) { diff --git a/source/src/main/webapp/js/testcase/condition.js b/source/src/main/webapp/js/testcase/condition.js index 979124b6f6..e5ee036f11 100644 --- a/source/src/main/webapp/js/testcase/condition.js +++ b/source/src/main/webapp/js/testcase/condition.js @@ -77,6 +77,18 @@ var conditionNewUIList = { "ifStringNotContains":{"value":"ifStringNotContains","label":{"en":"If String not Contains","fr":"Si le texte ne contient pas"}, "field1":{"label":{"en": "String 1", "fr": "Texte 1"},"class": "crb-autocomplete-variable"}, "field2":{"label":{"en": "String 2", "fr": "Texte 2"},"class": "crb-autocomplete-variable"}}, + "ifStepStatusOK":{"value":"ifStepStatusOK","label":{"en":"If step returned OK","fr":"Si le step est OK'"}, + "field4":{"label":{"en": "Step", "fr": "Step"}},"type":"combo","level":"step"}, + "ifStepStatusNE":{"value":"ifStepStatusNE","label":{"en":"If defined step not executed","fr":"Si le step n'a pas été executé'"}, + "field4":{"label":{"en": "Step", "fr": "Step"}},"type":"combo","level":"step"}, + "ifActionStatusOK":{"value":"ifActionStatusOK","label":{"en":"If action returned OK","fr":"Si l'action est OK'"}, + "field4":{"label":{"en": "Action", "fr": "Action"}},"type":"combo","level":"action"}, + "ifActionStatusNE":{"value":"ifActionStatusNE","label":{"en":"If defined Action not executed","fr":"Si l'action n'a pas été executée'"}, + "field4":{"label":{"en": "Action", "fr": "Action"}},"type":"combo","level":"action"}, + "ifControlStatusOK":{"value":"ifControlStatusOK","label":{"en":"If control returned OK","fr":"Si le contrôle est OK'"}, + "field4":{"label":{"en": "Control", "fr": "Control"}},"type":"combo","level":"control"}, + "ifControlStatusNE":{"value":"ifControlStatusNE","label":{"en":"If Control not executed","fr":"Si le contrôle n'a pas été executé'"}, + "field4":{"label":{"en": "Control", "fr": "Control"}},"type":"combo","level":"control"}, "never":{"value":"never","label":{"en":"Never","fr":"Jamais"}}, }