Search in sources :

Example 81 with Workspace

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

the class CourseMaterialsPageTestsBase method removeFileFieldTestAdmin.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX })
public void removeFileFieldTestAdmin() throws Exception {
    loginAdmin();
    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());
            waitAndClick(".muikku-file-input-field-file-remove");
            waitAndClick(".delete-button span");
            waitForPresent(String.format("#page-%d .muikku-field-saved", htmlMaterial.getId()));
            assertPresent(String.format("#page-%d .muikku-file-input-field-description", htmlMaterial.getId()));
            reloadCurrentPage();
            waitForPresent(String.format("#page-%d .muikku-file-field", htmlMaterial.getId()));
            assertNotPresent(".muikku-file-input-field-file");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
        }
    } finally {
        deleteWorkspace(workspace.getId());
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) 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 82 with Workspace

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

the class CourseMaterialsPageTestsBase method courseFullscreenReadingButtonExistsTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseFullscreenReadingButtonExistsTest() 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);
        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(".icon-fullscreen");
            assertVisible(".icon-fullscreen");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial1.getId());
            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 83 with Workspace

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

the class CourseMaterialsPageTestsBase method connectFieldAsciiMathSupportTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void connectFieldAsciiMathSupportTest() 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>Lorem not solor emut.</p><p><object type=\"application/vnd.muikku.field.connect\"><param name=\"type\" value=\"application/json\" />" + "<param name=\"content\" value=\"{&quot;name&quot;:&quot;muikku-field-r0iJ7LgkLdnysqQvJvIFffMf&quot;,&quot;fields&quot;:[{&quot;name&quot;" + ":&quot;1&quot;,&quot;text&quot;:&quot;`5x(a/(a + c)) = d`&quot;},{&quot;name&quot;:&quot;2&quot;,&quot;text&quot;:&quot;perti&quot;}," + "{&quot;name&quot;:&quot;3&quot;,&quot;text&quot;:&quot;sampo&quot;}],&quot;counterparts&quot;:[{&quot;name&quot;:&quot;A&quot;,&quot;text&quot;:&quot;Ei&quot;}," + "{&quot;name&quot;:&quot;B&quot;,&quot;text&quot;:&quot;Kylla&quot;},{&quot;name&quot;:&quot;C&quot;,&quot;text&quot;:&quot;kunta&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;}]}\" /></object></p> ", 1l, "EXERCISE");
        try {
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d .muikku-connect-field-term #MathJax-Element-2-Frame", htmlMaterial.getId()));
            assertVisible(String.format("#page-%d .muikku-connect-field-term #MathJax-Element-2-Frame", htmlMaterial.getId()));
            waitForAttributeToHaveValue(".muikku-connect-field-term #MathJax-Element-2-Frame", "data-mathml");
            String mathml = getAttributeValue(".muikku-connect-field-term #MathJax-Element-2-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);
            waitAndClick("div[data-field-name='1']");
            waitAndClick("div[data-field-value='A']");
            waitAndClick("div[data-field-name='2']");
            waitAndClick("div[data-field-value='B']");
            waitAndClick("div[data-field-name='3']");
            waitAndClick("div[data-field-value='C']");
            // TODO: Remove sleep when concurrent save and submit issue fixed
            sleep(350);
            waitAndClick("button.muikku-check-exercises");
            waitForPresentAndVisible(".correct-answers-count-data");
            assertEquals("1 / 1", getWebDriver().findElement(By.cssSelector(".correct-answers-count-data")).getText());
        } 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 84 with Workspace

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

the class CoursePickerTestsBase method coursePickerExistsTest.

@Test
public void coursePickerExistsTest() throws Exception {
    loginAdmin();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    PyramusMocks.personsPyramusMocks();
    try {
        getWebDriver().get(getAppUrl(true) + "/coursepicker");
        waitForElementToBePresent(By.id("coursesList"));
        boolean elementExists = getWebDriver().findElements(By.id("coursesList")).size() > 0;
        WireMock.reset();
        assertTrue(elementExists);
    } finally {
        deleteWorkspace(workspace.getId());
    }
}
Also used : Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 85 with Workspace

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

the class CoursePickerTestsBase method coursePickerLoadMoreTest.

@Test
public void coursePickerLoadMoreTest() 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();
        List<Workspace> workspaces = new ArrayList<>();
        for (Long i = (long) 0; i < 30; i++) workspaces.add(createWorkspace("testcourse", "test course for testing " + i.toString(), i.toString(), Boolean.TRUE));
        try {
            getWebDriver().get(getAppUrl(true) + "/coursepicker");
            waitForMoreThanSize(".cp-course", 24);
            assertCount(".cp-course", 25);
            waitForPresent(".mf-paging-tool");
            scrollIntoView(".mf-paging-tool");
            waitAndClick(".mf-paging-tool");
            waitForMoreThanSize(".cp-course", 25);
            assertCount(".cp-course", 30);
        } finally {
            for (Workspace w : workspaces) {
                deleteWorkspace(w.getId());
            }
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) ArrayList(java.util.ArrayList) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

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