use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerConnectFieldByClickingTestAdmin.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void answerConnectFieldByClickingTestAdmin() throws Exception {
loginAdmin();
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.connect\"><param name=\"type\" value=\"application/json\"/><param name=\"content\" value=\"{"name":"muikku-field-k08yrkwguDBhVbyFyqzvi0KB","fields":[{"name":"1","text":"Nakki"},{"name":"2","text":"Peruna"},{"name":"3","text":"Juusto"},{"name":"4","text":"Kinkku"},{"name":"5","text":"Leipä"}],"counterparts":[{"name":"A","text":"Keppi"},{"name":"B","text":"Pulla"},{"name":"C","text":"Hampurilainen"},{"name":"D","text":"Kebab"},{"name":"E","text":"Halko"}],"connections":[{"field":"1","counterpart":"A"},{"field":"2","counterpart":"B"},{"field":"3","counterpart":"C"},{"field":"4","counterpart":"D"},{"field":"5","counterpart":"E"}]}\"/></object><br/></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 div.muikku-connect-field", htmlMaterial.getId()));
assertClassNotPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()), "muikku-field-saved");
String firstTermValue = getAttributeValue(".muikku-connect-field-term:nth-of-type(1)", "data-field-name");
waitScrollAndClick(".muikku-connect-field-term:nth-of-type(1)");
waitClassPresent(".muikku-connect-field-term:nth-of-type(1)", "muikku-connect-field-term-selected");
String lastCounterpartValue = getAttributeValue(".muikku-connect-field-counterpart:nth-of-type(2)", "data-field-value");
waitScrollAndClick(".muikku-connect-field-counterpart:nth-of-type(2)");
waitClassPresent(".muikku-connect-field-counterpart:nth-of-type(1)", "muikku-connect-field-edited");
waitClassPresent(".muikku-connect-field-term:nth-of-type(1)", "muikku-connect-field-edited");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()));
List<WebElement> terms = findElements(".muikku-connect-field-term");
List<WebElement> counterparts = findElements(".muikku-connect-field-counterpart");
assertTrue("No terms found", terms.size() > 0);
for (int i = 0; i < terms.size(); i++) {
if (terms.get(i).getAttribute("data-field-name") == firstTermValue) {
assertEquals(lastCounterpartValue, counterparts.get(i).getAttribute("data-field-value"));
}
}
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method courseMaterialEvaluatedClassTest.
public void courseMaterialEvaluatedClassTest() 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, "EVALUATED");
try {
getWebDriver().get(getAppUrl(true) + "/workspace/testcourse/materials");
waitForElementToBePresent(By.cssSelector(".muikku-page-assignment-type"));
String actual = findElementByCssSelector("#page-45>div").getAttribute("class");
String expected = new String("muikku-page-assignment-type evaluated");
assertEquals(expected, actual);
WireMock.reset();
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerDropdownTestAdmin.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerDropdownTestAdmin() 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.select\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{"name":"muikku-field-22p0Ll4KipuGHcP9n6W1qXBU","listType":"dropdown","options":[{"name":"1","text":"un","correct":false},{"name":"2","text":"dos","correct":false},{"name":"3","text":"tres","correct":false}]}\" /><select name=\"muikku-field-22p0Ll4KipuGHcP9n6W1qXBU\"></select></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-select-field", htmlMaterial.getId()));
assertValue(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()), "");
assertClassNotPresent(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()), "muikku-field-saved");
selectOption(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()), "2");
waitClassPresent(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()), "muikku-field-saved");
navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
waitForPresent(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()));
assertSelectedOption(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()), "dos");
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace 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.atests.Workspace in project muikku by otavanopisto.
the class CourseMaterialsPageTestsBase method answerFileFieldTestAdmin.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER })
public void answerFileFieldTestAdmin() 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());
} finally {
deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
}
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
Aggregations