Search in sources :

Example 21 with Workspace

use of fi.otavanopisto.muikku.atests.Workspace 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 22 with Workspace

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

the class CourseManagementTestsBase method addWorkspaceProducerTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void addWorkspaceProducerTest() 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);
            waitForPresent(".workspace-material-producers input");
            scrollIntoView(".workspace-material-producers input");
            sendKeys(".workspace-material-producers input", "Mr. Tester");
            findElementByCssSelector(".workspace-material-producers input").sendKeys(Keys.RETURN);
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForNotVisible(".loading");
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            waitForPresent(".workspace-material-producer");
            assertTextIgnoreCase(".workspace-material-producer", "Mr. Tester");
        } 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) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 23 with Workspace

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

the class CourseManagementTestsBase method changeWorkspaceTypeTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void changeWorkspaceTypeTest() 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);
            waitForPresent(".additionalinfo-data .workspace-type");
            scrollIntoView(".additionalinfo-data .workspace-type");
            selectOption(".additionalinfo-data .workspace-type", "PYRAMUS-2");
            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, "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) 2, 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 WebhookCourseUpdatePayload(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-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc");
            assertTextIgnoreCase(".workspace-meta-wrapper .workspace-meta-item-wrapper:nth-child(3) .workspace-meta-desc", "Ryhmäkurssi");
        } 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) WebhookCourseUpdatePayload(fi.otavanopisto.pyramus.webhooks.WebhookCourseUpdatePayload) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 24 with Workspace

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

the class CourseMaterialsPageTestsBase method answerRadioButtonsTestStudent.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerRadioButtonsTestStudent() 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(student).build();
    login();
    try {
        maximizeWindow();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
        try {
            WorkspaceFolder workspaceFolder = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
            WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.select\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB&quot;,&quot;listType&quot;:&quot;radio-vertical&quot;,&quot;options&quot;:[{&quot;name&quot;:&quot;1&quot;,&quot;text&quot;:&quot;Koi&quot;,&quot;correct&quot;:false},{&quot;name&quot;:&quot;2&quot;,&quot;text&quot;:&quot;Koppis&quot;,&quot;correct&quot;:false},{&quot;name&quot;:&quot;3&quot;,&quot;text&quot;:&quot;Muurahainen&quot;,&quot;correct&quot;:true}]}\" /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"1\" /><label>Koi</label><br /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"2\" /><label>Koppis</label><br /><input name=\"muikku-field-d9DLvRe9kvMvvOCdtFqH4TiB\" type=\"radio\" value=\"3\" /><label>Muurahainen</label><br /></object></p><p>&nbsp;</p>", 1l, "EXERCISE");
            try {
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertVisible(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()));
                assertClassNotPresent(String.format("#page-%d .muikku-select-field input", htmlMaterial.getId()), "muikku-field-saved");
                waitAndClick(".muikku-select-field input[value=\"1\"]");
                waitClassPresent(String.format("#page-%d .muikku-select-field input", htmlMaterial.getId()), "muikku-field-saved");
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d .muikku-select-field", htmlMaterial.getId()));
                assertChecked(String.format("#page-%d .muikku-select-field input[value=\"1\"]", htmlMaterial.getId()), true);
            } finally {
                deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            }
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) 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) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 25 with Workspace

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

the class CourseMaterialsPageTestsBase method answerCheckboxTestStudent.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI })
public void answerCheckboxTestStudent() 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(student).build();
    login();
    try {
        maximizeWindow();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
        try {
            WorkspaceFolder workspaceFolder = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
            WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder.getId(), "Test", "text/html;editor=CKEditor", "<p><object type=\"application/vnd.muikku.field.multiselect\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nKTdumfsakZc5wFgru1LJoPs&quot;,&quot;listType&quot;:&quot;checkbox-horizontal&quot;,&quot;options&quot;:[{&quot;name&quot;:&quot;1&quot;,&quot;text&quot;:&quot;test1&quot;,&quot;correct&quot;:false},{&quot;name&quot;:&quot;2&quot;,&quot;text&quot;:&quot;test2&quot;,&quot;correct&quot;:false}]}\" /><input name=\"muikku-field-nKTdumfsakZc5wFgru1LJoPs\" type=\"checkbox\" value=\"1\" /><label>test1</label><input name=\"muikku-field-nKTdumfsakZc5wFgru1LJoPs\" type=\"checkbox\" value=\"2\" /><label>test2</label></object></p>", 1l, "EXERCISE");
            try {
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertVisible(String.format("#page-%d .muikku-checkbox-field", htmlMaterial.getId()));
                assertClassNotPresent(String.format("#page-%d .muikku-checkbox-field input", htmlMaterial.getId()), "muikku-field-saved");
                waitAndClick(".muikku-checkbox-field input[value=\"1\"]");
                waitClassPresent(String.format("#page-%d .muikku-checkbox-field input", htmlMaterial.getId()), "muikku-field-saved");
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d .muikku-checkbox-field", htmlMaterial.getId()));
                assertChecked(String.format("#page-%d .muikku-checkbox-field input[value=\"1\"]", htmlMaterial.getId()), true);
            } finally {
                deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            }
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) 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) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Aggregations

Workspace (fi.otavanopisto.muikku.atests.Workspace)95 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)92 Test (org.junit.Test)92 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)67 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)67 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)58 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)46 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)37 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)37 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)34 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 OffsetDateTime (java.time.OffsetDateTime)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)7 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 Discussion (fi.otavanopisto.muikku.atests.Discussion)5 DiscussionGroup (fi.otavanopisto.muikku.atests.DiscussionGroup)5 File (java.io.File)5 DiscussionThread (fi.otavanopisto.muikku.atests.DiscussionThread)3 Course (fi.otavanopisto.pyramus.rest.model.Course)3