use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class AbstractUITest method createWorkspace.
protected Workspace createWorkspace(String name, String description, String identifier, Boolean published) throws Exception {
PyramusMocks.workspacePyramusMock(NumberUtils.createLong(identifier), name, description);
ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
Workspace payload = new Workspace(null, name, null, "PYRAMUS", identifier, published);
Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces");
response.then().statusCode(200);
Workspace workspace = objectMapper.readValue(response.asString(), Workspace.class);
assertNotNull(workspace);
assertNotNull(workspace.getId());
return workspace;
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseAccessTestsBase method notLoggedInLoggedInCourseAccessTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void notLoggedInLoggedInCourseAccessTest() 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 workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitAndClick(".additionalinfo-data div input[value=\"LOGGED_IN\"]");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForElementToBePresent(By.cssSelector(".loading"));
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForVisible(".additionalinfo-data div input");
sleep(1000);
assertChecked(".additionalinfo-data div input[value=\"LOGGED_IN\"]", true);
logout();
mockBuilder.clearLoginMock();
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
assertNotPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseAccessTestsBase method loggedInAnyoneCourseAccessTest.
@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void loggedInAnyoneCourseAccessTest() 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).addStudent(student).mockLogin(admin).build();
login();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitAndClick(".additionalinfo-data div input[value=\"ANYONE\"]");
waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
waitForElementToBePresent(By.cssSelector(".loading"));
navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
waitForVisible(".additionalinfo-data div input");
sleep(1000);
assertChecked(".additionalinfo-data div input[value=\"ANYONE\"]", true);
logout();
mockBuilder.mockLogin(student);
login();
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
assertPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
} finally {
deleteWorkspace(workspace.getId());
}
} finally {
mockBuilder.wiremockReset();
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseTestsBase method courseUnpublishTest.
@Test
public void courseUnpublishTest() throws Exception {
loginAdmin();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForPresent(".workspace-title");
assertVisible(".workspace-unpublish-button");
assertNotVisible(".workspace-publish-button");
click(".workspace-unpublish-button");
waitForPresent(".workspace-title");
assertNotVisible(".workspace-unpublish-button");
assertVisible(".workspace-publish-button");
} finally {
WireMock.reset();
deleteWorkspace(workspace.getId());
}
}
use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.
the class CourseTestsBase method courseHomeButtonExistsTest.
@Test
public void courseHomeButtonExistsTest() throws Exception {
loginAdmin();
Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
try {
navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
waitForElementToBePresent(By.cssSelector("#workspaceNavigationWrapper"));
boolean elementExists = getWebDriver().findElements(By.cssSelector("a.icon-home-workspace")).size() > 0;
assertTrue(elementExists);
} finally {
deleteWorkspace(workspace.getId());
WireMock.reset();
}
}
Aggregations