use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method removeFileFieldTestAdmin.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX })
public void removeFileFieldTestAdmin() throws Exception {
loginAdmin();
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());
waitAndClick(".muikku-file-input-field-file-remove");
waitAndClick(".delete-button span");
waitForPresent(String.format("#page-%d .muikku-field-saved", htmlMaterial.getId()));
assertPresent(String.format("#page-%d .muikku-file-input-field-description", htmlMaterial.getId()));
reloadCurrentPage();
waitForPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
assertNotPresent(".muikku-file-input-field-file");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseFullscreenReadingButtonExistsTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseFullscreenReadingButtonExistsTest() 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();
maximizeWindow();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
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", workspace.getUrlName()), true);
waitForPresent(".icon-fullscreen");
assertVisible(".icon-fullscreen");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method connectFieldAsciiMathSupportTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void connectFieldAsciiMathSupportTest() 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();
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>Lorem not solor emut.</p><p><object type=\"application/vnd.muikku.field.connect\"><param name=\"type\" value=\"application/json\" />" + "<param name=\"content\" value=\"{"name":"muikku-field-r0iJ7LgkLdnysqQvJvIFffMf","fields":[{"name"" + ":"1","text":"`5x(a/(a + c)) = d`"},{"name":"2","text":"perti"}," + "{"name":"3","text":"sampo"}],"counterparts":[{"name":"A","text":"Ei"}," + "{"name":"B","text":"Kylla"},{"name":"C","text":"kunta"}],"connections"" + ":[{"field":"1","counterpart":"A"},{"field":"2","counterpart":"B"}," + "{"field":"3","counterpart":"C"}]}\" /></object></p> ", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-connect-field-term #MathJax-Element-2-Frame", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-connect-field-term #MathJax-Element-2-Frame", htmlMaterial.getId()));
waitForAttributeToHaveValue(".muikku-connect-field-term #MathJax-Element-2-Frame", "data-mathml");
String mathml = getAttributeValue(".muikku-connect-field-term #MathJax-Element-2-Frame", "data-mathml");
assertEquals("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mstyle displaystyle=\"true\"><mn>5</mn><mi>x</mi><mrow><mo>(</mo><mfrac><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mi>c</mi></mrow></mfrac><mo>)</mo></mrow><mo>=</mo><mi>d</mi></mstyle></math>", mathml);
waitAndClick("div[data-field-name='1']");
waitAndClick("div[data-field-value='A']");
waitAndClick("div[data-field-name='2']");
waitAndClick("div[data-field-value='B']");
waitAndClick("div[data-field-name='3']");
waitAndClick("div[data-field-value='C']");
// TODO: Remove sleep when concurrent save and submit issue fixed
sleep(350);
waitAndClick("button.muikku-check-exercises");
waitForPresentAndVisible(".correct-answers-count-data");
assertEquals("1 / 1", getWebDriver().findElement(By.cssSelector(".correct-answers-count-data")).getText());
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder 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.WorkspaceFolder 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();
}
}
Aggregations