Skip to content
Snippets Groups Projects
Commit 86a388ee authored by srosse's avatar srosse
Browse files

OO-3666: seleniium test which import 3 lectures blocks

parent 342f0b9a
No related branches found
No related tags found
No related merge requests found
......@@ -174,7 +174,7 @@ public class EditLectureBlockController extends FormBasicController {
plannedLecturesEl.setEnabled(!readOnly && plannedLecturesEditable);
String[] onValues = new String[]{ "" };
boolean compulsory = lectureBlock != null && lectureBlock.isCompulsory();
boolean compulsory = lectureBlock == null || lectureBlock.isCompulsory();
compulsoryEl = uifactory.addCheckboxesVertical("compulsory", "lecture.compulsory", formLayout, onKeys, onValues, 1);
compulsoryEl.setEnabled(!readOnly && !lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.compulsory));
compulsoryEl.addActionListener(FormEvent.ONCHANGE);
......
......@@ -573,4 +573,65 @@ public class LecturesTest extends Deployments {
.assertOnParticipantLectureBlocks()
.assertOnParticipantLectureBlockAuthorised(author, lectureTitle, title);
}
/**
* An author create a course to use the absence management
* and import some lectures blocks.
*
* @param loginPage
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void importLectures(@InitialPage LoginPage loginPage)
throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
// configure the lectures module
loginPage
.loginAs(author.getLogin(), author.getPassword())
.resume();
//go to authoring
AuthoringEnvPage authoringEnv = navBar
.assertOnNavigationPage()
.openAuthoringEnvironment();
String title = "Lecture " + UUID.randomUUID();
//create course
authoringEnv
.openCreateDropDown()
.clickCreate(ResourceType.course)
.fillCreateForm(title)
.assertOnGeneralTab()
.clickToolbarBack();
CoursePageFragment course = new CoursePageFragment(browser);
//enable the lectures
LectureRepositoryAdminPage lecturesAdmin = course
.lecturesAdministration();
lecturesAdmin
.settings()
.enableLectures()
.overrideDefaultSettings()
.saveSettings();
LectureRepositoryAdminListPage lectureList = lecturesAdmin
.lectureList();
// import the lecture blocks
lectureList
.importLecturesBlocks()
.importFile("lectures/import_lectures.txt")
.next()
.assertOnNumberOfNewBlocks(3)
.finish();
//check the blocks
lectureList
.assertOnLectureBlock("Abschlussparty")
.assertOnLectureBlock("Excel Workshop")
.assertOnLectureBlock("Mathematik Einf");
}
}
package org.olat.selenium.page.lecture;
import java.io.InputStream;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.selenium.page.graphene.OOGraphene;
import org.olat.test.JunitTestHelper;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
/**
*
* Initial date: 15 Oct 2018<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class ImportLecturesBlocksWizard {
private static final OLog log = Tracing.createLoggerFor(ImportLecturesBlocksWizard.class);
private final WebDriver browser;
public ImportLecturesBlocksWizard(WebDriver browser) {
this.browser = browser;
}
public ImportLecturesBlocksWizard importFile(String filename) {
StringBuilder sb = new StringBuilder(32000);
try(InputStream inStream = JunitTestHelper.class.getResourceAsStream("file_resources/" + filename)) {
String content = IOUtils.toString(inStream, "UTF-8");
String[] lines = content.split("\r?\n");
for(String line:lines) {
String[] cols = line.split("\t");
for(String col:cols) {
sb.append(col).append("\\t");
}
sb.append("\\n");
}
} catch(Exception ex) {
log.error("", ex);
}
By importAreaBy = By.cssSelector(".modal-content .o_wizard_steps_current_content textarea");
WebElement importAreaEl = browser.findElement(importAreaBy);
OOGraphene.textarea(importAreaEl, sb.toString(), browser);
return this;
}
public ImportLecturesBlocksWizard assertOnNumberOfNewBlocks(int numOfBlocks) {
By newRowsBy = By.cssSelector("td.o_dnd_label span i.o_icon.o_icon_check");
OOGraphene.waitElement(newRowsBy, browser);
List<WebElement> newRowsEl = browser.findElements(newRowsBy);
Assert.assertEquals(numOfBlocks, newRowsEl.size());
return this;
}
/**
* Next
* @return this
*/
public ImportLecturesBlocksWizard next() {
OOGraphene.nextStep(browser);
return this;
}
/**
* Finish the wizard
* @return this
*/
public ImportLecturesBlocksWizard finish() {
browser.findElement(OOGraphene.wizardFinishBy).click();
OOGraphene.waitBusy(browser);
OOGraphene.waitElementDisappears(By.cssSelector(".modal-content .wizard"), 5, browser);
return this;
}
}
......@@ -31,7 +31,7 @@ import org.openqa.selenium.WebDriver;
*/
public class LectureRepositoryAdminListPage {
private WebDriver browser;
private final WebDriver browser;
public LectureRepositoryAdminListPage(WebDriver browser) {
this.browser = browser;
......@@ -43,6 +43,12 @@ public class LectureRepositoryAdminListPage {
return this;
}
public LectureRepositoryAdminListPage assertOnLectureBlock(String title) {
By titleBy = By.xpath("//div[contains(@class,'o_table_flexi')]//td[text()[contains(.,'" + title + "')]]");
OOGraphene.waitElement(titleBy, browser);
return this;
}
public EditLectureBlockPage newLectureBlock() {
By addLectureBy = By.cssSelector("div.o_sel_repo_lectures_list a.o_sel_repo_add_lecture");
browser.findElement(addLectureBy).click();
......@@ -50,6 +56,15 @@ public class LectureRepositoryAdminListPage {
return new EditLectureBlockPage(browser);
}
public ImportLecturesBlocksWizard importLecturesBlocks() {
By importLecturesBy = By.cssSelector("div.o_sel_repo_lectures_list a.o_sel_repo_import_lectures");
browser.findElement(importLecturesBy).click();
OOGraphene.waitModalDialog(browser);
return new ImportLecturesBlocksWizard(browser);
}
}
L1 Mathematik Einführung 4 10/8/18 8:00 12:00 yes kanu@cyberiacafe.ch COURSE Zürich, HS76 This is about this and that Make your HP ready Teacher identified via Email address, participants from course
Abschlussparty 2 12/23/18 18:00 21:00:00 no aoi GROUP::Curriculum course group 1 Im Wald Ein schönes Abschlussfest Ein Wichtelgeschenk mitbringen Teacher identified via user name, Participants from a course group named "Samichlaus"
Excel Workshop 8 11/15/18 9:15 17:30 yes kanu@cyberiacafe.ch CURR::Physik Online Learn the basics of Excel Teacher identified via institutional user identifier, participants from a course curriculum element with ID "2018-HS-INFO"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment