Search in sources :

Example 66 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CourseMaterialsPageTestsBase method courseMaterialLicenseOverrideCC010Test.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void courseMaterialLicenseOverrideCC010Test() throws 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 {
        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-management", workspace.getUrlName()), true);
            waitForPresent(".page-license");
            click(".page-license");
            waitForPresent(".materials-management-page-license div select");
            waitForClickable(".materials-management-page-license div select");
            selectOption(".materials-management-page-license div select", "cc0-1.0");
            waitAndClick(".save-page-license");
            waitAndClick(String.format("#page-%d .publish-page", htmlMaterial1.getId()));
            waitAndClick(".ui-dialog-buttonset .publish-button");
            waitForPresent(".page-license");
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format(".material-license", htmlMaterial1.getId()));
            assertTextIgnoreCase(String.format(".material-license", htmlMaterial1.getId()), "https://creativecommons.org/publicdomain/zero/1.0/");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) 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 67 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CourseMaterialsPageTestsBase method organizerFieldAsciiMathSupportTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE })
public void organizerFieldAsciiMathSupportTest() throws 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();
    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.organizer\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" " + "value=\"{&quot;name&quot;:&quot;muikku-field-yFfjVqYptKe076qYHJDhJUW8&quot;,&quot;termTitle&quot;:&quot;Testi&quot;,&quot;terms&quot;" + ":[{&quot;id&quot;:&quot;t2&quot;,&quot;name&quot;:&quot;tarminen&quot;},{&quot;id&quot;:&quot;t3&quot;,&quot;name&quot;:&quot;torminen&quot;}" + ",{&quot;id&quot;:&quot;t4&quot;,&quot;name&quot;:&quot;`5x(a/(a + c)) = d`&quot;},{&quot;id&quot;:&quot;t5&quot;,&quot;name&quot;:&quot;dswe&quot;}]," + "&quot;categories&quot;:[{&quot;id&quot;:&quot;c1&quot;,&quot;name&quot;:&quot;Test1&quot;},{&quot;id&quot;:&quot;c2&quot;,&quot;name&quot;:&quot;test2&quot;}]," + "&quot;categoryTerms&quot;:[{&quot;category&quot;:&quot;c1&quot;,&quot;terms&quot;:[&quot;t2&quot;,&quot;t3&quot;,&quot;t4&quot;]},{&quot;category&quot;:&quot;c2&quot;" + ",&quot;terms&quot;:[&quot;t4&quot;,&quot;t5&quot;]}]}\" /></object></p>", 1l, "EXERCISE");
        try {
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d .muikku-term #MathJax-Element-1-Frame", htmlMaterial.getId()));
            assertVisible(String.format("#page-%d .muikku-term #MathJax-Element-1-Frame", htmlMaterial.getId()));
            waitForAttributeToHaveValue(".muikku-term #MathJax-Element-1-Frame", "data-mathml");
            String mathml = getAttributeValue(".muikku-term #MathJax-Element-1-Frame", "data-mathml");
            assertEquals("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mstyle displaystyle=\"true\"><mn>5</mn><mi>x</mi><mrow><mo>(</mo><mfrac><mi>a</mi><mrow><mi>a</mi><mo>+</mo><mi>c</mi></mrow></mfrac><mo>)</mo></mrow><mo>=</mo><mi>d</mi></mstyle></math>", mathml);
            dragAndDrop("div[data-term-id=\"t4\"]", "div[data-category-id=\"c1\"]");
            dragAndDrop("div[data-term-id=\"t2\"]", "div[data-category-id=\"c1\"]");
            dragAndDrop("div[data-term-id=\"t3\"]", "div[data-category-id=\"c1\"]");
            dragAndDrop("div[data-term-id=\"t4\"]", "div[data-category-id=\"c2\"]");
            dragAndDrop("div[data-term-id=\"t5\"]", "div[data-category-id=\"c2\"]");
            // TODO: Remove sleep when concurrent save and submit issue fixed
            sleep(350);
            waitAndClick("button.muikku-check-exercises");
            waitForPresentAndVisible("span.muikku-field-examples");
            assertClassPresent("div[data-category-id='c1']", "muikku-field-correct-answer");
            assertClassPresent("div[data-category-id='c2']", "muikku-field-correct-answer");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) 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 68 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CourseMaterialsPageTestsBase method courseMaterialLicenseOverrideCC4Test.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.SAFARI, TestEnvironments.Browser.PHANTOMJS })
public void courseMaterialLicenseOverrideCC4Test() throws 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 {
        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-management", workspace.getUrlName()), true);
            waitForPresent(".page-license");
            click(".page-license");
            waitForPresent(".materials-management-page-license div select");
            waitForClickable(".materials-management-page-license div select");
            selectOption(".materials-management-page-license div select", "cc-4.0");
            waitAndClick(".save-page-license");
            waitAndClick(String.format("#page-%d .publish-page", htmlMaterial1.getId()));
            waitAndClick(".ui-dialog-buttonset .publish-button");
            waitForPresent(".page-license");
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format(".material-license", htmlMaterial1.getId()));
            assertTextIgnoreCase(String.format(".material-license", htmlMaterial1.getId()), "https://creativecommons.org/licenses/by-sa/4.0");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) 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 69 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CourseMaterialsPageTestsBase method courseMaterialManagementButtonExistsTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseMaterialManagementButtonExistsTest() 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(admin).build();
    try {
        login();
        maximizeWindow();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
        try {
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(".icon-cogs");
            hoverOverElement(".icon-cogs");
            waitForPresentAndVisible(".icon-edit-materials");
            assertPresent(".icon-edit-materials");
        } finally {
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : 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) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 70 with Builder

use of fi.otavanopisto.muikku.mock.PyramusMock.Builder in project muikku by otavanopisto.

the class CourseMaterialsPageTestsBase method answerTextFieldTestStudent.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void answerTextFieldTestStudent() 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(admin).build();
    login();
    try {
        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.text\"><param name=\"type\" value=\"application/json\" /><param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-nT0yyez23QwFXD3G0I8HzYeK&quot;,&quot;rightAnswers&quot;:[],&quot;columns&quot;:&quot;&quot;,&quot;hint&quot;:&quot;&quot;}\" /></object></p>", 1l, "EXERCISE");
            logout();
            try {
                mockBuilder.mockLogin(student).build();
                login();
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
                assertVisible(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
                assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "");
                assertClassNotPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                sendKeys(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
                waitClassPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "muikku-field-saved");
                navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
                waitForPresent(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()));
                assertValue(String.format("#page-%d .muikku-text-field", htmlMaterial.getId()), "field value");
            } 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)88 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)88 Test (org.junit.Test)88 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)87 Workspace (fi.otavanopisto.muikku.atests.Workspace)67 MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)62 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