Search in sources :

Example 1 with MockStudent

use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.

the class CommunicatorTestsBase method communicatorAddLabelTest.

@Test
public void communicatorAddLabelTest() 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();
        try {
            long recipient = getUserIdByEmail("admin@example.com");
            long sender = getUserIdByEmail("student@example.com");
            createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
            createCommunicatorUserLabel(admin.getId(), "test");
            navigate("/communicator#inbox", true);
            waitAndClick("input[name=\"messageSelect\"]");
            waitAndClick(".mf-tool-container .cm-add-label-menu");
            waitAndClick(".cm-label-link-name");
            reloadCurrentPage();
            waitForPresent(".cm-message-header-content-primary");
            assertText(".cm-message-header-content-secondary .cm-message-label span", "test");
            waitAndClick(".cm-folder .cm-label-name");
            waitForPresent(".cm-message-header-container");
            assertText(".cm-message-header-container .cm-message-caption", "Test captiontest");
        } finally {
            deleteCommunicatorUserLabels(admin.getId());
            deleteCommunicatorMessages();
        }
    } finally {
        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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 2 with MockStudent

use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.

the class CommunicatorTestsBase method communicatorDeleteInboxMessageTest.

@Test
public void communicatorDeleteInboxMessageTest() 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();
        try {
            long sender = getUserIdByEmail("admin@example.com");
            long recipient = getUserIdByEmail("student@example.com");
            createCommunicatorMesssage("Test caption", "Test content.", sender, recipient);
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate("/communicator", true);
            waitAndClick("div.cm-message-select input[type=\"checkbox\"]");
            waitAndClick(".icon-delete");
            // waitForPresentVisible(".notification-queue-item-success");
            waitForPresent(".cm-messages-container");
            assertTrue("Element found even though it shouldn't be there", isElementPresent("div.mf-item-select input[type=\"checkbox\"]") == false);
        } finally {
            deleteCommunicatorMessages();
        }
    } finally {
        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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 3 with MockStudent

use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.

the class CourseAccessTestsBase method loggedInLoggedInCourseAccessTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void loggedInLoggedInCourseAccessTest() 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=\"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.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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 4 with MockStudent

use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.

the class CourseAccessTestsBase method courseStudentAnyoneCourseAccessTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseStudentAnyoneCourseAccessTest() 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();
        Long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent mockCourseStudent = new MockCourseStudent(3l, courseId, student.getId());
        mockBuilder.addCourseStudent(workspace.getId(), mockCourseStudent).build();
        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();
    }
}
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) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 5 with MockStudent

use of fi.otavanopisto.muikku.mock.model.MockStudent in project muikku by otavanopisto.

the class CourseAccessTestsBase method loggedInMembersOnlyCourseAccessTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void loggedInMembersOnlyCourseAccessTest() 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=\"MEMBERS_ONLY\"]");
            scrollIntoView(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            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);
            waitForPresent(".additionalinfo-data div input");
            sleep(1000);
            assertChecked(".additionalinfo-data div input[value=\"MEMBERS_ONLY\"]", true);
            logout();
            mockBuilder.clearLoginMock();
            mockBuilder.mockLogin(student);
            login();
            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();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)63 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)62 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)62 Test (org.junit.Test)62 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)61 Workspace (fi.otavanopisto.muikku.atests.Workspace)46 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)35 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)27 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)17 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)17 OffsetDateTime (java.time.OffsetDateTime)8 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)3 File (java.io.File)3 Date (java.sql.Date)3 ArrayList (java.util.ArrayList)3 WebhookStudentUpdatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload)2 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)1