use of teammates.test.pageobjects.StudentFeedbackResultsPage 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.StudentFeedbackResultsPage in project teammates by TEAMMATES.
the class FeedbackRankQuestionUiTest method testStudentSubmitAndResultsPages.
@Test
public void testStudentSubmitAndResultsPages() throws Exception {
______TS("Rank submission: input disabled for closed session");
FeedbackSubmitPage submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRankUiT.CS4221", "closed");
submitPage.waitForAndDismissAlertModal();
assertTrue(submitPage.isElementVisible(Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0-0"));
assertFalse(submitPage.isElementEnabled(Const.ParamsNames.FEEDBACK_RESPONSE_TEXT + "-1-0-0"));
______TS("Rank submission");
submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRankUiT.CS4221", "student");
// verifies that question submit form without existing responses loads correctly
submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPageRank.html");
submitPage.selectResponseTextDropdown(1, 0, 0, "1");
submitPage.selectResponseTextDropdown(1, 0, 1, "2");
// to check if deleting responses work
submitPage.selectResponseTextDropdown(1, 1, 1, "");
assertEquals("Please rank the above options.", submitPage.getRankMessage(1, 1));
submitPage.selectResponseTextDropdown(2, 0, 0, "1");
submitPage.selectResponseTextDropdown(2, 1, 0, "2");
// test rank messages
assertEquals("Please rank the above recipients.", submitPage.getRankMessage(5, 3));
submitPage.selectResponseTextDropdown(5, 0, 0, "2");
assertTrue(submitPage.getRankMessage(5, 0).isEmpty());
submitPage.selectResponseTextDropdown(5, 1, 0, "2");
assertEquals("The same rank should not be given multiple times.", submitPage.getRankMessage(5, 3));
// try to submit with error
submitPage.clickSubmitButton();
submitPage.waitForTextsForAllStatusMessagesToUserEquals("Please fix the error(s) for rank question(s) 5. " + "To skip a rank question, leave all the boxes blank.");
submitPage.selectResponseTextDropdown(5, 1, 0, "1");
assertEquals("Please rank the above recipients.", submitPage.getRankMessage(5, 3));
// Submit
submitPage.clickSubmitButton();
submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
FeedbackQuestionAttributes fq1 = BackDoor.getFeedbackQuestion("FRankUiT.CS4221", "Student Session", 1);
assertNotNull(BackDoor.getFeedbackResponse(fq1.getId(), "alice.b.tmms@gmail.tmt", "tmms.helper1@gmail.tmt"));
assertNull(BackDoor.getFeedbackResponse(fq1.getId(), "alice.b.tmms@gmail.tmt", "tmms.test@gmail.tmt"));
FeedbackQuestionAttributes fq2 = BackDoor.getFeedbackQuestion("FRankUiT.CS4221", "Student Session", 2);
assertNotNull(BackDoor.getFeedbackResponse(fq2.getId(), "alice.b.tmms@gmail.tmt", "tmms.helper1@gmail.tmt"));
assertNotNull(BackDoor.getFeedbackResponse(fq2.getId(), "alice.b.tmms@gmail.tmt", "tmms.test@gmail.tmt"));
// Go back to submission page and verify html
submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRankUiT.CS4221", "student");
// try to submit duplicate ranks for question that permits it
submitPage.selectResponseTextDropdown(6, 0, 0, "1");
submitPage.selectResponseTextDropdown(6, 1, 0, "1");
assertTrue("No error message expected", submitPage.getRankMessage(6, 0).isEmpty());
submitPage.selectResponseTextDropdown(1, 0, 0, "3");
assertEquals("The display message indicating this is a rank question is displayed until all options are ranked", "Please rank the above options.", submitPage.getRankMessage(1, 0));
submitPage.selectResponseTextDropdown(1, 0, 1, "3");
submitPage.selectResponseTextDropdown(1, 0, 2, "1");
submitPage.selectResponseTextDropdown(1, 0, 3, "4");
assertTrue("No error message expected", submitPage.getRankMessage(1, 0).isEmpty());
submitPage.selectResponseTextDropdown(7, 0, 0, "4");
submitPage.selectResponseTextDropdown(7, 0, 1, "3");
submitPage.selectResponseTextDropdown(7, 0, 2, "2");
submitPage.selectResponseTextDropdown(7, 0, 3, "1");
assertTrue("No error message expected", submitPage.getRankMessage(7, 0).isEmpty());
submitPage.clickSubmitButton();
// Go back to submission page
submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRankUiT.CS4221", "student");
// to verify that the question submit form with existing response works correctly
submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPageSuccessRank.html");
______TS("Rank : min/max options to be ranked test");
// Question with only min options to be ranked restriction
int qnNumber = 9;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertEquals("You need to rank at least 2 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 2, "2");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 0, 2, "");
assertEquals("You need to rank at least 2 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 3, "3");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
// Question with only max options to be ranked restriction
qnNumber = 10;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 0, 2, "2");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 0, 3, "3");
assertEquals("Rank no more than 2 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 3, "");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
// Question with both min and max options to be ranked restriction
qnNumber = 11;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertEquals("You need to rank at least 3 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 2, "2");
assertEquals("You need to rank at least 3 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 4, "4");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 0, 1, "3");
assertEquals("Rank no more than 3 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 3, "5");
assertEquals("Rank no more than 3 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 3, "");
assertEquals("Rank no more than 3 options.", submitPage.getRankMessage(qnNumber, 0));
submitPage.selectResponseTextDropdown(qnNumber, 0, 1, "");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 0).isEmpty());
______TS("Rank : min/max recipients to be ranked test");
// Question with only min recipients to be ranked restriction
qnNumber = 12;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertEquals("You need to rank at least 2 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 2, 0, "2");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 2, 0, "");
assertEquals("You need to rank at least 2 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 3, 0, "3");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
// Question with only max recipients to be ranked restriction
qnNumber = 13;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 2, 0, "2");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 3, 0, "3");
assertEquals("Rank no more than 2 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 3, 0, "");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
// Question with both min and max options to be ranked restriction
qnNumber = 14;
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "1");
assertEquals("You need to rank at least 3 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 1, 0, "2");
assertEquals("You need to rank at least 3 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 2, 0, "3");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
submitPage.selectResponseTextDropdown(qnNumber, 3, 0, "4");
assertEquals("Rank no more than 3 recipients.", submitPage.getRankMessage(qnNumber, 3));
submitPage.selectResponseTextDropdown(qnNumber, 0, 0, "");
assertTrue("No error message expected", submitPage.getRankMessage(qnNumber, 3).isEmpty());
______TS("Rank : student results");
StudentFeedbackResultsPage studentResultsPage = loginToStudentFeedbackResultsPage("alice.tmms@FRankUiT.CS4221", "student");
studentResultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageRank.html");
}
use of teammates.test.pageobjects.StudentFeedbackResultsPage in project teammates by TEAMMATES.
the class FeedbackRubricQuestionUiTest method testStudentResultsPage.
private void testStudentResultsPage() throws Exception {
______TS("test rubric question simple student results page");
StudentFeedbackResultsPage simpleResultsPage = loginToStudentFeedbackResultsPage("alice.tmms@FRubricQnUiT.CS2104", "openSession2");
simpleResultsPage.verifyHtmlMainContent("/studentFeedbackResultsPageRubric.html");
______TS("test rubric question extended student results page");
StudentFeedbackResultsPage extendedResultsPage = loginToStudentFeedbackResultsPage("alice.tmms@FRubricQnUiT.CS2104", "openSession4");
extendedResultsPage.verifyHtmlMainContent("/studentExtendedFeedbackResultsPageRubric.html");
}
Aggregations