Search in sources :

Example 16 with MockStaffMember

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

the class CourseAnnouncerTestsBase method createWorkspaceAnnouncementTest.

@Test
public void createWorkspaceAnnouncementTest() 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(".cke_wysiwyg_frame");
        waitForPresent("*[name='endDate']");
        clearElement("*[name='endDate']");
        sendKeys("*[name='endDate']", "21.12.2025");
        sendKeys(".mf-textfield-subject", "Test title");
        click(".mf-form-header");
        waitForPresent("#ui-datepicker-div");
        waitForNotVisible("#ui-datepicker-div");
        addTextToCKEditor("Announcer test announcement");
        waitAndClick(".mf-toolbar input[name='send']");
        waitForPresent(".an-announcement-topic");
        assertTextIgnoreCase(".an-announcement-topic>span", "Test title");
        assertTextIgnoreCase(".an-announcement-content>p", "Announcer test announcement");
    } 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 17 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember 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 18 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember 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 19 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember 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 20 with MockStaffMember

use of fi.otavanopisto.muikku.mock.model.MockStaffMember 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

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