コード例 #1
0
  private void testEditInstructorAction() throws Exception {

    ______TS("failure: ajax error on clicking edit button");
    int editInstructorIndex = 1;

    courseEditPage.changeCourseIdInForm(editInstructorIndex, "InvalidCourse");
    courseEditPage.clickEditInstructorLinkUnsuccessfully(editInstructorIndex);
    courseEditPage.waitForAjaxLoaderGifToDisappear();
    assertTrue(
        courseEditPage
            .getEditInstructorLink(editInstructorIndex)
            .getText()
            .contains("Edit failed."));
    courseEditPage.reloadPage();

    ______TS("success: edit an instructor");

    courseEditPage.editInstructor(
        editInstructorIndex,
        "New name",
        "*****@*****.**",
        Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);
    courseEditPage.verifyStatus(
        String.format(Const.StatusMessages.COURSE_INSTRUCTOR_EDITED, "New name"));

    ______TS(
        "success: edit an instructor (InsCrsEdit.coord)--viewing instructor permission details");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    assertTrue(courseEditPage.isInstructorEditable(editInstructorIndex));

    ______TS("view details: manager");

    courseEditPage.clickViewDetailsLinkForInstructor(
        editInstructorIndex, InstructorCourseEditPage.INSTRUCTOR_TYPE_MANAGER);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));
    courseEditPage.closeModal();

    ______TS("view details: observer");

    courseEditPage.clickViewDetailsLinkForInstructor(
        editInstructorIndex, InstructorCourseEditPage.INSTRUCTOR_TYPE_OBSERVER);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));
    courseEditPage.closeModal();

    ______TS("view details: tutor");

    courseEditPage.clickViewDetailsLinkForInstructor(
        editInstructorIndex, InstructorCourseEditPage.INSTRUCTOR_TYPE_TUTOR);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInModalChecked(
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));
    courseEditPage.closeModal();

    ______TS("view details: co-owner");

    courseEditPage.clickViewDetailsLinkForInstructor(
        editInstructorIndex, InstructorCourseEditPage.INSTRUCTOR_TYPE_COOWNER);
    courseEditPage.verifyHtmlMainContent("/instructorCourseEditEditInstructorPrivilegesModal.html");
    courseEditPage.closeModal();

    ______TS("verify that custom has no privileges by default");

    int customInstrNum = 5;
    courseEditPage.clickEditInstructorLink(customInstrNum);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifycourse"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifyinstructor"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifysession"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifystudent"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canviewstudentinsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "cangivecommentinsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canviewcommentinsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifycommentinsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "cansubmitsessioninsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canviewsessioninsection"));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            customInstrNum, "canmodifysessioncommentinsection"));
    courseEditPage.clickSaveInstructorButton(customInstrNum);

    ______TS("success: edit an instructor with privileges");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    assertTrue(courseEditPage.getDisplayedToStudentCheckBox(editInstructorIndex).isSelected());
    // not displayed to students
    courseEditPage.clickDisplayedToStudentCheckBox(editInstructorIndex);
    // select the role as Custom for instr1
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");

    // deselect some privileges from Co-owner default values
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_COURSE);
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_INSTRUCTORS);
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_OTHERS_COMMENTS);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 0, 0);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 0, 1);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_OTHERS_COMMENTS);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION);
    courseEditPage.clickSessionLevelInSectionLevel(editInstructorIndex, 0);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 1, 1);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 2, 1);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 2, 2);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 2, InstructorCourseEditPage.SECTION_MODIFY_RESPONSES_IN_SESSION);
    // after 3 sections added, no more things to add
    assertFalse(courseEditPage.getAddSectionLevelPrivilegesLink(editInstructorIndex).isDisplayed());
    courseEditPage.verifyHtmlMainContent(
        "/instructorCourseEditEditInstructorPrivilegesBeforeSubmit.html");

    courseEditPage.clickSaveInstructorButton(editInstructorIndex);
    courseEditPage.verifyHtmlMainContent(
        "/instructorCourseEditEditInstructorPrivilegesSuccessful.html");
    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    assertTrue(courseEditPage.isInstructorEditable(editInstructorIndex));
    courseEditPage.verifyHtmlMainContent(
        "/instructorCourseEditEditInstructorPrivilegesSuccessfulAndCheckEditAgain.html");
    courseEditPage.clickSaveInstructorButton(editInstructorIndex);

    ______TS("failure: edit failed due to invalid parameters");
    String invalidEmail = "InsCrsEdit.email.tmt";

    courseEditPage.editInstructor(
        editInstructorIndex,
        "New name",
        invalidEmail,
        Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForEmail(invalidEmail));

    String invalidName = "";

    courseEditPage.editInstructor(
        editInstructorIndex,
        invalidName,
        "*****@*****.**",
        Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForPersonName(invalidName));

    ______TS(
        "success: test Custom radio button getting other privileges' default values when selected");
    editInstructorIndex = 2;
    courseEditPage.clickEditInstructorLink(editInstructorIndex);

    ______TS("tutor->custom");

    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Tutor");
    courseEditPage.clickSaveInstructorButton(editInstructorIndex);
    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    ______TS("observer->custom");

    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Observer");
    courseEditPage.clickSaveInstructorButton(editInstructorIndex);
    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    ______TS("manager->custom");

    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Manager");
    courseEditPage.clickSaveInstructorButton(editInstructorIndex);
    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    ______TS("co-owner->custom");

    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Co-owner");
    courseEditPage.clickSaveInstructorButton(editInstructorIndex);
    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COURSE));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_SUBMIT_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    ______TS("verify that session level checkboxes are accessible");

    int sectionToCheck = 0;

    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSessionLevelInSectionLevel(editInstructorIndex, sectionToCheck);
    assertTrue(
        courseEditPage.isTuneSessionPermissionsDivVisible(editInstructorIndex, sectionToCheck));

    ______TS("verify checkbox toggling to false");

    int sessionToCheck = 0;

    // course level
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_VIEW_STUDENTS);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));

    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_VIEW_OTHERS_COMMENTS);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));

    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_VIEW_RESPONSES_IN_SESSION);
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertFalse(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    // section level
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, sectionToCheck, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex, sectionToCheck, InstructorCourseEditPage.SECTION_VIEW_STUDENTS));
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_GIVE_STUDENT_COMMENTS));

    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, sectionToCheck, InstructorCourseEditPage.SECTION_VIEW_OTHERS_COMMENTS);
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_VIEW_OTHERS_COMMENTS));
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_MODIFY_OTHERS_COMMENTS));

    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION);
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION));
    assertFalse(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_MODIFY_RESPONSES_IN_SESSION));

    // session level
    courseEditPage.clickSessionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        sessionToCheck,
        InstructorCourseEditPage.SESSION_VIEW_RESPONSES);
    assertFalse(
        courseEditPage.isSessionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            sessionToCheck,
            InstructorCourseEditPage.SESSION_VIEW_RESPONSES));
    assertFalse(
        courseEditPage.isSessionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            sessionToCheck,
            InstructorCourseEditPage.SESSION_MODIFY_RESPONSES));

    ______TS("verify checkbox toggling to true");

    // course level
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_GIVE_STUDENT_COMMENTS);
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_STUDENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_GIVE_COMMENT_IN_SECTIONS));

    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_OTHERS_COMMENTS);
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_COMMENT_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_COMMENT_IN_SECTIONS));

    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_RESPONSES_IN_SESSION);
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex, Const.ParamsNames.INSTRUCTOR_PERMISSION_VIEW_SESSION_IN_SECTIONS));
    assertTrue(
        courseEditPage.isPrivilegeCheckboxInPermissionDivChecked(
            editInstructorIndex,
            Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION_COMMENT_IN_SECTIONS));

    // section level
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        InstructorCourseEditPage.SECTION_GIVE_STUDENT_COMMENTS);
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex, sectionToCheck, InstructorCourseEditPage.SECTION_VIEW_STUDENTS));
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_GIVE_STUDENT_COMMENTS));

    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        InstructorCourseEditPage.SECTION_MODIFY_OTHERS_COMMENTS);
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_VIEW_OTHERS_COMMENTS));
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_MODIFY_OTHERS_COMMENTS));

    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        InstructorCourseEditPage.SECTION_MODIFY_RESPONSES_IN_SESSION);
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION));
    assertTrue(
        courseEditPage.isSectionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            InstructorCourseEditPage.SECTION_MODIFY_RESPONSES_IN_SESSION));

    // session level
    courseEditPage.clickSessionLevelPrivilegeLink(
        editInstructorIndex,
        sectionToCheck,
        sessionToCheck,
        InstructorCourseEditPage.SESSION_MODIFY_RESPONSES);
    assertTrue(
        courseEditPage.isSessionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            sessionToCheck,
            InstructorCourseEditPage.SESSION_VIEW_RESPONSES));
    assertTrue(
        courseEditPage.isSessionLevelPrivilegeLinkClicked(
            editInstructorIndex,
            sectionToCheck,
            sessionToCheck,
            InstructorCourseEditPage.SESSION_MODIFY_RESPONSES));

    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Co-owner");
  }
コード例 #2
0
  private void testCancelEditInstructorAction() throws Exception {

    ______TS("success: cancel editing an instructor role from Co-owner to Manager");

    int editInstructorIndex = 7;

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Manager");
    courseEditPage.clickCancelEditInstructorLink(editInstructorIndex);
    assertFalse(courseEditPage.isRoleSelectedForInstructor(editInstructorIndex, "Manager"));
    assertTrue(courseEditPage.isRoleSelectedForInstructor(editInstructorIndex, "Co-owner"));

    ______TS("success: cancel editing an instructor role from Co-owner to Custom");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Custom");
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_INSTRUCTORS);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 0, 0);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickSessionLevelInSectionLevel(editInstructorIndex, 0);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 1, 1);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 1, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickAddSectionLevelPrivilegesLink(editInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 2, 2);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 2, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickCancelEditInstructorLink(editInstructorIndex);

    courseEditPage.verifyHtmlPart(
        By.id("formEditInstructor" + editInstructorIndex),
        "/instructorCourseEditCancelEditCoownerForm.html");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    assertFalse(courseEditPage.isTunePermissionsDivVisible(editInstructorIndex));

    ______TS("success: cancel editing an instructor role from Custom to Co-owner");

    editInstructorIndex = 1;

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.selectRoleForInstructor(editInstructorIndex, "Co-owner");
    courseEditPage.clickCancelEditInstructorLink(editInstructorIndex);

    courseEditPage.verifyHtmlPart(
        By.id("formEditInstructor" + editInstructorIndex),
        "/instructorCourseEditCancelEditCustomInstructorForm.html");

    ______TS("success: cancel editing a Custom instructor's permissions");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    courseEditPage.clickCourseLevelPrivilegesLink(
        editInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_INSTRUCTORS);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 0, 0);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickSectionSelectionCheckBox(editInstructorIndex, 1, 1);
    courseEditPage.clickSectionLevelPrivilegeLink(
        editInstructorIndex, 1, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickHideSectionLevelPrivileges(editInstructorIndex, 2);
    courseEditPage.clickCancelEditInstructorLink(editInstructorIndex);

    courseEditPage.verifyHtmlPart(
        By.id("formEditInstructor" + editInstructorIndex),
        "/instructorCourseEditCancelEditCustomInstructorPermissionsForm.html");

    courseEditPage.clickEditInstructorLink(editInstructorIndex);
    assertTrue(courseEditPage.isTunePermissionsDivVisible(editInstructorIndex));
  }
コード例 #3
0
  private void testAddInstructorAction() throws Exception {

    ______TS("success: add an instructor with privileges");

    courseEditPage.clickShowNewInstructorFormButton();
    courseEditPage.fillNewInstructorName("Teammates Instructor");
    courseEditPage.fillNewInstructorEmail("*****@*****.**");

    int newInstructorIndex = 8;

    courseEditPage.selectRoleForInstructor(newInstructorIndex, "Custom");
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_COURSE);
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_STUDENTS);
    courseEditPage.clickCourseLevelPrivilegesLink(
        newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_OTHERS_COMMENTS);

    courseEditPage.clickAddSectionLevelPrivilegesLink(newInstructorIndex);
    courseEditPage.clickSectionSelectionCheckBox(newInstructorIndex, 0, 1);
    courseEditPage.clickSectionLevelPrivilegeLink(
        newInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_STUDENTS);
    courseEditPage.clickSectionLevelPrivilegeLink(
        newInstructorIndex, 0, InstructorCourseEditPage.SECTION_VIEW_RESPONSES_IN_SESSION);

    courseEditPage.clickAddInstructorButton();

    courseEditPage.verifyStatus(
        String.format(
            Const.StatusMessages.COURSE_INSTRUCTOR_ADDED,
            "Teammates Instructor",
            "*****@*****.**"));

    AppUrl courseDetailsLink =
        createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE)
            .withCourseId(courseId)
            .withUserId(testData.instructors.get("InsCrsEdit.test").googleId);

    InstructorCourseDetailsPage courseDetailsPage =
        AppPage.getNewPageInstance(browser, courseDetailsLink, InstructorCourseDetailsPage.class);
    courseDetailsPage.verifyHtmlPart(
        By.id("instructors"), "/instructorCourseDetailsAddInstructor.html");
    courseEditPage = getCourseEditPage();
    courseEditPage.clickEditInstructorLink(3);
    courseEditPage.verifyHtmlMainContent("/instructorCourseEditAddInstructor.html");

    ______TS("failure: add an existing instructor");

    courseEditPage.addNewInstructor("Teammates Instructor", "*****@*****.**");
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_EXISTS);

    ______TS("failure: add an instructor with an invalid parameter");

    String invalidEmail = "InsCrsEdit.email.tmt";

    courseEditPage.addNewInstructor("Teammates Instructor", invalidEmail);
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForEmail(invalidEmail));

    String invalidName = "";

    courseEditPage.addNewInstructor(invalidName, "*****@*****.**");
    courseEditPage.verifyStatus(new FieldValidator().getInvalidityInfoForPersonName(invalidName));
  }