コード例 #1
0
  /** Tests the UI of edit course. */
  private void testEditCourseAction() throws Exception {
    courseEditPage = getCourseEditPage();

    ______TS("edit course valid name");

    assertFalse(courseEditPage.isCourseEditFormEnabled());
    courseEditPage.clickEditCourseLink();
    assertTrue(courseEditPage.isCourseEditFormEnabled());

    courseEditPage.clickSaveCourseButton();
    courseEditPage.changePageType(InstructorCourseEditPage.class);
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_EDITED);

    ______TS("edit course invalid name");
    assertFalse(courseEditPage.isCourseEditFormEnabled());
    courseEditPage.clickEditCourseLink();
    assertTrue(courseEditPage.isCourseEditFormEnabled());
    courseEditPage.editCourseName("");
    courseEditPage.clickSaveCourseButton();
    courseEditPage.changePageType(InstructorCourseEditPage.class);
    courseEditPage.verifyStatus(
        getPopulatedErrorMessage(
            FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE,
            "",
            FieldValidator.COURSE_NAME_FIELD_NAME,
            FieldValidator.REASON_EMPTY,
            FieldValidator.COURSE_NAME_MAX_LENGTH));
  }
コード例 #2
0
  private void testDeleteInstructorAction() {
    courseEditPage = getCourseEditPage();

    ______TS("delete instructor then cancel");
    courseEditPage.clickDeleteInstructorLinkAndCancel();
    assertNotNull(BackDoor.getInstructorAsJsonByGoogleId(instructorId, courseId));

    ______TS("delete instructor successfully");
    courseEditPage.clickDeleteInstructorLinkAndConfirm();
    courseEditPage.verifyHtml("/instructorCourseEditDeleteInstructorSuccessful.html");

    ______TS("failed to delete the last instructor");
    courseEditPage.clickDeleteInstructorLinkAndConfirm();
    courseEditPage.clickDeleteInstructorLinkAndConfirm();
    courseEditPage.clickDeleteInstructorLinkAndConfirm();
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_DELETE_NOT_ALLOWED);

    ______TS("deleted own instructor role and redirect to courses page");
    // Change login id to another instructor
    BackDoor.createInstructor(testData.instructors.get("InsCrsEdit.coord"));
    instructorId = testData.instructors.get("InsCrsEdit.coord").googleId;

    courseEditPage = getCourseEditPage();
    courseEditPage.clickDeleteInstructorLinkAndConfirm();

    InstructorCoursesPage coursesPage = courseEditPage.changePageType(InstructorCoursesPage.class);
    coursesPage.verifyStatus(
        Const.StatusMessages.COURSE_INSTRUCTOR_DELETED + "\n" + Const.StatusMessages.COURSE_EMPTY);

    // Change back login id to original instructor to ensure remaining test cases work properly
    instructorId = testData.instructors.get("InsCrsEdit.test").googleId;
  }
コード例 #3
0
  private void testDeleteInstructorAction() {

    ______TS("delete instructor then cancel");

    courseEditPage.clickDeleteInstructorLinkAndCancel(1);
    assertNotNull(BackDoor.getInstructorByGoogleId(instructorId, courseId));

    ______TS("delete instructor successfully");

    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    String expectedMsg = "The instructor has been deleted from the course.";
    courseEditPage.verifyStatus(expectedMsg);

    ______TS("delete all other instructors");

    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(2);

    ______TS(
        "test the only registered instructor with the privilege to modify instructors cannot be deleted");

    // Create an registered instructor with all privileges except modifying instructors
    InstructorPrivileges privilege =
        new InstructorPrivileges(
            Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);
    privilege.updatePrivilege(Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_INSTRUCTOR, false);
    InstructorAttributes instructor =
        new InstructorAttributes(
            "InsCrsEdit.reg",
            courseId,
            "Teammates Reg",
            "*****@*****.**",
            Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_CUSTOM,
            "Teammates Reg",
            privilege);
    BackDoor.createInstructor(instructor);

    // Create an unregistered instructor with co-owner privilege
    courseEditPage.addNewInstructor("Unreg Instructor", "*****@*****.**");

    // Delete own instructor role
    courseEditPage.clickDeleteInstructorLinkAndConfirm(2);
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_DELETE_NOT_ALLOWED);

    // Delete other instructors
    courseEditPage.clickDeleteInstructorLinkAndConfirm(3);
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_DELETED);
    courseEditPage.clickDeleteInstructorLinkAndConfirm(1);
    courseEditPage.verifyStatus(Const.StatusMessages.COURSE_INSTRUCTOR_DELETED);

    ______TS("delete own instructor role and redirect to courses page");

    // Create another registered instructor with co-owner privilege
    BackDoor.createInstructor(testData.instructors.get("InsCrsEdit.coord"));
    courseEditPage = getCourseEditPage();

    // Delete own instructor role
    courseEditPage.clickDeleteInstructorLinkAndConfirm(2);

    InstructorCoursesPage coursesPage = courseEditPage.changePageType(InstructorCoursesPage.class);
    coursesPage.waitForAjaxLoadCoursesSuccess();
    coursesPage.verifyStatus(
        Const.StatusMessages.COURSE_INSTRUCTOR_DELETED + "\n" + Const.StatusMessages.COURSE_EMPTY);

    // Restore own instructor role to ensure remaining test cases work properly
    BackDoor.createInstructor(testData.instructors.get("InsCrsEdit.test"));
  }