From 8f96ddae47808d9ac941a433866274c0afcd7be7 Mon Sep 17 00:00:00 2001 From: srosse <stephane.rosse@frentix.com> Date: Tue, 4 Dec 2018 21:55:53 +0100 Subject: [PATCH] OO-3746, OO-3757: add 2 selenium tests for different config. of task el. --- pom.xml | 4 +- .../org/olat/selenium/AssessmentTest.java | 304 ++++++++++++++++++ .../course/GroupTaskConfigurationPage.java | 35 ++ .../selenium/page/course/GroupTaskPage.java | 11 +- .../page/course/GroupTaskToCoachPage.java | 8 +- .../selenium/page/graphene/OOGraphene.java | 7 + 6 files changed, 360 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index d2001103751..ac0eaa4ddcb 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ <org.postgresql.version>42.2.1</org.postgresql.version> <org.infinispan.version>8.2.8.Final</org.infinispan.version> <lucene.version>4.8.0</lucene.version> - <version.selenium>3.11.0</version.selenium> + <version.selenium>3.13.0</version.selenium> <version.drone>2.5.1</version.drone> <activemq.version>5.11.1</activemq.version> <qtiworks.version>1.0.9</qtiworks.version> @@ -2641,7 +2641,7 @@ <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> - <version>1.4.0.Final</version> + <version>1.4.1.Final</version> <scope>import</scope> <type>pom</type> </dependency> diff --git a/src/test/java/org/olat/selenium/AssessmentTest.java b/src/test/java/org/olat/selenium/AssessmentTest.java index e7b693215a9..b68b3d3f39f 100644 --- a/src/test/java/org/olat/selenium/AssessmentTest.java +++ b/src/test/java/org/olat/selenium/AssessmentTest.java @@ -1216,6 +1216,310 @@ public class AssessmentTest extends Deployments { .assertPassed(); } + /** + * An author create a course for a task with some custom + * settings, assignment and solution steps are disabled, + * but grading is selected with score and + * passed is automatically calculated.</br> + * It had a participant which goes through the workflow, + * submits 2 documents, one with the embedded editor, + * one with the upload mechanism.</br> + * The author reviews the documents, uploads a correction and + * want a revision.</br> + * The assessed participant upload a revised document.</br> + * The author sees it and close the revisions process, use + * the assessment tool to set the score.</br> + * The participant checks if she successfully passed the task. + * + * @param authorLoginPage + * @param ryomouBrowser + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void taskWithoutAssignment(@InitialPage LoginPage authorLoginPage, + @Drone @User WebDriver ryomouBrowser) + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("kanu"); + UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("ryomou"); + + authorLoginPage.loginAs(author.getLogin(), author.getPassword()); + + //create a course + String courseTitle = "Course-with-task-alt-1-" + UUID.randomUUID(); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack(); + + //create a course element of type Test with the test that we create above + String gtaNodeTitle = "Individual task 2"; + CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser) + .edit(); + courseEditor + .createNode("ita") + .nodeTitle(gtaNodeTitle); + + GroupTaskConfigurationPage gtaConfig = new GroupTaskConfigurationPage(browser); + gtaConfig + .selectWorkflow() + .enableAssignment(false) + .enableSolution(false) + .saveWorkflow(); + + gtaConfig + .selectAssessment() + .setAssessmentOptions(0.0f, 6.0f, 4.0f) + .saveAssessmentOptions(); + + courseEditor + .publish() + .quickPublish(UserAccess.membersOnly); + + MembersPage membersPage = courseEditor + .clickToolbarBack() + .members(); + + membersPage + .importMembers() + .setMembers(kanu, ryomou) + .nextUsers() + .nextOverview() + .nextPermissions() + .finish(); + + //go to the course + CoursePageFragment coursePage = membersPage + .clickToolbarBack(); + coursePage + .clickTree() + .selectWithTitle(gtaNodeTitle); + + //Participant log in + LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl); + ryomouLoginPage + .loginAs(ryomou) + .resume(); + + //open the course + NavigationPage ryomouNavBar = new NavigationPage(ryomouBrowser); + ryomouNavBar + .openMyCourses() + .select(courseTitle); + + //go to the group task + CoursePageFragment ryomouTestCourse = new CoursePageFragment(ryomouBrowser); + ryomouTestCourse + .clickTree() + .selectWithTitle(gtaNodeTitle); + + GroupTaskPage ryomouTask = new GroupTaskPage(ryomouBrowser); + ryomouTask + .assertSubmissionAvailable(); + + URL submit1Url = JunitTestHelper.class.getResource("file_resources/submit_2.txt"); + File submit1File = new File(submit1Url.toURI()); + String submittedFilename = "personal_solution.html"; + String submittedText = "This is my solution"; + ryomouTask + .submitFile(submit1File) + .submitText(submittedFilename, submittedText) + .submitDocuments(); + + //back to author + coursePage + .clickTree() + .selectWithTitle(gtaNodeTitle); + GroupTaskToCoachPage participantToCoach = new GroupTaskToCoachPage(browser); + + URL correctionUrl = JunitTestHelper.class.getResource("file_resources/correction_1.txt"); + File correctionFile = new File(correctionUrl.toURI()); + participantToCoach + .selectIdentityToCoach(ryomou) + .assertSubmittedDocument("personal_solution.html") + .assertSubmittedDocument("submit_2.txt") + .uploadCorrection(correctionFile) + .needRevision(); + + //participant add a revised document + URL revisionUrl = JunitTestHelper.class.getResource("file_resources/submit_3.txt"); + File revisionFile = new File(revisionUrl.toURI()); + ryomouTestCourse + .clickTree() + .selectWithTitle(gtaNodeTitle); + ryomouTask + .submitRevisedFile(revisionFile) + .submitRevision(); + + //back to author + coursePage + .clickTree() + .selectWithTitle(gtaNodeTitle); + participantToCoach + .selectIdentityToCoach(ryomou) + .assertRevision("submit_3.txt") + .closeRevisions() + .openIndividualAssessment() + .individualAssessment(null, 5.5f) + .assertPassed(); + + //participant checks she passed the task + ryomouTestCourse + .clickTree() + .selectWithTitle(gtaNodeTitle); + ryomouTask + .assertPassed(); + } + + /** + * An author create a course for a task with some custom + * settings, the following steps are not selected: review + * (and revisions) and solutions. The assignment is automatic. + * The assessment is set to passed automatically.</br> + * It had a participant which see the assignment and submits + * 2 documents, one with the embedded editor, + * one with the upload mechanism.</br> + * The author reviews the documents and use + * the assessment tool to set the score.</br> + * The participant checks if she successfully passed the task. + * + * @param authorLoginPage + * @param ryomouBrowser + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void taskWithIndividuScoreNoRevision(@InitialPage LoginPage authorLoginPage, + @Drone @User WebDriver ryomouBrowser) + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("kanu"); + UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("ryomou"); + + authorLoginPage.loginAs(author.getLogin(), author.getPassword()); + + //create a course + String courseTitle = "Course-with-individual-task-" + UUID.randomUUID(); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack(); + + //create a course element of type Test with the test that we create above + String gtaNodeTitle = "Individual task 1"; + CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser) + .edit(); + courseEditor + .createNode("ita") + .nodeTitle(gtaNodeTitle); + + GroupTaskConfigurationPage gtaConfig = new GroupTaskConfigurationPage(browser); + gtaConfig + .selectWorkflow() + .enableSolution(false) + .enableReview(false) + .saveWorkflow() + .selectAssignment(); + + URL task1Url = JunitTestHelper.class.getResource("file_resources/task_1_a.txt"); + File task1File = new File(task1Url.toURI()); + gtaConfig.uploadTask("Individual Task 1 alpha", task1File); + + URL task2Url = JunitTestHelper.class.getResource("file_resources/task_1_b.txt"); + File task2File = new File(task2Url.toURI()); + gtaConfig + .uploadTask("Individual Task 2 beta", task2File) + .enableAutoAssignment(true) + .saveTasks(); + + gtaConfig + .selectAssessment() + .setAssessmentOptions(0.0f, 6.0f, 4.0f) + .saveAssessmentOptions(); + + courseEditor + .publish() + .quickPublish(UserAccess.membersOnly); + + MembersPage membersPage = courseEditor + .clickToolbarBack() + .members(); + + membersPage + .importMembers() + .setMembers(kanu, ryomou) + .nextUsers() + .nextOverview() + .nextPermissions() + .finish(); + + //go to the course + CoursePageFragment coursePage = membersPage + .clickToolbarBack(); + coursePage + .clickTree() + .selectWithTitle(gtaNodeTitle); + + //Participant log in + LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl); + ryomouLoginPage + .loginAs(ryomou) + .resume(); + + //open the course + NavigationPage ryomouNavBar = new NavigationPage(ryomouBrowser); + ryomouNavBar + .openMyCourses() + .select(courseTitle); + + //go to the group task + CoursePageFragment ryomouTestCourse = new CoursePageFragment(ryomouBrowser); + ryomouTestCourse + .clickTree() + .selectWithTitle(gtaNodeTitle); + + GroupTaskPage ryomouTask = new GroupTaskPage(ryomouBrowser); + ryomouTask + .assertAssignmentAvailable() + .assertTask("Individual Task") + .assertSubmissionAvailable(); + + URL submit1Url = JunitTestHelper.class.getResource("file_resources/submit_2.txt"); + File submit1File = new File(submit1Url.toURI()); + String submittedFilename = "personal_solution.html"; + String submittedText = "This is my solution"; + ryomouTask + .submitFile(submit1File) + .submitText(submittedFilename, submittedText) + .submitDocuments(); + + //back to author + coursePage + .clickTree() + .selectWithTitle(gtaNodeTitle); + GroupTaskToCoachPage participantToCoach = new GroupTaskToCoachPage(browser); + + participantToCoach + .selectIdentityToCoach(ryomou) + .assertSubmittedDocument("personal_solution.html") + .assertSubmittedDocument("submit_2.txt") + .openIndividualAssessment() + .individualAssessment(null, 5.5f) + .assertPassed(); + + //participant checks she passed the task + ryomouTestCourse + .clickTree() + .selectWithTitle(gtaNodeTitle); + ryomouTask + .assertPassed(); + } + /** * Create an assessment course element, add two users to the course * and assesses them with the bulk assessment tool. The 2 users diff --git a/src/test/java/org/olat/selenium/page/course/GroupTaskConfigurationPage.java b/src/test/java/org/olat/selenium/page/course/GroupTaskConfigurationPage.java index 431a015631c..10ab1f1c8e2 100644 --- a/src/test/java/org/olat/selenium/page/course/GroupTaskConfigurationPage.java +++ b/src/test/java/org/olat/selenium/page/course/GroupTaskConfigurationPage.java @@ -48,6 +48,32 @@ public class GroupTaskConfigurationPage { return selectTab(configBy); } + public GroupTaskConfigurationPage enableAssignment(boolean enable) { + return enableStep("task.assignment", enable); + } + + public GroupTaskConfigurationPage enableReview(boolean enable) { + return enableStep("review", enable); + } + + public GroupTaskConfigurationPage enableRevision(boolean enable) { + return enableStep("revision", enable); + } + + public GroupTaskConfigurationPage enableSolution(boolean enable) { + return enableStep("sample", enable); + } + + private GroupTaskConfigurationPage enableStep(String name, boolean enable) { + By stepBy = By.xpath("//fieldset[contains(@class,'o_sel_course_gta_steps')]//label[input[@name='" + name + "']]"); + WebElement labelEl = browser.findElement(stepBy); + By checkboxStepBy = By.xpath("//fieldset[contains(@class,'o_sel_course_gta_steps')]//label/input[@name='" + name + "']"); + WebElement checkboxEl = browser.findElement(checkboxStepBy); + OOGraphene.check(labelEl, checkboxEl, Boolean.valueOf(enable)); + OOGraphene.waitBusy(browser); + return this; + } + public GroupTaskConfigurationPage saveWorkflow() { By saveBy = By.cssSelector(".o_sel_course_gta_save_workflow button.btn-primary"); browser.findElement(saveBy).click(); @@ -122,6 +148,15 @@ public class GroupTaskConfigurationPage { return this; } + public GroupTaskConfigurationPage enableAutoAssignment(boolean enable) { + //task.assignment.type + String type = enable ? "auto" : "manual"; + By typeBy = By.xpath("//fieldset[contains(@class,'o_sel_course_gta_task_config_form')]//input[@name='task.assignment.type'][@value='" + type + "']"); + browser.findElement(typeBy).click(); + OOGraphene.waitBusy(browser); + return this; + } + public GroupTaskConfigurationPage saveTasks() { By saveBy = By.cssSelector(".o_sel_course_gta_task_config_buttons button.btn-primary"); List<WebElement> saveEls = browser.findElements(saveBy); diff --git a/src/test/java/org/olat/selenium/page/course/GroupTaskPage.java b/src/test/java/org/olat/selenium/page/course/GroupTaskPage.java index f0662777d9f..42c5b89d128 100644 --- a/src/test/java/org/olat/selenium/page/course/GroupTaskPage.java +++ b/src/test/java/org/olat/selenium/page/course/GroupTaskPage.java @@ -103,6 +103,7 @@ public class GroupTaskPage { By saveButtonBy = By.cssSelector(".o_sel_course_gta_upload_form button.btn-primary"); browser.findElement(saveButtonBy).click(); OOGraphene.waitBusy(browser); + OOGraphene.waitModalDialogDisappears(browser); return this; } @@ -117,10 +118,16 @@ public class GroupTaskPage { browser.findElement(saveBy).click(); OOGraphene.waitBusy(browser); - OOGraphene.tinymce(text, browser); - By saveAndCloseBy = By.cssSelector("#o_button_saveclose a.btn"); + By saveAndCloseBy = By.cssSelector(".modal-body #o_button_saveclose a.btn"); + OOGraphene.waitElement(saveAndCloseBy, browser); + + OOGraphene.tinymceExec(text, browser); + + By saveAndCloseDirtyBy = By.cssSelector(".modal-body #o_button_saveclose a.btn.o_button_dirty"); + OOGraphene.waitElement(saveAndCloseDirtyBy, browser); browser.findElement(saveAndCloseBy).click(); OOGraphene.waitBusy(browser); + OOGraphene.waitModalDialogDisappears(browser); return this; } diff --git a/src/test/java/org/olat/selenium/page/course/GroupTaskToCoachPage.java b/src/test/java/org/olat/selenium/page/course/GroupTaskToCoachPage.java index deb15a7fbd3..f9e7601419b 100644 --- a/src/test/java/org/olat/selenium/page/course/GroupTaskToCoachPage.java +++ b/src/test/java/org/olat/selenium/page/course/GroupTaskToCoachPage.java @@ -71,8 +71,7 @@ public class GroupTaskToCoachPage { public GroupTaskToCoachPage assertSubmittedDocument(String title) { By selectLinkBy = By.xpath("//div[@id='o_step_submit_content']//ul//a//span[contains(text(),'" + title + "')]"); - List<WebElement> documentLinkEls = browser.findElements(selectLinkBy); - Assert.assertFalse(documentLinkEls.isEmpty()); + OOGraphene.waitElement(selectLinkBy, browser); return this; } @@ -141,11 +140,10 @@ public class GroupTaskToCoachPage { By collpaseBy = By.xpath("//a[@href='#o_step_grading_content']"); browser.findElement(collpaseBy).click(); OOGraphene.waitElement(assessmentButtonBy, browser); - browser.findElement(assessmentButtonBy).click(); - } else { - buttons.get(0).click(); } + browser.findElement(assessmentButtonBy).click(); OOGraphene.waitBusy(browser); + OOGraphene.waitModalDialog(browser); return this; } diff --git a/src/test/java/org/olat/selenium/page/graphene/OOGraphene.java b/src/test/java/org/olat/selenium/page/graphene/OOGraphene.java index 25eaa999b5e..4d52ba9f1f5 100644 --- a/src/test/java/org/olat/selenium/page/graphene/OOGraphene.java +++ b/src/test/java/org/olat/selenium/page/graphene/OOGraphene.java @@ -231,6 +231,13 @@ public class OOGraphene { ((JavascriptExecutor)browser).executeScript("top.tinymce.activeEditor.setContent('" + content + "')"); } + public static final void tinymceExec(String content, WebDriver browser) { + Graphene.waitModel(browser).withTimeout(waitTinyDuration, TimeUnit.SECONDS) + .pollingEvery(poolingDuration, TimeUnit.MILLISECONDS) + .until(new TinyMCELoadedPredicate()); + ((JavascriptExecutor)browser).executeScript("top.tinymce.activeEditor.execCommand('mceInsertRawHTML', true, '" + content + "')"); + } + public static final void tinymce(String content, String containerCssSelector, WebDriver browser) { By tinyIdBy = By.cssSelector(containerCssSelector + " div.o_richtext_mce"); waitElement(tinyIdBy, 5, browser); -- GitLab