use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method organizerFieldAsciiMathSupportTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void organizerFieldAsciiMathSupportTest() 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><object type=\"application/vnd.muikku.field.organizer\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" " + "value=\"{"name":"muikku-field-yFfjVqYptKe076qYHJDhJUW8","termTitle":"Testi","terms"" + ":[{"id":"t2","name":"tarminen"},{"id":"t3","name":"torminen"}" + ",{"id":"t4","name":"`5x(a/(a + c)) = d`"},{"id":"t5","name":"dswe"}]," + ""categories":[{"id":"c1","name":"Test1"},{"id":"c2","name":"test2"}]," + ""categoryTerms":[{"category":"c1","terms":["t2","t3","t4"]},{"category":"c2"" + ","terms":["t4","t5"]}]}\" /></object></p>", 1l, "EXERCISE");
try {
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-term #MathJax-Element-1-Frame", htmlMaterial.getId()));
assertVisible(String.format("#page-%d .muikku-term #MathJax-Element-1-Frame", htmlMaterial.getId()));
waitForAttributeToHaveValue(".muikku-term #MathJax-Element-1-Frame", "data-mathml");
String mathml = getAttributeValue(".muikku-term #MathJax-Element-1-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);
dragAndDrop("div[data-term-id=\"t4\"]", "div[data-category-id=\"c1\"]");
dragAndDrop("div[data-term-id=\"t2\"]", "div[data-category-id=\"c1\"]");
dragAndDrop("div[data-term-id=\"t3\"]", "div[data-category-id=\"c1\"]");
dragAndDrop("div[data-term-id=\"t4\"]", "div[data-category-id=\"c2\"]");
dragAndDrop("div[data-term-id=\"t5\"]", "div[data-category-id=\"c2\"]");
// TODO: Remove sleep when concurrent save and submit issue fixed
sleep(350);
waitAndClick("button.muikku-check-exercises");
waitForPresentAndVisible("span.muikku-field-examples");
assertClassPresent("div[data-category-id='c1']", "muikku-field-correct-answer");
assertClassPresent("div[data-category-id='c2']", "muikku-field-correct-answer");
} 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 CourseMaterialsPageTestsBase method courseMaterialLicenseOverrideCC4Test.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void courseMaterialLicenseOverrideCC4Test() 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", "cc-4.0");
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()), "https://creativecommons.org/licenses/by-sa/4.0");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseTOCExistsTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.PHANTOMJS, TestEnvironments.Browser.SAFARI })
public void courseTOCExistsTest() throws Exception {
maximizeWindow();
loginAdmin();
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 {
WorkspaceFolder workspaceFolder2 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 2, "Test material 2.0", "DEFAULT");
WorkspaceHtmlMaterial htmlMaterial2 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder2.getId(), "2.0 Testmaterial", "text/html;editor=CKEditor", "<html><body><p>Test Matherial: Lorem ipsum dolor sit amet </p><p>Senim 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("#workspaceMaterialsTOCWrapper");
assertVisible("#workspaceMaterialsTOCWrapper");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial2.getId());
}
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseMaterialExerciseClassTest.
public void courseMaterialExerciseClassTest() throws Exception {
loginAdmin();
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 {
getWebDriver().get(getAppUrl(true) + "/workspace/testcourse/materials");
waitForElementToBePresent(By.cssSelector(".muikku-page-assignment-type"));
String actual = findElementByCssSelector(String.format("#page-%d>div", htmlMaterial1.getId())).getAttribute("class");
String expected = new String("muikku-page-assignment-type exercise");
assertEquals(expected, actual);
WireMock.reset();
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.WorkspaceFolder in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerCheckboxTestAdmin.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerCheckboxTestAdmin() throws Exception {
loginAdmin();
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());
WireMock.reset();
}
}
Aggregations