Search in sources :

Example 1 with DiscussionGroup

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

Example 2 with DiscussionGroup

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

the class CourseDiscussionTestsBase method courseDiscussionDeleteThreadTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseDiscussionDeleteThreadTest() throws Exception {
    Long courseId = 1l;
    loginAdmin();
    try {
        Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), 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-remove-thread-link");
                        waitAndClick(".delete-button>span");
                        waitForPresent(".mf-content-empty>h3");
                        assertNotPresent(".di-threads .di-message");
                    } catch (Exception e) {
                        deleteWorkspaceDiscussionThread(workspace.getId(), discussionGroup.getId(), discussion.getId(), thread.getId());
                    } 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 3 with DiscussionGroup

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

the class AbstractUITest method createDiscussionGroup.

protected DiscussionGroup createDiscussionGroup(String name) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    DiscussionGroup payload = new DiscussionGroup(null, name);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/discussiongroups");
    response.then().statusCode(200);
    DiscussionGroup discussionGroup = objectMapper.readValue(response.asString(), DiscussionGroup.class);
    assertNotNull(discussionGroup);
    assertNotNull(discussionGroup.getId());
    return discussionGroup;
}
Also used : Response(com.jayway.restassured.response.Response) DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with DiscussionGroup

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

the class DiscussionTestsBase method discussionReplyTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void discussionReplyTest() throws Exception {
    loginAdmin();
    DiscussionGroup discussionGroup = createDiscussionGroup("test group");
    try {
        Discussion discussion = createDiscussion(discussionGroup.getId(), "test discussion");
        try {
            DiscussionThread thread = createDiscussionThread(discussionGroup.getId(), discussion.getId(), "Testing", "<p>Testing testing daa daa</p>", false, false);
            try {
                navigate("/discussion", 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 {
                deleteDiscussionThread(discussionGroup.getId(), discussion.getId(), thread.getId());
            }
        } finally {
            deleteDiscussion(discussionGroup.getId(), discussion.getId());
        }
    } finally {
        deleteDiscussionGroup(discussionGroup.getId());
        WireMock.reset();
    }
}
Also used : DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) Discussion(fi.otavanopisto.muikku.atests.Discussion) DiscussionThread(fi.otavanopisto.muikku.atests.DiscussionThread) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 5 with DiscussionGroup

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

the class AbstractUITest method createWorkspaceDiscussionGroup.

protected DiscussionGroup createWorkspaceDiscussionGroup(Long workspaceEntityId, String name) throws IOException {
    ObjectMapper objectMapper = new ObjectMapper().registerModule(new JSR310Module()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    DiscussionGroup payload = new DiscussionGroup(null, name);
    Response response = asAdmin().contentType("application/json").body(payload).post("/test/workspaces/{WORKSPACEENTITYID}/discussiongroups", workspaceEntityId);
    response.then().statusCode(200);
    DiscussionGroup workspaceDiscussionGroup = objectMapper.readValue(response.asString(), DiscussionGroup.class);
    assertNotNull(workspaceDiscussionGroup);
    assertNotNull(workspaceDiscussionGroup.getId());
    return workspaceDiscussionGroup;
}
Also used : Response(com.jayway.restassured.response.Response) DiscussionGroup(fi.otavanopisto.muikku.atests.DiscussionGroup) JSR310Module(com.fasterxml.jackson.datatype.jsr310.JSR310Module) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

DiscussionGroup (fi.otavanopisto.muikku.atests.DiscussionGroup)12 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)10 Discussion (fi.otavanopisto.muikku.atests.Discussion)10 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)10 Test (org.junit.Test)10 DiscussionThread (fi.otavanopisto.muikku.atests.DiscussionThread)6 Workspace (fi.otavanopisto.muikku.atests.Workspace)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)2 Response (com.jayway.restassured.response.Response)2