Search in sources :

Example 16 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.

the class CourseTestsBase method courseExistsTest.

@Test
public void courseExistsTest() 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.className("workspace-title"));
        boolean elementExists = getWebDriver().findElements(By.className("workspace-title")).size() > 0;
        assertTrue(elementExists);
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 17 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.

the class CourseAnnouncerTestsBase method workspaceAnnouncementVisibleInWorkspaceFrontpageTest.

@SuppressWarnings("deprecation")
@Test
public void workspaceAnnouncementVisibleInWorkspaceFrontpageTest() throws JsonProcessingException, 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());
    Long courseId = 1l;
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    login();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
    mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
    Long announcementId = createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", new Date(115, 10, 12), new Date(125, 10, 12), false, true, null);
    updateAnnouncementWorkspace(announcementId, workspace.getId());
    logout();
    mockBuilder.mockLogin(student).build();
    try {
        login();
        navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
        waitForPresent(".workspace-announcement-title");
        assertTextIgnoreCase(".workspace-announcement-title", "Test title");
    } finally {
        deleteAnnouncements();
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Date(java.sql.Date) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 18 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.

the class CourseAnnouncerTestsBase method workspaceAnnouncementFrontpageListingForStudentTest.

@SuppressWarnings("deprecation")
@Test
public void workspaceAnnouncementFrontpageListingForStudentTest() throws JsonProcessingException, 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());
    Long courseId = 1l;
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    login();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(2l, courseId, student.getId());
    mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
    Long announcementId = createAnnouncement(admin.getId(), "Test title", "Announcer test announcement", new Date(115, 10, 12), new Date(125, 10, 12), false, true, null);
    updateAnnouncementWorkspace(announcementId, workspace.getId());
    logout();
    mockBuilder.mockLogin(student).build();
    try {
        login();
        waitForPresent("#announcements ul>li>div>a");
        assertTextIgnoreCase("#announcements ul>li>div>a", "Test title");
        waitForPresent("#announcements ul>li>div.fp-announcement-info-workspace");
        assertTextIgnoreCase("#announcements ul>li>div.fp-announcement-info-workspace", "testcourse");
    } finally {
        deleteAnnouncements();
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Date(java.sql.Date) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 19 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.

the class CourseAnnouncerTestsBase method createWorkspaceAnnouncementTest.

@Test
public void createWorkspaceAnnouncementTest() throws JsonProcessingException, 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 {
        navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
        waitForPresent(".icon-cogs");
        hoverOverElement(".icon-cogs");
        waitAndClick(".icon-announcer");
        waitAndClick(".an-new-announcement");
        waitForPresent(".cke_wysiwyg_frame");
        waitForPresent("*[name='endDate']");
        clearElement("*[name='endDate']");
        sendKeys("*[name='endDate']", "21.12.2025");
        sendKeys(".mf-textfield-subject", "Test title");
        click(".mf-form-header");
        waitForPresent("#ui-datepicker-div");
        waitForNotVisible("#ui-datepicker-div");
        addTextToCKEditor("Announcer test announcement");
        waitAndClick(".mf-toolbar input[name='send']");
        waitForPresent(".an-announcement-topic");
        assertTextIgnoreCase(".an-announcement-topic>span", "Test title");
        assertTextIgnoreCase(".an-announcement-content>p", "Announcer test announcement");
    } finally {
        deleteAnnouncements();
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 20 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace in project muikku by otavanopisto.

the class CourseDiscussionTestsBase method courseDiscussionAdminCreateAreaTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionAdminCreateAreaTest() throws Exception {
    loginAdmin();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    try {
        DiscussionGroup discussionGroup = createWorkspaceDiscussionGroup(workspace.getId(), "test group");
        try {
            Discussion discussion = createWorkspaceDiscussion(workspace.getId(), discussionGroup.getId(), "test discussion");
            try {
                navigate(String.format("/workspace/%s/discussions", workspace.getName()), true);
                waitAndClick(".sm-flex-hide .di-new-area-button");
                waitAndSendKeys(".mf-textfield input", "Test area");
                click("*[name='send']");
                waitForPresent("#discussionAreaSelect option:nth-child(2)");
                assertText("#discussionAreaSelect option:nth-child(2)", "Test area");
            } finally {
                deleteWorkspaceDiscussion(workspace.getId(), discussionGroup.getId(), discussion.getId());
            }
        } finally {
            deleteWorkspaceDiscussionGroup(workspace.getId(), discussionGroup.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) Discussion(fi.otavanopisto.muikku.atests.Discussion) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

Workspace (fi.otavanopisto.muikku.atests.Workspace)95 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)92 Test (org.junit.Test)92 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)67 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)67 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)58 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)46 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)37 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)37 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)34 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 OffsetDateTime (java.time.OffsetDateTime)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)7 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 Discussion (fi.otavanopisto.muikku.atests.Discussion)5 DiscussionGroup (fi.otavanopisto.muikku.atests.DiscussionGroup)5 File (java.io.File)5 DiscussionThread (fi.otavanopisto.muikku.atests.DiscussionThread)3 Course (fi.otavanopisto.pyramus.rest.model.Course)3