Search in sources :

Example 6 with MockStudent

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

the class CourseAccessTestsBase method courseStudentMembersOnlyCourseAccessTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseStudentMembersOnlyCourseAccessTest() 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();
    try {
        mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
        login();
        Long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent mockCourseStudent = new MockCourseStudent(3l, courseId, student.getId());
        mockBuilder.addCourseStudent(workspace.getId(), mockCourseStudent).build();
        try {
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            waitAndClick(".additionalinfo-data div input[value=\"MEMBERS_ONLY\"]");
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForElementToBePresent(By.cssSelector(".loading"));
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            waitForVisible(".additionalinfo-data div input");
            sleep(1000);
            assertChecked(".additionalinfo-data div input[value=\"MEMBERS_ONLY\"]", true);
            logout();
            mockBuilder.mockLogin(student);
            login();
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            waitForPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
            assertPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
        } 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) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 7 with MockStudent

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

the class CourseAccessTestsBase method courseStudentLoggedInCourseAccessTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.PHANTOMJS })
public void courseStudentLoggedInCourseAccessTest() 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();
    try {
        mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
        login();
        Long courseId = 1l;
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent mockCourseStudent = new MockCourseStudent(3l, courseId, student.getId());
        mockBuilder.addCourseStudent(workspace.getId(), mockCourseStudent).build();
        try {
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            waitAndClick(".additionalinfo-data div input[value=\"LOGGED_IN\"]");
            waitAndClick(".workspace-management-footer .workspace-management-footer-actions-container button.save");
            waitForElementToBePresent(By.cssSelector(".loading"));
            navigate(String.format("/workspace/%s/workspace-management", workspace.getUrlName()), true);
            waitForVisible(".additionalinfo-data div input");
            sleep(1000);
            assertChecked(".additionalinfo-data div input[value=\"LOGGED_IN\"]", true);
            logout();
            mockBuilder.mockLogin(student);
            login();
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            assertPresent(".workspace-header-wrapper .workspace-header-container h1.workspace-title");
        } 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) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 8 with MockStudent

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

the class CourseTestsBase method courseTeacherVacationInfoTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseTeacherVacationInfoTest() 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();
    long courseId = 1l;
    CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
    MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
    mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
    login();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", Long.toString(courseId), Boolean.TRUE);
    mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
    try {
        navigate("/profile", true);
        waitForPresent(".profile-vacation-date");
        sendKeys(".profile-vacation-date input[name=\"profile-vacation-start\"]", "21.12.2010");
        sendKeys(".profile-vacation-date input[name=\"profile-vacation-end\"]", "21.12.2025");
        waitAndClick(".save-profile-fields");
        logout();
        mockBuilder.mockLogin(student);
        login();
        navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
        waitForPresent(".workspace-teacher-info .vacation-period");
        assertNotTextIgnoreCase(".workspace-teacher-info .vacation-period", "Unavailable 21.12.2010 - 21.12.2025");
    } finally {
        WireMock.reset();
        deleteWorkspace(workspace.getId());
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest) TestEnvironments(fi.otavanopisto.muikku.TestEnvironments)

Example 9 with MockStudent

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

the class CourseTestsBase method courseProgressWidgetsExistsTest.

@Test
public void courseProgressWidgetsExistsTest() 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());
    Long courseId = 1l;
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    try {
        login();
        Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.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, "EVALUATED");
        WorkspaceHtmlMaterial htmlMaterial2 = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.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);
            login();
            navigate(String.format("/workspace/%s", workspace.getUrlName()), true);
            waitForElementToBePresent(By.className("workspace-title"));
            waitForPresent(".materials-progress-evaluated-status");
            boolean evaluatedExists = getWebDriver().findElements(By.cssSelector(".materials-progress-evaluated-status")).size() > 0;
            assertTrue(evaluatedExists);
            waitAndClick(".materials-progress-evaluated-status");
            waitForPresentAndVisible(".workspace-progress-element-menu-content.evaluable");
            assertPresent(".workspace-progress-element-menu-content.evaluable");
            waitForPresent(".materials-progress-practice-status");
            boolean practiceExists = getWebDriver().findElements(By.cssSelector(".materials-progress-practice-status")).size() > 0;
            assertTrue(practiceExists);
            waitAndClick(".materials-progress-practice-status");
            waitForPresentAndVisible(".workspace-progress-element-menu-content.exercise");
            assertPresent(".workspace-progress-element-menu-content.exercise");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial2.getId());
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) Workspace(fi.otavanopisto.muikku.atests.Workspace) WorkspaceFolder(fi.otavanopisto.muikku.atests.WorkspaceFolder) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 10 with MockStudent

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

the class CourseTestsBase method courseProgressWidgetTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void courseProgressWidgetTest() 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());
    Long courseId = 2l;
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStudent(student).mockLogin(admin).build();
    try {
        login();
        Workspace workspace = createWorkspace("testcourses", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        MockCourseStudent courseStudent = new MockCourseStudent(2l, courseId, student.getId());
        CourseStaffMember courseStaffMember = new CourseStaffMember(1l, courseId, admin.getId(), 7l);
        mockBuilder.addCourseStaffMember(courseId, courseStaffMember).addCourseStudent(courseId, courseStudent).build();
        WorkspaceFolder workspaceFolder1 = createWorkspaceFolder(workspace.getId(), null, Boolean.FALSE, 1, "Test Course material folder", "DEFAULT");
        WorkspaceHtmlMaterial htmlMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.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, "EVALUATED");
        WorkspaceHtmlMaterial exerciseMaterial = createWorkspaceHtmlMaterial(workspace.getId(), workspaceFolder1.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);
            login();
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(".materials-progress-evaluated-status");
            boolean evaluatedExists = getWebDriver().findElements(By.cssSelector(".materials-progress-evaluated-status")).size() > 0;
            assertTrue(evaluatedExists);
            waitForPresent(".materials-progress-practice-status");
            boolean practiceExists = getWebDriver().findElements(By.cssSelector(".materials-progress-practice-status")).size() > 0;
            assertTrue(practiceExists);
            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");
            waitAndClick(String.format("#page-%d .muikku-submit-assignment", htmlMaterial.getId()));
            waitForPresentAndVisible(".notification-queue-item-success");
            waitForElementToBeClickable(String.format("#page-%d .muikku-withdraw-assignment", htmlMaterial.getId()));
            waitForPresent(".materials-progress-evaluated-status");
            assertTextIgnoreCase(".materials-progress-evaluated-status span", "1/1");
            assertVisible(String.format("#page-%d .muikku-text-field", exerciseMaterial.getId()));
            assertValue(String.format("#page-%d .muikku-text-field", exerciseMaterial.getId()), "");
            assertClassNotPresent(String.format("#page-%d .muikku-text-field", exerciseMaterial.getId()), "muikku-field-saved");
            sendKeys(String.format("#page-%d .muikku-text-field", exerciseMaterial.getId()), "field value");
            waitClassPresent(String.format("#page-%d .muikku-text-field", exerciseMaterial.getId()), "muikku-field-saved");
            waitAndClick(String.format("#page-%d .muikku-assignment-button", exerciseMaterial.getId()));
            waitUntilAnimationIsDone(".materials-progress-practice-status .slice .bar");
            waitForPresent(".materials-progress-practice-status");
            assertTextIgnoreCase(".materials-progress-practice-status span", "1/1");
            waitAndClick(".materials-progress-evaluated-status.evaluable span");
            waitForPresentAndVisible(".workspace-progress-element-menu-content.evaluable");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(2)>span:first-child", "Tehtäviä palautettu");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(2)>span:last-child", "1");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(3)>span:first-child", "Tehtäviä yhteensä");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(3)>span:last-child", "1");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(4)>span:first-child", "Tehtäviä arvioimatta");
            assertTextIgnoreCase("#evaluableMenu>div>div:nth-child(4)>span:last-child", "1");
            waitAndClick(".materials-progress-practice-status.exercise span");
            waitForPresentAndVisible(".workspace-progress-element-menu-content.exercise");
            assertTextIgnoreCase("#exerciseMenu>div>div:nth-child(2)>span:first-child", "Tehtäviä tehty");
            assertTextIgnoreCase("#exerciseMenu>div>div:nth-child(2)>span:last-child", "1");
            assertTextIgnoreCase("#exerciseMenu>div>div:nth-child(3)>span:first-child", "Tehtäviä yhteensä");
            assertTextIgnoreCase("#exerciseMenu>div>div:nth-child(3)>span:last-child", "1");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspaceHtmlMaterial(workspace.getId(), exerciseMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        WireMock.reset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) CourseStaffMember(fi.otavanopisto.pyramus.rest.model.CourseStaffMember) MockStaffMember(fi.otavanopisto.muikku.mock.model.MockStaffMember) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) MockCourseStudent(fi.otavanopisto.muikku.mock.model.MockCourseStudent) 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

MockStudent (fi.otavanopisto.muikku.mock.model.MockStudent)63 Builder (fi.otavanopisto.muikku.mock.PyramusMock.Builder)62 AbstractUITest (fi.otavanopisto.muikku.ui.AbstractUITest)62 Test (org.junit.Test)62 MockStaffMember (fi.otavanopisto.muikku.mock.model.MockStaffMember)61 Workspace (fi.otavanopisto.muikku.atests.Workspace)46 MockCourseStudent (fi.otavanopisto.muikku.mock.model.MockCourseStudent)35 TestEnvironments (fi.otavanopisto.muikku.TestEnvironments)27 CourseStaffMember (fi.otavanopisto.pyramus.rest.model.CourseStaffMember)18 WorkspaceFolder (fi.otavanopisto.muikku.atests.WorkspaceFolder)17 WorkspaceHtmlMaterial (fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial)17 OffsetDateTime (java.time.OffsetDateTime)8 MockCourse (fi.otavanopisto.muikku.mock.model.MockCourse)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 JSR310Module (com.fasterxml.jackson.datatype.jsr310.JSR310Module)3 File (java.io.File)3 Date (java.sql.Date)3 ArrayList (java.util.ArrayList)3 WebhookStudentUpdatePayload (fi.otavanopisto.pyramus.webhooks.WebhookStudentUpdatePayload)2 CourseAssessment (fi.otavanopisto.pyramus.rest.model.CourseAssessment)1