Index: lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java =================================================================== diff -u -r3efe43338b4e0ca5b68f60752f95a90c919121fb -rba4ff235b722eae45c0b93a138bd60f2c43ce37d --- lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java (.../GatesTests.java) (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) +++ lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java (.../GatesTests.java) (revision ba4ff235b722eae45c0b93a138bd60f2c43ce37d) @@ -27,6 +27,7 @@ import org.lamsfoundation.lams.author.util.AuthorConstants; import org.lamsfoundation.lams.pages.IndexPage; import org.lamsfoundation.lams.pages.LoginPage; +import org.lamsfoundation.lams.pages.author.ConditionsPropertiesPage; import org.lamsfoundation.lams.pages.author.FLAPage; import org.lamsfoundation.lams.util.LamsUtil; import org.openqa.selenium.Point; @@ -118,21 +119,21 @@ public void createDesign() { // Drop activities in canvas - fla.dragActivityToCanvasPosition(AuthorConstants.FORUM_TITLE, 200, 50); + fla.dragActivityToCanvasPosition(AuthorConstants.MULTIPLE_CHOICE_TITLE, 200, 50); fla.dragGateToCanvas(); fla.dragActivityToCanvasPosition(AuthorConstants.SHARE_RESOURCES_TITLE, 350, (10 * randomInteger)); // Draw transitions in between the activities - fla.drawTransitionFromTo(AuthorConstants.FORUM_TITLE, AuthorConstants.GATE_TITLE); + fla.drawTransitionFromTo(AuthorConstants.MULTIPLE_CHOICE_TITLE, AuthorConstants.GATE_TITLE); fla.drawTransitionFromTo(AuthorConstants.GATE_TITLE, AuthorConstants.SHARE_RESOURCES_TITLE); // Now get all the activity titles List allActivityTitles = fla.getAllActivityNames(); // Assert that all of them are in the design - Assert.assertTrue(allActivityTitles.contains(AuthorConstants.FORUM_TITLE), - "The title " + AuthorConstants.FORUM_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.MULTIPLE_CHOICE_TITLE), + "The title " + AuthorConstants.MULTIPLE_CHOICE_TITLE + " was not found as an activity in the design"); Assert.assertTrue(allActivityTitles.contains(AuthorConstants.GATE_TITLE), "The title " + AuthorConstants.GATE_TITLE + " was not found as an activity in the design"); Assert.assertTrue(allActivityTitles.contains(AuthorConstants.SHARE_RESOURCES_TITLE), @@ -324,19 +325,70 @@ @Test(dependsOnMethods="setGateTypeToSchedule") public void setGateTypeToCondition() { + // Test data + + String conditionZero = "Zero zone"; + String conditionOne = "One zone"; + + String zeroOption = "0"; + String oneOption = "1"; + + String gateOpen = "open"; + String gateClosed = "closed"; + fla.gateProperties() .setGateType(GATE_TYPE_CONDITION) .setGateTitle("Condition Gate") .setGateDescription("Testing condition gate") - .setConditionInput(AuthorConstants.FORUM_TITLE); + .setConditionInput(AuthorConstants.MULTIPLE_CHOICE_TITLE); + + + fla.gateProperties() + .clickCreateConditions() + .setConditionOutput(ConditionsPropertiesPage.OUTPUT_MCQ_TOTAL_MARK) + .setOptionType(ConditionsPropertiesPage.OPTION_RANGE) + .setFromRangeValue(zeroOption) + .setToRangeValue(zeroOption) + .clickAddOptionRange() + .setConditionName(conditionZero, "2") // #2 here is to append it to the right input (gotta fix this in the future) + .setFromRangeValue(oneOption) + .setToRangeValue(oneOption) + .clickAddOptionRange() + .setConditionName(conditionOne, "3") // same goes here + .clickOkConditionsButton() + .matchConditionToBranch(conditionZero, gateOpen) + .matchConditionToBranch(conditionOne, gateClosed) + .clickOkMatchingConditionsToBranchesButton(); savesDesign(); // Now assertions + // Assert tool input String assertConditionInput = fla.gateProperties().getConditionInput(); - Assert.assertEquals(assertConditionInput, AuthorConstants.FORUM_TITLE, + Assert.assertEquals(assertConditionInput, AuthorConstants.MULTIPLE_CHOICE_TITLE, "Condition input activity is not the same!"); + // Assert conditions + List assertAllConditions = fla.gateProperties() + .clickCreateConditions() + .getConditionNames(); + + Assert.assertTrue(assertAllConditions.contains(conditionOne), + conditionOne + " is not in the list of conditions"); + Assert.assertTrue(assertAllConditions.contains(conditionZero), + conditionZero + " is not in the list of conditions"); + + // Assert mappings + List assertAllMappings = fla.gateProperties() + .clickCreateConditions() + .clickOkConditionsButton() + .getAllMappings(); + + Assert.assertTrue(assertAllMappings.contains(conditionOne + " matches " + gateClosed), + conditionOne + " doesn't match " + gateClosed); + Assert.assertTrue(assertAllMappings.contains(conditionZero + " matches " + gateOpen), + conditionZero + " doesn't match " + gateOpen); + } } Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java =================================================================== diff -u -r3efe43338b4e0ca5b68f60752f95a90c919121fb -rba4ff235b722eae45c0b93a138bd60f2c43ce37d --- lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java (.../GatePropertyPage.java) (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) +++ lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java (.../GatePropertyPage.java) (revision ba4ff235b722eae45c0b93a138bd60f2c43ce37d) @@ -65,7 +65,7 @@ /** - * Schedule gate properties + * Condition gate properties * */ @@ -86,7 +86,7 @@ * Set gate title * * @param designDescription - * @return + * @return {@link GatePropertyPage} */ public GatePropertyPage setGateTitle(String gateTitleText) { @@ -112,7 +112,7 @@ /** * Sets gate description * @param gateDescriptionText - * @return + * @return {@link GatePropertyPage} */ public GatePropertyPage setGateDescription(String gateDescriptionText) { @@ -138,7 +138,7 @@ /** * Set gate type in select * @param gateType - * @return + * @return {@link GatePropertyPage} */ public GatePropertyPage setGateType(String gateType) { @@ -162,6 +162,11 @@ } + /** + * Sets days + * @param days + * @return {@link GatePropertyPage} + */ public GatePropertyPage setScheduleDays(String days) { scheduleDays.click(); @@ -171,13 +176,23 @@ return PageFactory.initElements(driver, GatePropertyPage.class); } + /** + * Gets set days + * + * @return days + */ public String getScheduleDays() { return scheduleDays.getAttribute("value"); } + /** + * Set hours + * @param hours + * @return {@link GatePropertyPage} + */ public GatePropertyPage setScheduleHours(String hours) { scheduleHours.click(); @@ -187,12 +202,23 @@ return PageFactory.initElements(driver, GatePropertyPage.class); } + /** + * Gets set hours + * + * @return + */ public String getScheduleHours() { return scheduleHours.getAttribute("value"); } + /** + * Set minutes + * + * @param minutes + * @return {@link GatePropertyPage} + */ public GatePropertyPage setScheduleMinutes(String minutes) { scheduleMinutes.click(); @@ -203,12 +229,20 @@ } + /** + * Gets set minutes + * @return + */ public String getScheduleMinutes() { return scheduleMinutes.getAttribute("value"); } + /** + * click on option "since previews finished activity" + * @return {@link GatePropertyPage} + */ public GatePropertyPage setSincePreviewActivity() { sincePreviewActivity.click(); @@ -217,13 +251,22 @@ } + /** + * Returns boolean with SincePreviewActivity property + * @return + */ public Boolean isSincePreviewActivity() { return sincePreviewActivity.isSelected(); } + /** + * Sets condition input type + * @param activity + * @return {@link GatePropertyPage} + */ public GatePropertyPage setConditionInput(String activity) { Select inputDropDown = new Select(conditionInputSelect); @@ -233,11 +276,23 @@ return PageFactory.initElements(driver, GatePropertyPage.class); } + /** + * Returns the input tool + * @return + */ public String getConditionInput() { Select inputDropDown = new Select(conditionInputSelect); return inputDropDown.getFirstSelectedOption().getText(); + } + + + public ConditionsPropertiesPage clickCreateConditions() { + + createConditionsButton.click(); + + return PageFactory.initElements(driver, ConditionsPropertiesPage.class); } }