use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method deleteAnnouncementTest.
@Test
public void deleteAnnouncementTest() 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");
waitAndClick(".an-announcement-select input");
waitAndClick(".mf-items-toolbar .icon-delete");
waitAndClick(".mf-toolbar input[name='send']");
reloadCurrentPage();
assertTrue("Element found even though it shouldn't be there", isElementPresent(".an-announcement-topic>span") == false);
} finally {
deleteAnnouncements();
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method userGroupAnnouncementVisibleTest.
@Test
public void userGroupAnnouncementVisibleTest() 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).addStudentToStudentGroup(2l, student).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 ul>li>div>a");
assertTextIgnoreCase("#announcements ul>li>div>a", "Test title");
} finally {
deleteAnnouncements();
deleteUserGroup(2l);
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method myAnnnouncementsListTest.
@Test
public void myAnnnouncementsListTest() 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());
MockStaffMember another = new MockStaffMember(3l, 3l, "Another", "User", UserRole.ADMINISTRATOR, "121212-1234", "blaablaa@example.com", Sex.MALE);
Long courseId = 1l;
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStaffMember(another).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), new java.util.Date(), false, true, null);
createAnnouncement(another.getId(), "Another test title", "Another announcer test announcement", date(115, 10, 12), new java.util.Date(), false, true, null);
try {
navigate("/announcer", true);
waitForPresent(".an-announcement-topic");
assertCount("div.an-announcement-topic>span", 2);
waitAndClick("li.an-category[data-folder-id~=\"mine\"]");
waitForPresent("li.an-category.selected[data-folder-id~=\"mine\"]");
waitForPresent("div.an-announcement-topic>span");
assertTextIgnoreCase("div.an-announcement-topic>span", "Test title");
assertCount("div.an-announcement-topic>span", 1);
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class AnnouncerTestsBase method pastAnnnouncementsListTest.
@Test
public void pastAnnnouncementsListTest() 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());
Long courseId = 1l;
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", date(115, 10, 12), date(115, 10, 15), false, true, null);
try {
navigate("/announcer", true);
waitForPresent("div.mf-content-empty");
waitAndClick("li.an-category[data-folder-id~=\"past\"]");
waitForPresent("div.an-announcement-topic>span");
assertTextIgnoreCase("div.an-announcement-topic>span", "Test title");
navigate("/announcements", true);
waitForPresent("#announcements");
assertNotPresent(".announcement-article>header");
} finally {
deleteAnnouncements();
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.mock.model.MockStaffMember in project muikku by otavanopisto.
the class CoursePickerTestsBase method coursePickerSearchTest.
@Test
public void coursePickerSearchTest() 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();
Workspace workspace1 = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
Workspace workspace2 = createWorkspace("wiener course", "wiener course for testing", "2", Boolean.TRUE);
Workspace workspace3 = createWorkspace("potato course", "potato course for testing", "3", Boolean.TRUE);
try {
navigate("/coursepicker", true);
waitForPresent("#coursesList");
waitAndSendKeys(".cp-search-field input.search", "pot");
waitAndSendKeys(".cp-search-field input.search", "ato");
waitUntilElementCount(".cp-course-details-container .cp-course-long-name", 1);
sleep(1000);
waitForPresentAndVisible(".cp-course-details-container .cp-course-long-name");
assertTextIgnoreCase(".cp-course-details-container .cp-course-long-name", "potato course");
} finally {
deleteWorkspace(workspace1.getId());
deleteWorkspace(workspace2.getId());
deleteWorkspace(workspace3.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
Aggregations