use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerFileFieldTestStudent.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER })
public void answerFileFieldTestStudent() 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 {
File testFile = getTestFile();
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.file\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-lAEveKeKFmjD5wQwcMh4SW20"}\" /><input name=\"muikku-field-lAEveKeKFmjD5wQwcMh4SW20\" type=\"file\" /></p>", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
assertPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
assertClassNotPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()), "muikku-field-saved");
assertCount(String.format("#page-%d .muikku-file-input-field-file", htmlMaterial.getId()), 0);
sendKeys(String.format("#page-%d .muikku-file-input-field-file-uploader-container input[type='file']", htmlMaterial.getId()), testFile.getAbsolutePath());
waitClassPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()), "muikku-field-saved");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
assertCount(String.format("#page-%d .muikku-file-input-field-file", htmlMaterial.getId()), 1);
assertTextIgnoreCase(String.format("#page-%d .muikku-file-input-field-file .muikku-file-input-field-file-label a", htmlMaterial.getId()), testFile.getName());
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseMaterialLicenseOverrideLinkTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void courseMaterialLicenseOverrideLinkTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial1 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "1.0 Testimateriaali", "text/html;editor=CKEditor", "<html><body><p>Testi materiaalia: Lorem ipsum dolor sit amet </p><p>Proin suscipit luctus orci placerat fringilla. Donec hendrerit laoreet risus eget adipiscing. Suspendisse in urna ligula, a volutpat mauris. Sed enim mi, bibendum eu pulvinar vel, sodales vitae dui. Pellentesque sed sapien lorem, at lacinia urna. In hac habitasse platea dictumst. Vivamus vel justo in leo laoreet ullamcorper non vitae lorem</p></body></html>", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials-management", workspace.getUrlName()), true);
waitForPresent(".page-license");
click(".page-license");
waitForPresent(".materials-management-page-license div select");
waitForClickable(".materials-management-page-license div select");
selectOption(".materials-management-page-license div select", "link");
waitAndSendKeys("input[name=\"license\"]", "www.test.com");
waitAndClick(".save-page-license");
waitAndClick(String.format("#page-%d .publish-page", htmlMaterial1.getId()));
waitAndClick(".ui-dialog-buttonset .publish-button");
waitForPresent(".page-license");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format(".material-license", htmlMaterial1.getId()));
assertTextIgnoreCase(String.format(".material-license", htmlMaterial1.getId()), "www.test.com");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseManagementButtonExistsTest.
@Test
public void courseManagementButtonExistsTest() 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(admin).build();
try {
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(".icon-cogs");
assertPresent(".icon-cogs");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method createAnnouncementTest.
@Test
public void createAnnouncementTest() throws JsonProcessingException, Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "User", UserRole.ADMINISTRATOR, "121212-1234", "admin@example.com", Sex.MALE);
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
try {
try {
login();
maximizeWindow();
navigate("/announcer", true);
waitAndClick(".an-new-announcement");
waitForPresent(".cke_wysiwyg_frame");
waitForPresent("*[name='endDate']");
clearElement("*[name='endDate']");
sendKeys("*[name='endDate']", "21.12.2025");
sendKeys(".mf-textfield-subject", "Test title");
click(".mf-form-header");
waitForPresent("#ui-datepicker-div");
waitForNotVisible("#ui-datepicker-div");
addTextToCKEditor("Announcer test announcement");
waitAndClick(".mf-toolbar input[name='send']");
waitForPresent(".an-announcement-topic");
assertTextIgnoreCase(".an-announcement-topic>span", "Test title");
assertTextIgnoreCase(".an-announcement-content>p", "Announcer test announcement");
} finally {
deleteAnnouncements();
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method userGroupAnnouncementNotVisibleTest.
@Test
public void userGroupAnnouncementNotVisibleTest() throws JsonProcessingException, 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();
try {
mockBuilder.addStaffMember(admin).addStudent(student).addStudentGroup(2l, "Test group", "Test group for users", 1l, false).addStaffMemberToStudentGroup(2l, admin).mockLogin(admin).build();
login();
try {
List<Long> userGroups = new ArrayList<>();
userGroups.add(2l);
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(125, 10, 12), false, false, userGroups);
logout();
mockBuilder.mockLogin(student);
login();
waitForPresent("#announcements");
assertTrue("Element found even though it shouldn't be there", isElementPresent("#announcements ul>li>div>a") == false);
} finally {
deleteAnnouncements();
}
} finally {
mockBuilder.wiremockReset();
}
}
Aggregations