use of teammates.test.pageobjects.InstructorCourseDetailsPage in project teammates by TEAMMATES.
the class InstructorStudentListPageUiTest method testDeleteAction.
private void testDeleteAction() {
InstructorAttributes instructorWith2Courses = testData.instructors.get("instructorOfCourse2");
String instructorId = instructorWith2Courses.googleId;
AppUrl viewPageUrl = createUrl(Const.ActionURIs.INSTRUCTOR_STUDENT_LIST_PAGE).withUserId(instructorId);
______TS("action: delete");
viewPage = loginAdminToPage(viewPageUrl, InstructorStudentListPage.class);
viewPage.checkCourse(0);
viewPage.checkCourse(1);
ThreadHelper.waitFor(500);
String studentName = testData.students.get("Student2Course2").name;
String studentEmail = testData.students.get("Student2Course2").email;
String courseId = testData.courses.get("course2").getId();
viewPage.clickDeleteAndCancel(courseId, studentName);
assertNotNull(BackDoor.getStudent(courseId, studentEmail));
String expectedStatus = "The student has been removed from the course";
viewPage.clickDeleteAndConfirm(courseId, studentName);
InstructorCourseDetailsPage courseDetailsPage = viewPage.changePageType(InstructorCourseDetailsPage.class);
courseDetailsPage.waitForTextsForAllStatusMessagesToUserEquals(expectedStatus);
}
use of teammates.test.pageobjects.InstructorCourseDetailsPage in project teammates by TEAMMATES.
the class AdminHomePageUiTest method testCreateInstructorAction.
private void testCreateInstructorAction() throws Exception {
InstructorAttributes instructor = new InstructorAttributes();
instructor.name = "AHPUiT Instrúctör WithPlusInEmail";
instructor.email = "AHPUiT+++_.instr1!@gmail.tmt";
String institute = "TEAMMATES Test Institute 1";
String demoCourseId = "AHPUiT____.instr1_.gma-demo";
String instructorDetails = instructor.name + " | " + instructor.email + "\n" + instructor.name + " | " + instructor.email + " | " + institute;
______TS("action fail & success: add multiple instructors");
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteCourse(demoCourseId);
BackDoor.deleteInstructor(demoCourseId, instructor.email);
homePage.createInstructorByInstructorDetailsSingleLineForm(instructorDetails);
InstructorAttributes instructorInBackend = getInstructorWithRetry(demoCourseId, instructor.email);
assertEquals("Instructor Details must have 3 columns", homePage.getMessageFromResultTable(1));
String encryptedKey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
// use AppUrl from Config because the join link takes its base URL from build.properties
String expectedjoinUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(encryptedKey).withInstructorInstitution(institute).toAbsoluteString();
assertEquals("Instructor AHPUiT Instrúctör WithPlusInEmail has been successfully created " + Const.JOIN_LINK, homePage.getMessageFromResultTable(2));
assertEquals(expectedjoinUrl, homePage.getJoinLink(homePage.getMessageFromResultTable(2)));
assertEquals(instructor.getName(), instructorInBackend.getName());
assertEquals(instructor.getEmail(), instructorInBackend.getEmail());
homePage.clearInstructorDetailsSingleLineForm();
______TS("action success: displayed instructor details are properly HTML-encoded");
InstructorAttributes dangerousInstructor = new InstructorAttributes();
dangerousInstructor.name = "Malicious <script>alert('dangerous');</script>Instrúctör";
dangerousInstructor.email = "malicious.instr1<>!@gmail.tmt";
String dangerousInstitute = "TEAMMATES Malicious Institute <!@!@!>";
String dangerousDemoCourseId = "malicious.instr1___.gma-demo";
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteCourse(dangerousDemoCourseId);
BackDoor.deleteInstructor(dangerousDemoCourseId, dangerousInstructor.email);
homePage.createInstructor(dangerousInstructor, dangerousInstitute);
assertEquals(dangerousInstructor.name, homePage.getNameFromResultTable(1));
assertEquals(dangerousInstructor.email, homePage.getEmailFromResultTable(1));
assertEquals(dangerousInstitute, homePage.getInstitutionFromResultTable(1));
______TS("action success : create instructor account and the account is created successfully " + "after user's verification");
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteCourse(demoCourseId);
BackDoor.deleteInstructor(demoCourseId, instructor.email);
homePage.createInstructor(instructor, institute);
encryptedKey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
// use AppUrl from Config because the join link takes its base URL from build.properties
expectedjoinUrl = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(encryptedKey).withInstructorInstitution(institute).toAbsoluteString();
assertEquals("Instructor AHPUiT Instrúctör WithPlusInEmail has been successfully created " + Const.JOIN_LINK, homePage.getMessageFromResultTable(1));
assertEquals(expectedjoinUrl, homePage.getJoinLink(homePage.getMessageFromResultTable(1)));
homePage.logout();
// verify the instructor and the demo course have been created
assertNotNull(getCourseWithRetry(demoCourseId));
assertNotNull(getInstructorWithRetry(demoCourseId, instructor.email));
// get the joinURL which sent to the requester's email
String regkey = getKeyForInstructorWithRetry(demoCourseId, instructor.email);
String joinLink = createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(regkey).withInstructorInstitution(institute).toAbsoluteString();
// simulate the user's verification here because it is added by admin
browser.driver.get(joinLink);
InstructorCourseJoinConfirmationPage confirmationPage = AppPage.createCorrectLoginPageType(browser).loginAsJoiningInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
confirmationPage.clickCancelButton();
browser.driver.get(joinLink);
confirmationPage = AppPage.createCorrectLoginPageType(browser).loginAsJoiningInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
confirmationPage.clickConfirmButtonWithRetry();
// check a account has been created for the requester successfully
assertNotNull(getAccountWithRetry(TestProperties.TEST_INSTRUCTOR_ACCOUNT));
// verify sample course is accessible for newly joined instructor as an instructor
______TS("new instructor can see sample course in homepage");
InstructorHomePage instructorHomePage = AppPage.getNewPageInstance(browser, InstructorHomePage.class);
instructorHomePage.verifyHtmlMainContent("/newlyJoinedInstructorHomePage.html");
______TS("new instructor can access sample course details page");
InstructorCourseEnrollPage enrollPage = instructorHomePage.clickCourseEnrollLink(demoCourseId);
instructorHomePage = enrollPage.goToPreviousPage(InstructorHomePage.class);
InstructorCourseDetailsPage detailsPage = instructorHomePage.clickCourseViewLink(demoCourseId);
detailsPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseDetailsPage.html");
______TS("new instructor can access sample course edit page");
instructorHomePage = detailsPage.goToPreviousPage(InstructorHomePage.class);
InstructorCourseEditPage editPage = instructorHomePage.clickCourseEditLink(demoCourseId);
editPage.verifyHtmlMainContent("/newlyJoinedInstructorCourseEditPage.html");
______TS("new instructor can view feedback sessions of sample course");
AppUrl url = createUrl(Const.ActionURIs.INSTRUCTOR_COURSES_PAGE).withUserId(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
coursesPage = AppPage.getNewPageInstance(browser, url, InstructorCoursesPage.class);
coursesPage.waitForAjaxLoadCoursesSuccess();
verifyCanViewSessionResults(demoCourseId, "First team feedback session", "/newlyJoinedInstructorFirstFeedbackSessionResultsPage.html");
verifyCanViewSessionResults(demoCourseId, "Second team feedback session", "/newlyJoinedInstructorSecondFeedbackSessionResultsPage.html");
verifyCanViewSessionResults(demoCourseId, "Session with different question types", "/newlyJoinedInstructorThirdFeedbackSessionResultsPage.html");
______TS("action failure : trying to create instructor with an invalid email");
AppUrl homeUrl = createUrl(Const.ActionURIs.ADMIN_HOME_PAGE);
homePage = loginAdminToPage(homeUrl, AdminHomePage.class);
instructor.email = "AHPUiT.email.tmt";
homePage.createInstructor(instructor, institute);
assertEquals(getPopulatedErrorMessage(FieldValidator.EMAIL_ERROR_MESSAGE, instructor.email, FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.EMAIL_MAX_LENGTH), homePage.getMessageFromResultTable(1));
______TS("action success: course is accessible for newly joined instructor as student");
// in staging server, the student account uses the hardcoded email above, so this can only be test on dev server
if (!TestProperties.isDevServer()) {
BackDoor.deleteCourse(demoCourseId);
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteInstructor(demoCourseId, instructor.email);
return;
}
// verify sample course is accessible for newly joined instructor as an student
StudentHomePage studentHomePage = getHomePage().clickStudentLogin().loginAsStudent(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
studentHomePage.verifyContains(demoCourseId);
studentHomePage.clickViewTeam();
StudentCourseDetailsPage courseDetailsPage = AppPage.getNewPageInstance(browser, StudentCourseDetailsPage.class);
courseDetailsPage.verifyHtmlMainContent("/newlyJoinedInstructorStudentCourseDetailsPage.html");
studentHomePage = courseDetailsPage.goToPreviousPage(StudentHomePage.class);
studentHomePage.clickViewFeedbackButton("First team feedback session");
StudentFeedbackResultsPage sfrp = AppPage.getNewPageInstance(browser, StudentFeedbackResultsPage.class);
sfrp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackResultsPage.html");
studentHomePage = sfrp.goToPreviousPage(StudentHomePage.class);
studentHomePage.clickEditFeedbackButton("First team feedback session");
FeedbackSubmitPage fsp = AppPage.getNewPageInstance(browser, FeedbackSubmitPage.class);
fsp.verifyHtmlMainContent("/newlyJoinedInstructorStudentFeedbackSubmissionEdit.html");
studentHomePage = fsp.loadStudentHomeTab();
StudentProfilePage spp = studentHomePage.loadProfileTab();
spp.verifyContains("Student Profile");
spp.verifyContains("AHPUiT Instrúctör WithPlusInEmail");
studentHomePage.logout();
// login in as instructor again to test sample course deletion
instructorHomePage = getHomePage().clickInstructorLogin().loginAsInstructor(TestProperties.TEST_INSTRUCTOR_ACCOUNT, TestProperties.TEST_INSTRUCTOR_PASSWORD);
instructorHomePage.clickAndConfirm(instructorHomePage.getDeleteCourseLink(demoCourseId));
assertTrue(instructorHomePage.getTextsForAllStatusMessagesToUser().contains("The course " + demoCourseId + " has been deleted."));
instructorHomePage.logout();
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteCourse(demoCourseId);
BackDoor.deleteInstructor(demoCourseId, instructor.email);
BackDoor.deleteAccount(TestProperties.TEST_INSTRUCTOR_ACCOUNT);
BackDoor.deleteCourse(dangerousDemoCourseId);
BackDoor.deleteInstructor(dangerousDemoCourseId, dangerousInstructor.email);
}
use of teammates.test.pageobjects.InstructorCourseDetailsPage in project teammates by TEAMMATES.
the class InstructorHomePageUiTest method testCourseLinks.
private void testCourseLinks() {
String courseId = testData.courses.get("CHomeUiT.CS1101").getId();
String instructorId = testData.accounts.get("account").googleId;
______TS("link: course enroll");
InstructorCourseEnrollPage enrollPage = homePage.clickCourseEnrollLink(courseId);
enrollPage.verifyContains("Enroll Students for CHomeUiT.CS1101");
String expectedEnrollLinkText = createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_ENROLL_PAGE).withCourseId(courseId).withUserId(instructorId).toAbsoluteString();
assertEquals(expectedEnrollLinkText, browser.driver.getCurrentUrl());
homePage.goToPreviousPage(InstructorHomePage.class);
______TS("link: course view");
InstructorCourseDetailsPage detailsPage = homePage.clickCourseViewLink(courseId);
detailsPage.verifyContains("Course Details");
String expectedViewLinkText = createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE).withCourseId(courseId).withUserId(instructorId).toAbsoluteString();
assertEquals(expectedViewLinkText, browser.driver.getCurrentUrl());
homePage.goToPreviousPage(InstructorHomePage.class);
______TS("link: course edit");
InstructorCourseEditPage editPage = homePage.clickCourseEditLink(courseId);
editPage.verifyContains("Edit Course Details");
String expectedEditLinkText = createUrl(Const.ActionURIs.INSTRUCTOR_COURSE_EDIT_PAGE).withCourseId(courseId).withUserId(instructorId).toAbsoluteString();
assertEquals(expectedEditLinkText, browser.driver.getCurrentUrl());
homePage.goToPreviousPage(InstructorHomePage.class);
______TS("link: course add session");
InstructorFeedbackSessionsPage feedbacksPage = homePage.clickCourseAddEvaluationLink(courseId);
feedbacksPage.verifyContains("Add New Feedback Session");
String expectedAddSessionLinkText = createUrl(Const.ActionURIs.INSTRUCTOR_FEEDBACK_SESSIONS_PAGE).withUserId(instructorId).withCourseId(courseId).toAbsoluteString();
assertEquals(expectedAddSessionLinkText, browser.driver.getCurrentUrl());
homePage.goToPreviousPage(InstructorHomePage.class);
}
use of teammates.test.pageobjects.InstructorCourseDetailsPage in project teammates by TEAMMATES.
the class InstructorCourseEditPageUiTest method testAddInstructorAction.
private void testAddInstructorAction() throws Exception {
______TS("success: add an instructor with privileges");
courseEditPage.clickShowNewInstructorFormButton();
courseEditPage.fillNewInstructorName("Teammates Instructor");
courseEditPage.fillNewInstructorEmail("InsCrsEdit.instructor@gmail.tmt");
int newInstructorIndex = 8;
courseEditPage.selectRoleForInstructor(newInstructorIndex, "Custom");
courseEditPage.clickCourseLevelPrivilegesLink(newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_COURSE);
courseEditPage.clickCourseLevelPrivilegesLink(newInstructorIndex, InstructorCourseEditPage.COURSE_MODIFY_STUDENTS);
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.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.COURSE_INSTRUCTOR_ADDED, "Teammates Instructor", "InsCrsEdit.instructor@gmail.tmt"));
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", "InsCrsEdit.instructor@gmail.tmt");
courseEditPage.waitForTextsForAllStatusMessagesToUserEquals(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.waitForTextsForAllStatusMessagesToUserEquals(new FieldValidator().getInvalidityInfoForEmail(invalidEmail));
String invalidName = "";
courseEditPage.addNewInstructor(invalidName, "teammates@email.tmt");
courseEditPage.waitForTextsForAllStatusMessagesToUserEquals(new FieldValidator().getInvalidityInfoForPersonName(invalidName));
}
use of teammates.test.pageobjects.InstructorCourseDetailsPage in project teammates by TEAMMATES.
the class InstructorCourseStudentDetailsEditPageUiTest method testEditAction.
private void testEditAction() {
______TS("Error case, invalid email parameter (email already taken by others)");
StudentAttributes anotherStudent = testData.students.get("unregisteredStudent");
editPage = editPage.submitUnsuccessfully("New name2", "New team2", anotherStudent.email, "New comments2");
editPage.waitForTextsForAllStatusMessagesToUserEquals(String.format(Const.StatusMessages.STUDENT_EMAIL_TAKEN_MESSAGE, anotherStudent.name, anotherStudent.email));
editPage.verifyIsCorrectPage("CCSDEditUiT.jose.tmms@gmail.tmt");
// Verify data
StudentAttributes student = BackDoor.getStudent(testData.courses.get("CCSDEditUiT.CS2104").getId(), "CCSDEditUiT.jose.tmms@gmail.tmt");
assertEquals("José Gómez</option></td></div>'\"", student.name);
assertEquals("Team 1</td></div>'\"", student.team);
assertEquals(testData.students.get("registeredStudent").googleId, student.googleId);
assertEquals("CCSDEditUiT.jose.tmms@gmail.tmt", student.email);
assertEquals("This student's name is José Gómez</option></td></div>'\"", student.comments);
______TS("edit action");
InstructorCourseDetailsPage detailsPage = editPage.submitSuccessfully("New name", "New team", "newemail@gmail.tmt", "New comments");
detailsPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.STUDENT_EDITED);
detailsPage.verifyIsCorrectPage(testData.courses.get("CCSDEditUiT.CS2104").getId());
// Verify data
student = BackDoor.getStudent(testData.courses.get("CCSDEditUiT.CS2104").getId(), "newemail@gmail.tmt");
assertEquals("New name", student.name);
assertEquals("New team", student.team);
assertEquals("newemail@gmail.tmt", student.email);
assertEquals("New comments", student.comments);
// Due to Google ID reset
assertTrue(student.googleId.isEmpty());
// Verify adding the original student again does not overwrite the edited entity
BackDoor.createStudent(testData.students.get("registeredStudent"));
student = BackDoor.getStudent(testData.courses.get("CCSDEditUiT.CS2104").getId(), "newemail@gmail.tmt");
assertNotNull(student);
}
Aggregations