Search in sources :

Example 6 with WorkspaceHtmlMaterial

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

the class CourseMaterialsPageTestsBase method courseMaterialTOCHighlightTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.PHANTOMJS, TestEnvironments.Browser.SAFARI })
public void courseMaterialTOCHighlightTest() throws Exception {
    maximizeWindow();
    loginAdmin();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    try {
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial1 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "1.0 Testimateriaali", "text/html;editor=CKEditor", "<html><body><p>Testi materiaalia:  Lorem ipsum dolor sit amet </p><p>Proin suscipit luctus orci placerat fringilla. Donec hendrerit laoreet risus eget adipiscing. Suspendisse in urna ligula, a volutpat mauris. Sed enim mi, bibendum eu pulvinar vel, sodales vitae dui. Pellentesque sed sapien lorem, at lacinia urna. In hac habitasse platea dictumst. Vivamus vel justo in leo laoreet ullamcorper non vitae lorem</p></body></html>", 1l, "EXERCISE");
        try {
            WorkspaceFolder workspaceFolder2 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 2, "Test material 2.0", "DEFAULT");
            WorkspaceHtmlMaterial htmlMaterial2 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder2.getId(), "2.0 Testmaterial", "text/html;editor=CKEditor", "<html><body><p>Test Matherial:  Lorem ipsum dolor sit amet </p><p>Senim mi, bibendum eu pulvinar vel, sodales vitae dui. Pellentesque sed sapien lorem, at lacinia urna. In hac habitasse platea dictumst. Vivamus vel justo in leo laoreet ullamcorper non vitae lorem</p></body></html>", 1l, "EXERCISE");
            try {
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitAndClick(String.format("a[href='#page-%d']", htmlMaterial2.getId()));
                waitForPresent(String.format("a.active[href='#page-%d']", htmlMaterial2.getId()));
                assertVisible(String.format("a.active[href='#page-%d']", htmlMaterial2.getId()));
            } finally {
                deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial2.getId());
            }
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) 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 7 with WorkspaceHtmlMaterial

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

the class CourseMaterialsPageTestsBase method answerFileFieldTestStudent.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER })
public void answerFileFieldTestStudent() 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 {
        File testFile = getTestFile();
        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.file\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-lAEveKeKFmjD5wQwcMh4SW20&quot;}\" /><input name=\"muikku-field-lAEveKeKFmjD5wQwcMh4SW20\" type=\"file\" /></p>", 1l, "EXERCISE");
            try {
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
                assertClassNotPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()), "muikku-field-saved");
                assertCount(String.format("#page-%d .muikku-file-input-field-file", htmlMaterial.getId()), 0);
                sendKeys(String.format("#page-%d .muikku-file-input-field-file-uploader-container input[type='file']", htmlMaterial.getId()), testFile.getAbsolutePath());
                waitClassPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()), "muikku-field-saved");
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
                assertCount(String.format("#page-%d .muikku-file-input-field-file", htmlMaterial.getId()), 1);
                assertTextIgnoreCase(String.format("#page-%d .muikku-file-input-field-file .muikku-file-input-field-file-label a", htmlMaterial.getId()), testFile.getName());
            } 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) File(java.io.File) 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 8 with WorkspaceHtmlMaterial

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

the class CourseMaterialsPageTestsBase method courseMaterialExistsTest.

@Test
public void courseMaterialExistsTest() throws Exception {
    loginAdmin();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    try {
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial1 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.getId(), "1.0 Testimateriaali", "text/html;editor=CKEditor", "<html><body><p>Testi materiaalia:  Lorem ipsum dolor sit amet </p><p>Proin suscipit luctus orci placerat fringilla. Donec hendrerit laoreet risus eget adipiscing. Suspendisse in urna ligula, a volutpat mauris. Sed enim mi, bibendum eu pulvinar vel, sodales vitae dui. Pellentesque sed sapien lorem, at lacinia urna. In hac habitasse platea dictumst. Vivamus vel justo in leo laoreet ullamcorper non vitae lorem</p></body></html>", 1l, "EXERCISE");
        try {
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(".material-view");
            assertVisible("article p");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Workspace(fi.otavanopisto.muikku.atests.Workspace) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 9 with WorkspaceHtmlMaterial

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

the class CourseMaterialsPageTestsBase method answerConnectFieldByDraggingTestAdmin.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void answerConnectFieldByDraggingTestAdmin() throws Exception {
    loginAdmin();
    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.connect\"><param name=\"type\" value=\"application/json\"/><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-k08yrkwguDBhVbyFyqzvi0KB&quot;,&quot;fields&quot;:[{&quot;name&quot;:&quot;1&quot;,&quot;text&quot;:&quot;Nakki&quot;},{&quot;name&quot;:&quot;2&quot;,&quot;text&quot;:&quot;Peruna&quot;},{&quot;name&quot;:&quot;3&quot;,&quot;text&quot;:&quot;Juusto&quot;},{&quot;name&quot;:&quot;4&quot;,&quot;text&quot;:&quot;Kinkku&quot;},{&quot;name&quot;:&quot;5&quot;,&quot;text&quot;:&quot;Leipä&quot;}],&quot;counterparts&quot;:[{&quot;name&quot;:&quot;A&quot;,&quot;text&quot;:&quot;Keppi&quot;},{&quot;name&quot;:&quot;B&quot;,&quot;text&quot;:&quot;Pulla&quot;},{&quot;name&quot;:&quot;C&quot;,&quot;text&quot;:&quot;Hampurilainen&quot;},{&quot;name&quot;:&quot;D&quot;,&quot;text&quot;:&quot;Kebab&quot;},{&quot;name&quot;:&quot;E&quot;,&quot;text&quot;:&quot;Halko&quot;}],&quot;connections&quot;:[{&quot;field&quot;:&quot;1&quot;,&quot;counterpart&quot;:&quot;A&quot;},{&quot;field&quot;:&quot;2&quot;,&quot;counterpart&quot;:&quot;B&quot;},{&quot;field&quot;:&quot;3&quot;,&quot;counterpart&quot;:&quot;C&quot;},{&quot;field&quot;:&quot;4&quot;,&quot;counterpart&quot;:&quot;D&quot;},{&quot;field&quot;:&quot;5&quot;,&quot;counterpart&quot;:&quot;E&quot;}]}\"/></object><br/></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 div.muikku-connect-field", htmlMaterial.getId()));
            assertClassNotPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()), "muikku-field-saved");
            String firstTermValue = getAttributeValue(".muikku-connect-field-term:nth-of-type(5)", "data-field-name");
            String lastCounterpartValue = getAttributeValue(".muikku-connect-field-counterpart:nth-of-type(4)", "data-field-value");
            scrollIntoView(".muikku-connect-field-counterpart:nth-of-type(5)");
            dragAndDrop(".muikku-connect-field-counterpart:nth-of-type(4)", ".muikku-connect-field-counterpart:nth-of-type(5)");
            waitClassPresent(".muikku-connect-field-counterpart:nth-of-type(5)", "muikku-connect-field-edited");
            waitClassPresent(".muikku-connect-field-term:nth-of-type(5)", "muikku-connect-field-edited");
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()));
            List<WebElement> terms = findElements(".muikku-connect-field-term");
            List<WebElement> counterparts = findElements(".muikku-connect-field-counterpart");
            assertTrue("No terms found", terms.size() > 0);
            for (int i = 0; i < terms.size(); i++) {
                if (terms.get(i).getAttribute("data-field-name") == firstTermValue) {
                    assertEquals(lastCounterpartValue, counterparts.get(i).getAttribute("data-field-value"));
                }
            }
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) WebElement(org.openqa.selenium.WebElement) 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 10 with WorkspaceHtmlMaterial

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

the class CourseMaterialsPageTestsBase method answerConnectFieldByClickingTestAdmin.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void answerConnectFieldByClickingTestAdmin() throws Exception {
    loginAdmin();
    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.connect\"><param name=\"type\" value=\"application/json\"/><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-k08yrkwguDBhVbyFyqzvi0KB&quot;,&quot;fields&quot;:[{&quot;name&quot;:&quot;1&quot;,&quot;text&quot;:&quot;Nakki&quot;},{&quot;name&quot;:&quot;2&quot;,&quot;text&quot;:&quot;Peruna&quot;},{&quot;name&quot;:&quot;3&quot;,&quot;text&quot;:&quot;Juusto&quot;},{&quot;name&quot;:&quot;4&quot;,&quot;text&quot;:&quot;Kinkku&quot;},{&quot;name&quot;:&quot;5&quot;,&quot;text&quot;:&quot;Leipä&quot;}],&quot;counterparts&quot;:[{&quot;name&quot;:&quot;A&quot;,&quot;text&quot;:&quot;Keppi&quot;},{&quot;name&quot;:&quot;B&quot;,&quot;text&quot;:&quot;Pulla&quot;},{&quot;name&quot;:&quot;C&quot;,&quot;text&quot;:&quot;Hampurilainen&quot;},{&quot;name&quot;:&quot;D&quot;,&quot;text&quot;:&quot;Kebab&quot;},{&quot;name&quot;:&quot;E&quot;,&quot;text&quot;:&quot;Halko&quot;}],&quot;connections&quot;:[{&quot;field&quot;:&quot;1&quot;,&quot;counterpart&quot;:&quot;A&quot;},{&quot;field&quot;:&quot;2&quot;,&quot;counterpart&quot;:&quot;B&quot;},{&quot;field&quot;:&quot;3&quot;,&quot;counterpart&quot;:&quot;C&quot;},{&quot;field&quot;:&quot;4&quot;,&quot;counterpart&quot;:&quot;D&quot;},{&quot;field&quot;:&quot;5&quot;,&quot;counterpart&quot;:&quot;E&quot;}]}\"/></object><br/></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 div.muikku-connect-field", htmlMaterial.getId()));
            assertClassNotPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()), "muikku-field-saved");
            String firstTermValue = getAttributeValue(".muikku-connect-field-term:nth-of-type(1)", "data-field-name");
            waitScrollAndClick(".muikku-connect-field-term:nth-of-type(1)");
            waitClassPresent(".muikku-connect-field-term:nth-of-type(1)", "muikku-connect-field-term-selected");
            String lastCounterpartValue = getAttributeValue(".muikku-connect-field-counterpart:nth-of-type(2)", "data-field-value");
            waitScrollAndClick(".muikku-connect-field-counterpart:nth-of-type(2)");
            waitClassPresent(".muikku-connect-field-counterpart:nth-of-type(1)", "muikku-connect-field-edited");
            waitClassPresent(".muikku-connect-field-term:nth-of-type(1)", "muikku-connect-field-edited");
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d div.muikku-connect-field", htmlMaterial.getId()));
            List<WebElement> terms = findElements(".muikku-connect-field-term");
            List<WebElement> counterparts = findElements(".muikku-connect-field-counterpart");
            assertTrue("No terms found", terms.size() > 0);
            for (int i = 0; i < terms.size(); i++) {
                if (terms.get(i).getAttribute("data-field-name") == firstTermValue) {
                    assertEquals(lastCounterpartValue, counterparts.get(i).getAttribute("data-field-value"));
                }
            }
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) WebElement(org.openqa.selenium.WebElement) 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

WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)38 Workspace (fi.otavanopisto.muikku.atests.Workspace)37 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)37 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)35 Test (org.junit.Test)35 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)33 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)24 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)24 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)17 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)10 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)10 OffsetDateTime (java.time.OffsetDateTime)6 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)5 File (java.io.File)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)2 WebElement (org.openqa.selenium.WebElement)2 Response (com.jayway.restassured.response.Response)1 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)1