Search in sources :

Example 36 with MockStudent

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

the class CommunicatorTestsBase method communicatorSentMessagesTest.

@Test
public void communicatorSentMessagesTest() 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();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    try {
        try {
            login();
            navigate("/communicator", true);
            waitAndClick(".mf-primary-function .mf-primary-function-content");
            waitForPresent("#recipientContent");
            sendKeys("#recipientContent", "Test");
            waitAndClick(".ui-autocomplete li.ui-menu-item");
            waitForPresent(".mf-textfield-subject");
            sendKeys(".mf-textfield-subject", "Test");
            waitAndClick("#cke_1_contents");
            addTextToCKEditor("Communicator test");
            waitAndClick("*[name='send']");
            waitForPresent(".mf-content-master");
            getWebDriver().get("about:blank");
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-header-content-secondary");
            assertText(".cm-message-header-content-secondary", "Test");
        } 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 37 with MockStudent

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

the class CommunicatorTestsBase method communicatorDeleteSentMessageTest.

@Test
public void communicatorDeleteSentMessageTest() 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);
            navigate("/communicator#sent", true);
            waitForPresent(".cm-message-select input[name=\"messageSelect\"]");
            click(".cm-message-select input[name=\"messageSelect\"]");
            waitForPresent(".icon-delete");
            click(".icon-delete");
            waitForPresent(".cm-messages-container");
            waitForPresent(".content");
            String currentUrl = getWebDriver().getCurrentUrl();
            assertTrue("Communicator does not stay in sent messages box.", currentUrl.equals("https://dev.muikku.fi:" + getPortHttps() + "/communicator#sent"));
            assertTrue("Element found even though it shouldn't be there", isElementPresent("div.cm-message-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 38 with MockStudent

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

the class CommunicatorTestsBase method communicatorReadMessageTest.

@Test
public void communicatorReadMessageTest() 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-header-content-secondary");
            waitForPresent(".cm-message-content-text");
            assertText("div.cm-message-content-text", "Test content.");
        } 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 39 with MockStudent

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

the class CommunicatorTestsBase method communicatorEditLabelTest.

@Test
public void communicatorEditLabelTest() 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(".mf-label-functions");
            waitAndClick(".mf-label-function-edit");
            waitForPresent(".mf-label-edit-dialog input[name=\"name\"]");
            clearElement(".mf-label-edit-dialog input[name=\"name\"]");
            waitAndSendKeys(".mf-label-edit-dialog input[name=\"name\"]", "edited");
            waitAndClick(".save-button span");
            assertText(".cm-folder .cm-label-name a span", "edited");
        } 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 40 with MockStudent

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

the class CommunicatorTestsBase method communicatorPagingTest.

@Test
public void communicatorPagingTest() 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");
            for (int i = 0; i < 30; i++) createCommunicatorMesssage("Test " + i, "Test content " + i, sender, recipient);
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate("/communicator", true);
            waitScrollAndClick(".cm-page-link-load-more");
            assertTrue(String.format("Elements list is not greater than %d in size", 10), waitForMoreThanSize("div.cm-message-header-content-secondary", 10));
        } 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)

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