use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseUsersTestsBase method courseArchiveStudentTest.
@Test
public void courseArchiveStudentTest() 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();
try {
mockBuilder.addStaffMember(admin).mockLogin(admin).build();
login();
Long courseId = 1l;
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addStudent(student).addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
try {
navigate(String.format("/workspace/%s/users", workspace.getUrlName()), true);
waitForPresent(".workspace-students-listing-wrapper .workspace-users-name");
waitAndClick("div[data-user-id='PYRAMUS-STUDENT-2']>div.workspace-users-archive");
waitAndClick(".archive-button");
waitForPresentAndVisible(".workspace-students-listing-wrapper");
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
String payload = objectMapper.writeValueAsString(new WebhookStudentUpdatePayload(2l));
TestUtilities.webhookCall("http://dev.muikku.fi:" + getPortHttp() + "/pyramus/webhook", payload);
reloadCurrentPage();
waitForPresent(".workspace-students-list");
assertNotPresent("div[data-user-id='PYRAMUS-STUDENT-2']");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
mockBuilder.resetBuilder();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class EvaluationTestsBase method evaluateWorkspaceStudent.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateWorkspaceStudent() 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();
try {
mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
Long courseId = 1l;
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", courseId.toString(), Boolean.TRUE);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
try {
WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-nT0yyez23QwFXD3G0I8HzYeK","rightAnswers":[],"columns":"","hint":""}\" /></object></p>", 1l, "EVALUATED");
try {
Long assessorId = getUserEntityIdForIdentifier(String.format("STAFF-%s", admin.getId()));
logout();
mockBuilder.mockLogin(student).build();
login();
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
waitForPresentAndVisible(".notification-queue-item-success");
waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
logout();
mockBuilder.mockLogin(admin).build();
login();
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
// TODO: Move to new mocker
OffsetDateTime assessmentCreated = OffsetDateTime.of(2015, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
CourseAssessment courseAssessment = new CourseAssessment(1l, courseStudent.getId(), 1l, 1l, admin.getId(), assessmentCreated, "Test evaluation.", Boolean.TRUE);
stubFor(post(urlMatching(String.format("/1/students/students/%d/courses/%d/assessments/", student.getId(), courseStudent.getCourseId()))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(objectMapper.writeValueAsString(courseAssessment)).withStatus(200)));
navigate(String.format("/evaluation"), true);
waitAndClick("#filter-students-by-assessment-requested");
waitAndClick(".evaluation-student-name");
addTextToCKEditor("Test evaluation.");
clearElement("#evaluationDate");
sendKeys("#evaluationDate", "2.12.2015");
selectOption("#grade", "1/PYRAMUS@1/PYRAMUS");
selectOption("select[name='assessor']", assessorId.toString());
click(".save-evaluation-button");
waitForPresent(".notification-queue-item-success");
// There's no JSONComparator that allows different values. And since dev machine and travis testing gives different dates we can not test requestBody with CourseAssessment model.
CourseAssessment cAss = new fi.otavanopisto.pyramus.rest.model.CourseAssessment(null, courseStudent.getId(), 1l, 1l, admin.getId(), null, "<p>Test evaluation.</p>\n", Boolean.TRUE);
verify(postRequestedFor(urlEqualTo(String.format("/1/students/students/%d/courses/%d/assessments/", student.getId(), courseId))).withHeader("Content-Type", equalTo("application/json")).withRequestBody(equalToJson(objectMapper.writeValueAsString(cAss), true, true)));
PyramusMocks.mockAssessedStudent1Workspace1(courseStudent, assessorId);
waitForPresentAndVisible(".evaluation-assignment-wrapper");
assertClassPresent(".evaluation-student-wrapper", "workspace-evaluated");
waitAndClick(".evaluation-student-name");
waitForPresent("#grade");
assertValue("#grade", "1/PYRAMUS@1/PYRAMUS");
waitForPresent("select[name='assessor']");
assertValue("select[name='assessor']", assessorId.toString());
waitForPresent(".cke_contents");
assertEquals("Test evaluation.", getCKEditorContent());
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class EvaluationTestsBase method evaluateStudentWorkspaceMaterialTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluateStudentWorkspaceMaterialTest() 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();
try {
mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
Long courseId = 1l;
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
try {
WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-nT0yyez23QwFXD3G0I8HzYeK","rightAnswers":[],"columns":"","hint":""}\" /></object></p>", 1l, "EVALUATED");
Long assessorId = getUserEntityIdForIdentifier(String.format("STAFF-%s", admin.getId()));
logout();
mockBuilder.mockLogin(student).build();
login();
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
waitForPresentAndVisible(".notification-queue-item-success");
waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
logout();
mockBuilder.mockLogin(admin).build();
login();
navigate(String.format("/evaluation"), true);
waitAndClick("#filter-students-by-assessment-requested");
waitAndClick(".assignment-submitted");
addTextToCKEditor("Test evaluation.");
selectOption("#grade", "1/PYRAMUS@1/PYRAMUS");
selectOption("select[name='assessor']", assessorId.toString());
click(".save-evaluation-button");
waitForPresentAndVisible(".evaluation-assignment-wrapper");
assertClassPresent(".evaluation-assignment-wrapper", "assignment-evaluated");
waitAndClick(".assignment-submitted");
waitForPresent("#grade");
assertValue("#grade", "1/PYRAMUS@1/PYRAMUS");
waitForPresent("select[name='assessor']");
assertValue("select[name='assessor']", assessorId.toString());
waitForPresent(".cke_contents");
assertEquals("Test evaluation.", getCKEditorContent());
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class FlagTestsBase method editFlagTest.
@Test
public void editFlagTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@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());
MockStudent student2 = new MockStudent(4l, 4l, "Thirdester", "User", "testsostudent@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "030584-5656", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).addStudent(student2).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testscourse", "test course for testing", "3", Boolean.TRUE);
Workspace workspace2 = createWorkspace("diffentscourse", "Second test course", "4", Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(3l, workspace.getId(), student.getId());
MockCourseStudent mcs2 = new MockCourseStudent(4l, workspace.getId(), student2.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).addCourseStudent(workspace.getId(), mcs2).build();
Long flagId = createFlag("Test Flaggi", "#990000", "Fishing flags");
Long studentFlagId = flagStudent(student.getId(), flagId);
try {
navigate("/guider", true);
waitForPresentAndVisible("div.gt-user");
waitForPresentAndVisible(".gt-filters a.gt-filter-link");
click(".gt-filters a.gt-filter-link");
waitForPresent("div.gt-user .gt-user-name .gt-user-meta-topic>span");
click("div.gt-user .gt-user-name .gt-user-meta-topic>span");
waitForPresentAndVisible(".gt-tool-view-profile>span");
click(".gt-tool-view-profile>span");
waitForPresent("div.gt-flag.icon-flag");
hoverOverElement("div.gt-flag.icon-flag");
waitForPresentAndVisible(".gt-edit-flag");
click(".gt-edit-flag");
waitForPresent("input#guider-edit-flag-dialog-color");
setAttributeBySelector("input[type=\"color\"]", "value", "#009900");
clearElement("#guider-edit-flag-dialog-name");
waitAndSendKeys("#guider-edit-flag-dialog-name", "Test flag");
waitForPresent("textarea[name=\"description\"]");
clearElement("textarea[name=\"description\"]");
waitAndSendKeys("textarea[name=\"description\"]", "Sailing flags");
waitForPresentAndVisible(".ui-dialog-buttonset .save-button");
click(".ui-dialog-buttonset .save-button");
waitForPresent(".gt-flag-action-container");
reloadCurrentPage();
waitForPresent(".mf-widget.gt-user-view-flags-container .gt-flag>span.gt-flag-label");
assertTextIgnoreCase(".mf-widget.gt-user-view-flags-container .gt-flag>span.gt-flag-label", "Test Flag");
assertEquals("#009900", getAttributeValue("div.icon-flag", "data-flag-color"));
} finally {
deleteStudentFlag(studentFlagId);
deleteFlag(flagId);
deleteWorkspace(workspace.getId());
deleteWorkspace(workspace2.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class FlagTestsBase method unflagTest.
@Test
public void unflagTest() throws Exception {
MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@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());
MockStudent student2 = new MockStudent(4l, 4l, "Thirdester", "User", "testsostudent@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "030584-5656", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
Builder mockBuilder = mocker();
mockBuilder.addStaffMember(admin).addStudent(student).addStudent(student2).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testscourse", "test course for testing", "3", Boolean.TRUE);
Workspace workspace2 = createWorkspace("diffentscourse", "Second test course", "4", Boolean.TRUE);
MockCourseStudent mcs = new MockCourseStudent(3l, workspace.getId(), student.getId());
MockCourseStudent mcs2 = new MockCourseStudent(4l, workspace.getId(), student2.getId());
mockBuilder.addCourseStudent(workspace.getId(), mcs).addCourseStudent(workspace.getId(), mcs2).build();
Long flagId = createFlag("Test Flaggi", "#990000", "Fishing flags");
flagStudent(student.getId(), flagId);
try {
navigate("/guider", true);
waitForPresentAndVisible("div.gt-user");
waitForPresentAndVisible(".gt-filters a.gt-filter-link");
click(".gt-filters a.gt-filter-link");
waitForPresent("div.gt-user .gt-user-name .gt-user-meta-topic>span");
click("div.gt-user .gt-user-name .gt-user-meta-topic>span");
waitForPresentAndVisible(".gt-tool-view-profile>span");
click(".gt-tool-view-profile>span");
waitForPresent("div.gt-flag.icon-flag");
hoverOverElement("div.gt-flag.icon-flag");
waitForPresentAndVisible(".gt-remove-flag");
click(".gt-remove-flag");
waitForPresent(".gt-user-view-headline");
reloadCurrentPage();
waitForPresent(".gt-user-view-headline");
assertNotPresent(".mf-widget.gt-user-view-flags-container .gt-flag>span.gt-flag-label");
} finally {
deleteFlag(flagId);
deleteWorkspace(workspace.getId());
deleteWorkspace(workspace2.getId());
mockBuilder.wiremockReset();
}
}
Aggregations