use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.
the class CourseDiscussionTestsBase method courseDiscussionDeleteThreadTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionDeleteThreadTest() throws Exception {
Long courseId = 1l;
loginAdmin();
try {
Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
try {
DiscussionGroup discussionGroup = createWorkspaceDiscussionGroup(workspace.getId(), "test group");
try {
Discussion discussion = createWorkspaceDiscussion(workspace.getId(), discussionGroup.getId(), "test discussion");
try {
DiscussionThread thread = createWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), "Testing", "<p>Testing testing daa daa</p>", false, false);
try {
navigate(String.format("/workspace/%s/discussions", workspace.getName()), true);
waitAndClick(".di-message-meta-topic>span");
waitAndClick(".di-remove-thread-link");
waitAndClick(".delete-button>span");
waitForPresent(".mf-content-empty>h3");
assertNotPresent(".di-threads .di-message");
} catch (Exception e) {
deleteWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), thread.getId());
} finally {
deleteWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), thread.getId());
}
} finally {
deleteWorkspaceDiscussion(workspace.getId(), discussionGroup.getId(), discussion.getId());
}
} finally {
deleteWorkspaceDiscussionGroup(workspace.getId(), discussionGroup.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.
the class CourseManagementTestsBase method addWorkspaceProducerTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void addWorkspaceProducerTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
long courseId = 1l;
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForPresent(".workspace-material-producers input");
scrollIntoView(".workspace-material-producers input");
sendKeys(".workspace-material-producers input", "Mr. Tester");
findElementByCssSelector(".workspace-material-producers input").sendKeys(Keys.RETURN);
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForNotVisible(".loading");
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".workspace-material-producer");
assertTextIgnoreCase(".workspace-material-producer", "Mr. Tester");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.
the class CourseManagementTestsBase method changeWorkspaceTypeTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeWorkspaceTypeTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
long courseId = 1l;
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForPresent(".additionalinfo-data .workspace-type");
scrollIntoView(".additionalinfo-data .workspace-type");
selectOption(".additionalinfo-data .workspace-type", "PYRAMUS-2");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForNotVisible(".loading");
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
OffsetDateTime created = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
OffsetDateTime end = OffsetDateTime.of(2050, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
Course course = new Course(courseId, "testcourse", created, created, "<p>test course for testing</p>\n", false, 1, (long) 25, begin, end, "test extension", (double) 15, (double) 45, (double) 45, (double) 15, (double) 45, (double) 45, end, (long) 1, (long) 1, (long) 1, null, (double) 45, (long) 1, (long) 1, (long) 1, (long) 2, null, null);
String courseJson = objectMapper.writeValueAsString(course);
stubFor(put(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
String payload = objectMapper.writeValueAsString(new WebhookCourseUpdatePayload(course.getId()));
TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc");
assertTextIgnoreCase(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc", "Ryhmäkurssi");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerRadioButtonsTestStudent.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerRadioButtonsTestStudent() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(student).build();
login();
try {
maximizeWindow();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
WorkspaceFolder workspaceFolder = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.select\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB","listType":"radio-vertical","options":[{"name":"1","text":"Koi","correct":false},{"name":"2","text":"Koppis","correct":false},{"name":"3","text":"Muurahainen","correct":true}]}\" /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"1\" /><label>Koi</label><br /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"2\" /><label>Koppis</label><br /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"3\" /><label>Muurahainen</label><br /></object></p><p> </p>", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()));
assertClassNotPresent(String.format("#page-%d .muikku-select-field input", htmlMaterial.getId()), "muikku-field-saved");
waitAndClick(".muikku-select-field input[value=\"1\"]");
waitClassPresent(String.format("#page-%d .muikku-select-field input", htmlMaterial.getId()), "muikku-field-saved");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()));
assertChecked(String.format("#page-%d .muikku-select-field input[value=\"1\"]", htmlMaterial.getId()), true);
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerCheckboxTestStudent.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerCheckboxTestStudent() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
MockStudent student = new MockStudent(2l, 2l, "Student", "Tester", "student@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(student).build();
login();
try {
maximizeWindow();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
WorkspaceFolder workspaceFolder = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.multiselect\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-nKTdumfsakZc5wFgru1LJoPs","listType":"checkbox-horizontal","options":[{"name":"1","text":"test1","correct":false},{"name":"2","text":"test2","correct":false}]}\" /><input name=\"muikku-field-nKTdumfsakZc5wFgru1LJoPs\" type=\"checkbox\" value=\"1\" /><label>test1</label><input name=\"muikku-field-nKTdumfsakZc5wFgru1LJoPs\" type=\"checkbox\" value=\"2\" /><label>test2</label></object></p>", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-checkbox-field", htmlMaterial.getId()));
assertClassNotPresent(String.format("#page-%d .muikku-checkbox-field input", htmlMaterial.getId()), "muikku-field-saved");
waitAndClick(".muikku-checkbox-field input[value=\"1\"]");
waitClassPresent(String.format("#page-%d .muikku-checkbox-field input", htmlMaterial.getId()), "muikku-field-saved");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-checkbox-field", htmlMaterial.getId()));
assertChecked(String.format("#page-%d .muikku-checkbox-field input[value=\"1\"]", htmlMaterial.getId()), true);
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
Aggregations