Search in sources :

Example 56 with MockStaffMember

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

the class CourseAnnouncerTestsBase method deleteWorkspaceAnnouncementTest.

@Test
public void deleteWorkspaceAnnouncementTest() 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("*[name='endDate']");
        clearElement("*[name='endDate']");
        sendKeys("*[name='endDate']", "21.12.2025");
        sendKeys(".mf-textfield-subject", "Test title");
        click(".mf-form-header h3");
        waitForNotVisible("#ui-datepicker-div");
        addTextToCKEditor("Announcer test announcement");
        waitAndClick(".mf-toolbar input[name='send']");
        waitForPresent(".an-announcement-topic");
        waitAndClick(".an-announcement-select input");
        waitAndClick(".mf-items-toolbar .icon-delete");
        waitAndClick(".mf-toolbar input[name='send']");
        reloadCurrentPage();
        assertTrue("Element found even though it shouldn't be there", isElementPresent(".an-announcement-topic>span") == false);
    } 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 57 with MockStaffMember

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

the class CourseJournalPageTestsBase method courseJournalNewEntryForStudent.

@Test
public void courseJournalNewEntryForStudent() 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);
        Long courseId = NumberUtils.createLong(workspace.getIdentifier());
        MockCourseStudent courseStudent = new MockCourseStudent(1l, courseId, student.getId());
        mockBuilder.addCourseStudent(courseId, courseStudent).build();
        logout();
        mockBuilder.mockLogin(student).build();
        login();
        try {
            navigate(String.format("/workspace/%s/journal", workspace.getUrlName()), true);
            waitForPresent(".workspace-journal-content-wrapper");
            assertVisible(".workspace-journal-new-entry-button");
        } 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)

Example 58 with MockStaffMember

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

the class CourseJournalPageTestsBase method courseJournalToolsForTeacher.

@Test
public void courseJournalToolsForTeacher() 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/journal", workspace.getUrlName()), true);
            waitForPresent(".workspace-journal-content-wrapper");
            assertVisible(".workspace-journal-teacher-tools-container");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        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 59 with MockStaffMember

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

the class CourseJournalPageTestsBase method courseJournalEntryAdded.

@Test
public void courseJournalEntryAdded() 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);
        Long courseId = NumberUtils.createLong(workspace.getIdentifier());
        MockCourseStudent courseStudent = new MockCourseStudent(1l, courseId, student.getId());
        mockBuilder.addCourseStudent(courseId, courseStudent).build();
        logout();
        mockBuilder.mockLogin(student).build();
        login();
        try {
            navigate(String.format("/workspace/%s/journal", workspace.getUrlName()), true);
            click(".workspace-journal-new-entry-button");
            addTextToCKEditor("content");
            sendKeys(".mf-textfield-subject", "title");
            click("#socialNavigation.sn-container .jo-message-create .mf-toolbar input[name=\"send\"]");
            waitForPresent("#content");
            waitForPresent(".workspace-journal-title");
            assertText(".workspace-journal-title", "title");
            waitForPresent(".workspace-journal-content>p");
            assertText(".workspace-journal-content>p", "content");
        } 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)

Example 60 with MockStaffMember

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

the class CourseManagementTestsBase method changeAdditionalInfoTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeAdditionalInfoTest() 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();
        long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        try {
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            scrollIntoView(".additionalinfo-data input[name=\"workspaceNameExtension\"]");
            waitAndClick(".additionalinfo-data input[name=\"workspaceNameExtension\"]");
            clearElement(".additionalinfo-data input[name=\"workspaceNameExtension\"]");
            sendKeys(".additionalinfo-data input[name=\"workspaceNameExtension\"]", "For Test");
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForNotVisible(".loading");
            ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).setSerializationInclusion(Include.NON_NULL);
            OffsetDateTime created = OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC);
            OffsetDateTime begin = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
            OffsetDateTime end = OffsetDateTime.of(2050, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
            Course course = new Course(courseId, "testcourse", created, created, "<p>test course for testing</p>\n", false, 1, (long) 25, begin, end, "For Test", (double) 15, (double) 45, (double) 45, (double) 15, (double) 45, (double) 45, end, (long) 1, (long) 1, (long) 1, null, (double) 45, (long) 1, (long) 1, (long) 1, (long) 1, null, null);
            String courseJson = objectMapper.writeValueAsString(course);
            stubFor(put(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
            stubFor(get(urlEqualTo(String.format("/1/courses/courses/%d", courseId))).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(courseJson).withStatus(200)));
            String payload = objectMapper.writeValueAsString(new WebhookCourseCreatePayload(course.getId()));
            TestUtilities.webhookCall("http://dev.muikku.fi:" + System.getProperty("it.port.http") + "/pyramus/webhook", payload);
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            waitForPresent(".workspace-header-wrapper .workspace-additional-info-wrapper span");
            assertTextIgnoreCase(".workspace-header-wrapper .workspace-additional-info-wrapper span", "For Test");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Course(fi.otavanopisto.pyramus.rest.model.Course) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebhookCourseCreatePayload(fi.otavanopisto.pyramus.webhooks.WebhookCourseCreatePayload) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)87 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)87 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)87 Test (org.junit.Test)87 Workspace (fi.otavanopisto.muikku.atests.Workspace)67 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)61 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)43 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)34 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)24 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)24 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 OffsetDateTime (java.time.OffsetDateTime)11 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)6 Course (fi.otavanopisto.pyramus.rest.model.Course)3 File (java.io.File)3 Date (java.sql.Date)3 ArrayList (java.util.ArrayList)3 WebhookCourseCreatePayload (fi.otavanopisto.pyramus.webhooks.WebhookCourseCreatePayload)2