Search in sources :

Example 26 with MockStudent

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

the class FlagTestsBase method shareFlagTest.

@Test
public void shareFlagTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
    MockStaffMember testPerson = new MockStaffMember(2l, 2l, "Test", "Person", UserRole.ADMINISTRATOR, "090979-5434", "testperson@example.com", Sex.MALE);
    MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@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());
    MockStudent student2 = new MockStudent(4l, 4l, "Thirdester", "User", "testsostudent@example.com", 1l, OffsetDateTime.of(1990, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), "030584-5656", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    Builder mockBuilder = mocker();
    mockBuilder.addStaffMember(admin).addStaffMember(testPerson).addStudent(student).addStudent(student2).mockLogin(admin).build();
    login();
    Workspace workspace = createWorkspace("testscourse", "test course for testing", "3", Boolean.TRUE);
    Workspace workspace2 = createWorkspace("diffentscourse", "Second test course", "4", Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(3l, workspace.getId(), student.getId());
    MockCourseStudent mcs2 = new MockCourseStudent(4l, workspace.getId(), student2.getId());
    mockBuilder.addCourseStudent(workspace.getId(), mcs).addCourseStudent(workspace.getId(), mcs2).build();
    Long flagId = createFlag("Test Flaggi", "#990000", "Fishing flags");
    Long studentFlagId = flagStudent(student.getId(), flagId);
    try {
        navigate("/guider", true);
        waitForPresentAndVisible("div.gt-user");
        waitForPresentAndVisible(".gt-filters a.gt-filter-link");
        click(".gt-filters a.gt-filter-link");
        waitForPresent("div.gt-user .gt-user-name .gt-user-meta-topic>span");
        click("div.gt-user .gt-user-name .gt-user-meta-topic>span");
        waitForPresentAndVisible(".gt-tool-view-profile>span");
        click(".gt-tool-view-profile>span");
        waitForPresent("div.gt-flag.icon-flag");
        hoverOverElement("div.gt-flag.icon-flag");
        waitForPresentAndVisible(".gt-share-flag");
        click(".gt-share-flag");
        waitAndSendKeys("#guider-share-flag-dialog-users", "Test");
        waitAndClick(".guider-dialog-user-search ul li.ui-menu-item");
        waitForPresent("div.shares div.share label");
        assertText("div.shares div.share label", "Test Person <testperson@example.com>");
        waitAndClick(".ui-dialog-buttonpane .save-button>span");
        waitForPresent(".gt-user-view-headline");
        reloadCurrentPage();
        logout();
        mockBuilder.mockLogin(testPerson).build();
        login();
        navigate("/guider", true);
        waitForPresentAndVisible("div.gt-user");
        click("div.gt-user .gt-user-name .gt-user-meta-topic>span");
        waitForPresentAndVisible(".gt-tool-view-profile>span");
        click(".gt-tool-view-profile>span");
        waitForPresentAndVisible(".gt-filters a.gt-filter-link");
        assertTextIgnoreCase(".gt-filters a.gt-filter-link>span:not(.icon-flag)", "Test Flaggi");
    } finally {
        deleteFlagShares(flagId);
        deleteStudentFlag(studentFlagId);
        deleteFlag(flagId);
        deleteWorkspace(workspace.getId());
        deleteWorkspace(workspace2.getId());
        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)

Example 27 with MockStudent

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

the class GuiderTestsBase method filterByNameTest.

@Test
public void filterByNameTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@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();
    Workspace workspace = createWorkspace("testscourse", "test course for testing", "3", Boolean.TRUE);
    Workspace workspace2 = createWorkspace("diffentscourse", "Second test course", "4", Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(3l, workspace.getId(), student.getId());
    mockBuilder.addCourseStudent(workspace.getId(), mcs).build();
    try {
        navigate("/guider", true);
        sendKeys(".gt-search .search", "Second User");
        waitForPresent(".gt-user .gt-user-meta-topic>span");
        assertText(".gt-user .gt-user-meta-topic>span", "Second User (Test Study Programme)");
    } finally {
        deleteWorkspace(workspace.getId());
        deleteWorkspace(workspace2.getId());
        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)

Example 28 with MockStudent

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

the class GuiderTestsBase method filterByWorkspaceTest.

@Test
public void filterByWorkspaceTest() throws Exception {
    MockStaffMember admin = new MockStaffMember(1l, 1l, "Admin", "Person", UserRole.ADMINISTRATOR, "090978-1234", "testadmin@example.com", Sex.MALE);
    MockStudent student = new MockStudent(3l, 3l, "Second", "User", "teststudent@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();
    Workspace workspace = createWorkspace("testcourse", "test course for testing", "1", Boolean.TRUE);
    Workspace workspace2 = createWorkspace("diffentcourse", "Second test course", "2", Boolean.TRUE);
    MockCourseStudent mcs = new MockCourseStudent(1l, workspace.getId(), student.getId());
    CourseStaffMember courseStaffMember = new CourseStaffMember(1l, 1l, admin.getId(), 7l);
    mockBuilder.addCourseStaffMember(workspace.getId(), courseStaffMember).addCourseStudent(workspace.getId(), mcs).build();
    try {
        navigate("/guider", true);
        waitAndClick(String.format("a.gt-filter-link[data-id~=\"%d\"]", workspace.getId()));
        waitForPresent(".gt-user .gt-user-meta-topic>span");
        assertText(".gt-user .gt-user-meta-topic>span", "Second User (Test Study Programme)");
    } finally {
        deleteWorkspace(workspace2.getId());
        deleteWorkspace(workspace.getId());
        mockBuilder.wiremockReset();
    }
}
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)

Example 29 with MockStudent

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

the class IndexPageTestsBase method studentLoginTest.

@Test
public void studentLoginTest() throws Exception {
    MockStudent student = new MockStudent(2l, 2l, "Second", "User", "teststudent@example.com", 1l, TestUtilities.toDate(1990, 1, 1), "121212-1212", Sex.FEMALE, TestUtilities.toDate(2012, 1, 1), TestUtilities.getNextYear());
    Builder mockBuilder = mocker();
    mockBuilder.addStudent(student).mockLogin(student).build();
    try {
        login();
        assertVisible("#loggedUser");
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : Builder(fi.otavanopisto.muikku.mock.PyramusMock.Builder) MockStudent(fi.otavanopisto.muikku.mock.model.MockStudent) Test(org.junit.Test) AbstractUITest(fi.otavanopisto.muikku.ui.AbstractUITest)

Example 30 with MockStudent

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

the class NewEvaluationTestsBase method evaluationVisibleInMaterialViewTest.

@Test
@TestEnvironments(browsers = { TestEnvironments.Browser.CHROME, TestEnvironments.Browser.FIREFOX, TestEnvironments.Browser.INTERNET_EXPLORER, TestEnvironments.Browser.EDGE, TestEnvironments.Browser.SAFARI })
public void evaluationVisibleInMaterialViewTest() 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());
    OffsetDateTime date = OffsetDateTime.of(2016, 11, 10, 1, 1, 1, 1, ZoneOffset.UTC);
    Builder mockBuilder = mocker();
    try {
        mockBuilder.addStudent(student).addStaffMember(admin).mockLogin(admin).build();
        Long courseId = 1l;
        login();
        Workspace workspace = createWorkspace("testcourse", "test course for testing", String.valueOf(courseId), Boolean.TRUE);
        OffsetDateTime created = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime begin = OffsetDateTime.of(2015, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        OffsetDateTime end = OffsetDateTime.of(2045, 10, 12, 12, 12, 0, 0, ZoneOffset.UTC);
        MockCourse mockCourse = new MockCourse(workspace.getId(), workspace.getName(), created, "test course", begin, end);
        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 exercise", "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");
        try {
            logout();
            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");
            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()));
            mockBuilder.mockAssessmentRequests(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, date).mockCompositeGradingScales().addCompositeCourseAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, date).mockCompositeCourseAssessmentRequests().addStaffCompositeAssessmentRequest(student.getId(), courseId, courseStudent.getId(), "Hello!", false, false, TestUtilities.courseFromMockCourse(mockCourse), student, admin.getId(), date).mockStaffCompositeCourseAssessmentRequests();
            logout();
            mockBuilder.mockLogin(admin).build();
            login();
            navigate(String.format("/evaluation2"), true);
            waitAndClick(".evaluate-button");
            waitAndClick(".assignment-title-wrapper");
            waitForPresentAndVisible(".assignment-wrapper .muikku-text-field");
            assertTextIgnoreCase(".assignment-wrapper .muikku-text-field", "field value");
            waitAndClick(".assignment-evaluate-button");
            waitUntilAnimationIsDone("#evaluationAssignmentEvaluateContainer");
            waitForElementToBeClickable("#evaluationAssignmentEvaluateContainer .evaluation-modal-evaluate-form #cke_assignmentEvaluateFormLiteralEvaluation .cke_contents");
            // click("#evaluationAssignmentEvaluateContainer .evaluation-modal-evaluate-form #cke_assignmentEvaluateFormLiteralEvaluation .cke_contents");
            getWebDriver().switchTo().frame(findElementByCssSelector("#evaluationAssignmentEvaluateContainer .evaluation-modal-evaluate-form #cke_assignmentEvaluateFormLiteralEvaluation .cke_wysiwyg_frame"));
            sendKeys(".cke_contents_ltr", "Test evaluation.");
            getWebDriver().switchTo().defaultContent();
            selectOption("#workspaceGrade", "PYRAMUS-1@PYRAMUS-1");
            waitAndClick("#assignmentSaveButton");
            waitForPresent(".notification-queue-item-success");
            waitForPresentAndVisible(".assignment-wrapper .assignment-evaluated-label");
            waitForPresentAndVisible(".assignment-wrapper .assignment-grade .assignment-grade-data");
            assertTextIgnoreCase(".assignment-wrapper .assignment-grade .assignment-grade-data", "Excellent");
            logout();
            mockBuilder.mockLogin(student).build();
            login();
            navigate(String.format("/workspace/%s/materials", workspace.getUrlName()), true);
            waitForPresent(String.format("#page-%d", htmlMaterial.getId()));
            waitAndClick(".muikku-show-evaluation-button");
            waitForPresentAndVisible(".evaluation-container .assignment-literal-container .assignment-literal-data");
            assertText(".evaluation-container .assignment-literal-container .assignment-literal-data p", "Test evaluation.");
            assertText(".evaluation-container .assignment-grade-container span.assignment-grade-data", "Excellent");
        } finally {
            deleteWorkspaceHtmlMaterial(workspace.getId(), htmlMaterial.getId());
            deleteWorkspace(workspace.getId());
        }
    } finally {
        mockBuilder.wiremockReset();
    }
}
Also used : WorkspaceHtmlMaterial(fi.otavanopisto.muikku.atests.WorkspaceHtmlMaterial) OffsetDateTime(java.time.OffsetDateTime) 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) MockCourse(fi.otavanopisto.muikku.mock.model.MockCourse) 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