Search in sources :

Example 31 with TestEnvironments

use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.

the class CourseDiscussionTestsBase method courseDiscussionReplyTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionReplyTest() 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 {
                DiscussionThread thread = createWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), "Testing", "<p>Testing testing daa daa</p>", false, false);
                try {
                    navigate(String.format("/workspace/%s/discussions", workspace.getName()), true);
                    waitAndClick(".di-message-meta-topic>span");
                    waitAndClick(".di-message-reply-link");
                    addTextToCKEditor("Test reply for test.");
                    click("*[name='send']");
                    waitForPresent(".di-replies-container .mf-item-content-text p");
                    assertText(".di-replies-container .mf-item-content-text p", "Test reply for test.");
                } finally {
                    deleteWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), thread.getId());
                }
            } 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) DiscussionThread(fi.otavanopisto.muikku.atests.DiscussionThread) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 32 with TestEnvironments

use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.

the class CourseDiscussionTestsBase method courseDiscussionReplyReplyTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionReplyReplyTest() throws Exception {
    loginAdmin();
    try {
        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 {
                    DiscussionThread thread = createWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), "Testing", "<p>Testing testing daa daa</p>", false, false);
                    try {
                        navigate(String.format("/workspace/%s/discussions", workspace.getName()), true);
                        waitAndClick(".di-message-meta-topic>span");
                        waitAndClick(".di-message-reply-link");
                        addTextToCKEditor("Test reply for test.");
                        waitForPresent("*[name='send']");
                        click("*[name='send']");
                        waitForPresent(".di-replies-container .mf-item-content-text p");
                        waitAndClick(".di-replies-page .di-reply-answer-link>span");
                        addTextToCKEditor("Test reply reply for test.");
                        waitForPresent("*[name='send']");
                        click("*[name='send']");
                        waitForPresent(".di-replies-container .di-reply-reply .mf-item-content-text p");
                        assertText(".di-replies-container .di-reply-reply .mf-item-content-text p", "Test reply reply for test.");
                    } finally {
                        deleteWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), thread.getId());
                    }
                } finally {
                    deleteWorkspaceDiscussion(workspace.getId(), discussionGroup.getId(), discussion.getId());
                }
            } finally {
                deleteWorkspaceDiscussionGroup(workspace.getId(), discussionGroup.getId());
            }
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        WireMock.reset();
    }
}
Also used : DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) Discussion(fi.otavanopisto.muikku.atests.Discussion) DiscussionThread(fi.otavanopisto.muikku.atests.DiscussionThread) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 33 with TestEnvironments

use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.

the class CourseDiscussionTestsBase method courseDiscussionSendMessageTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionSendMessageTest() 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(".di-new-message-button>span");
                waitForPresent(".di-newmessage-form-container");
                waitForPresent(".mf-textfield-subcontainer input");
                sendKeys(".mf-textfield-subcontainer input", "Test title for discussion");
                addTextToCKEditor("Test text for discussion.");
                click("*[name='send']");
                waitForPresent(".di-message-meta-content>span>p");
                assertText(".di-message-meta-content>span>p", "Test text for discussion.");
            } 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)

Example 34 with TestEnvironments

use of fi.otavanopisto.muikku.TestEnvironments 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)

Example 35 with TestEnvironments

use of fi.otavanopisto.muikku.TestEnvironments in project muikku by otavanopisto.

the class CourseManagementTestsBase method changeCourseNameTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeCourseNameTest() 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);
            waitAndClick(".workspace-management-container input[name=\"workspaceName\"]");
            clearElement(".workspace-management-container input[name=\"workspaceName\"]");
            sendKeys(".workspace-management-container input[name=\"workspaceName\"]", "Testing course");
            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);
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForNotVisible(".loading");
            Course course = new Course(courseId, "Testing course", created, created, "<p>test course for testing</p>\n", false, 1, (long) 25, begin, end, "test extension", (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-header-container h1.workspace-title");
            assertTextIgnoreCase(".workspace-header-wrapper .workspace-header-container h1.workspace-title", "Testing course");
        } 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

TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)63 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)63 Test (org.junit.Test)63 Workspace (fi.otavanopisto.muikku.atests.Workspace)58 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)43 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)43 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)33 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)33 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)27 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)16 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)13 OffsetDateTime (java.time.OffsetDateTime)11 Discussion (fi.otavanopisto.muikku.atests.Discussion)10 DiscussionGroup (fi.otavanopisto.muikku.atests.DiscussionGroup)10 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 DiscussionThread (fi.otavanopisto.muikku.atests.DiscussionThread)6 File (java.io.File)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)4 Course (fi.otavanopisto.pyramus.rest.model.Course)3