Search in sources :

Example 1 with FeedbackSubmitPage

use of teammates.test.pageobjects.FeedbackSubmitPage 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);
}
Also used : StudentFeedbackResultsPage(teammates.test.pageobjects.StudentFeedbackResultsPage) InstructorCourseEnrollPage(teammates.test.pageobjects.InstructorCourseEnrollPage) AppUrl(teammates.common.util.AppUrl) InstructorCoursesPage(teammates.test.pageobjects.InstructorCoursesPage) FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage) StudentCourseDetailsPage(teammates.test.pageobjects.StudentCourseDetailsPage) StudentProfilePage(teammates.test.pageobjects.StudentProfilePage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorCourseEditPage(teammates.test.pageobjects.InstructorCourseEditPage) AdminHomePage(teammates.test.pageobjects.AdminHomePage) InstructorCourseDetailsPage(teammates.test.pageobjects.InstructorCourseDetailsPage) InstructorHomePage(teammates.test.pageobjects.InstructorHomePage) StudentHomePage(teammates.test.pageobjects.StudentHomePage) InstructorCourseJoinConfirmationPage(teammates.test.pageobjects.InstructorCourseJoinConfirmationPage)

Example 2 with FeedbackSubmitPage

use of teammates.test.pageobjects.FeedbackSubmitPage in project teammates by TEAMMATES.

the class FeedbackRubricQuestionUiTest method testInstructorSubmitPage.

private void testInstructorSubmitPage() {
    ______TS("test rubric question input disabled for closed session");
    FeedbackSubmitPage submitPage = loginToInstructorFeedbackSubmitPage("teammates.test.instructor", "closedSession");
    int qnNumber = 1;
    int responseNumber = 0;
    int rowNumber = 0;
    assertFalse(submitPage.isNamedElementEnabled(Const.ParamsNames.FEEDBACK_QUESTION_RUBRIC_CHOICE + "-" + qnNumber + "-" + responseNumber + "-" + rowNumber));
    ______TS("test rubric question submission");
// Done in testStudentSubmitPage
}
Also used : FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage)

Example 3 with FeedbackSubmitPage

use of teammates.test.pageobjects.FeedbackSubmitPage in project teammates by TEAMMATES.

the class InstructorFeedbackEditPageUiTest method testPreviewSessionAction.

private void testPreviewSessionAction() throws Exception {
    // add questions for previewing
    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("TEXT");
    assertTrue(feedbackEditPage.verifyNewEssayQuestionFormIsDisplayed());
    feedbackEditPage.fillQuestionTextBoxForNewQuestion("question for me");
    feedbackEditPage.fillQuestionDescriptionForNewQuestion("more details");
    feedbackEditPage.enableOtherFeedbackPathOptionsForNewQuestion();
    feedbackEditPage.selectRecipientsToBeStudents();
    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("TEXT");
    assertTrue(feedbackEditPage.verifyNewEssayQuestionFormIsDisplayed());
    feedbackEditPage.fillQuestionTextBoxForNewQuestion("question for students");
    feedbackEditPage.fillQuestionDescriptionForNewQuestion("more details");
    feedbackEditPage.enableOtherFeedbackPathOptionsForNewQuestion();
    feedbackEditPage.selectGiverToBeStudents();
    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("TEXT");
    assertTrue(feedbackEditPage.verifyNewEssayQuestionFormIsDisplayed());
    feedbackEditPage.fillQuestionTextBoxForNewQuestion("question for instructors");
    feedbackEditPage.fillQuestionDescriptionForNewQuestion("more details");
    feedbackEditPage.enableOtherFeedbackPathOptionsForNewQuestion();
    feedbackEditPage.selectGiverToBeInstructors();
    feedbackEditPage.clickAddQuestionButton();
    feedbackEditPage.clickNewQuestionButton();
    feedbackEditPage.selectNewQuestionType("TEXT");
    assertTrue(feedbackEditPage.verifyNewEssayQuestionFormIsDisplayed());
    feedbackEditPage.fillQuestionTextBoxForNewQuestion("question for students to instructors");
    feedbackEditPage.fillQuestionDescriptionForNewQuestion("more details");
    feedbackEditPage.enableOtherFeedbackPathOptionsForNewQuestion();
    feedbackEditPage.selectGiverToBeStudents();
    feedbackEditPage.selectRecipientsToBeInstructors();
    feedbackEditPage.clickAddQuestionButton();
    ______TS("preview as instructor");
    feedbackEditPage.waitForElementPresence(By.id("button_preview_instructor"));
    FeedbackSubmitPage previewPage = feedbackEditPage.clickPreviewAsInstructorButton();
    previewPage.verifyHtmlMainContent("/instructorFeedbackSubmitPagePreview.html");
    previewPage.closeCurrentWindowAndSwitchToParentWindow();
    ______TS("preview as student");
    feedbackEditPage.waitForElementPresence(By.id("button_preview_student"));
    previewPage = feedbackEditPage.clickPreviewAsStudentButton();
    previewPage.verifyHtmlMainContent("/studentFeedbackSubmitPagePreview.html");
    previewPage.closeCurrentWindowAndSwitchToParentWindow();
}
Also used : FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage)

Example 4 with FeedbackSubmitPage

use of teammates.test.pageobjects.FeedbackSubmitPage in project teammates by TEAMMATES.

the class InstructorFeedbackSessionsPageUiTest method testSubmitLink.

private void testSubmitLink() {
    FeedbackSubmitPage feedbackResultsPage;
    FeedbackSessionAttributes fsa;
    ______TS("submit link clickable when visible");
    fsa = testData.feedbackSessions.get("awaitingSession");
    feedbackResultsPage = feedbackPage.loadSubmitLink(fsa.getCourseId(), fsa.getFeedbackSessionName());
    assertTrue(feedbackResultsPage.isCorrectPage(fsa.getCourseId(), fsa.getFeedbackSessionName()));
    feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);
    ______TS("submit link clickable when private (never visible)");
    fsa = testData.feedbackSessions.get("privateSession");
    feedbackResultsPage = feedbackPage.loadSubmitLink(fsa.getCourseId(), fsa.getFeedbackSessionName());
    assertTrue(feedbackResultsPage.isCorrectPage(fsa.getCourseId(), fsa.getFeedbackSessionName()));
    feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage)

Example 5 with FeedbackSubmitPage

use of teammates.test.pageobjects.FeedbackSubmitPage in project teammates by TEAMMATES.

the class FeedbackRubricQuestionUiTest method testStudentSubmitPage.

private void testStudentSubmitPage() throws Exception {
    ______TS("test rubric question input disabled for closed session");
    FeedbackSubmitPage submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRubricQnUiT.CS2104", "closedSession");
    int qnNumber = 1;
    int responseNumber = 0;
    int rowNumber = 0;
    assertFalse(submitPage.isNamedElementEnabled(Const.ParamsNames.FEEDBACK_QUESTION_RUBRIC_CHOICE + "-" + qnNumber + "-" + responseNumber + "-" + rowNumber));
    ______TS("test rubric question submission");
    submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRubricQnUiT.CS2104", "openSession2");
    assertTrue(submitPage.isNamedElementEnabled(Const.ParamsNames.FEEDBACK_QUESTION_RUBRIC_CHOICE + "-" + qnNumber + "-" + responseNumber + "-" + rowNumber));
    // Select table cell
    submitPage.clickRubricRadio(1, 0, 0, 1);
    submitPage.clickRubricRadio(1, 1, 0, 1);
    submitPage.clickRubricRadio(1, 1, 1, 0);
    // Submit
    submitPage.clickSubmitButton();
    submitPage.waitForTextsForAllStatusMessagesToUserEquals(Const.StatusMessages.FEEDBACK_RESPONSES_SAVED);
    // Go back to submission page and verify html
    submitPage = loginToStudentFeedbackSubmitPage("alice.tmms@FRubricQnUiT.CS2104", "openSession2");
    submitPage.waitForCellHoverToDisappear();
    submitPage.verifyHtmlMainContent("/studentFeedbackSubmitPageRubricSuccess.html");
    // Submit another feedback response using another student's account
    submitPage = loginToStudentFeedbackSubmitPage("benny.tmms@FRubricQnUiT.CS2104", "openSession2");
    submitPage.clickRubricRadio(1, 0, 0, 0);
    submitPage.clickRubricRadio(1, 0, 1, 1);
    submitPage.clickRubricRadio(1, 1, 0, 0);
    submitPage.clickRubricRadio(1, 1, 1, 0);
    submitPage.clickSubmitButton();
    submitPage = loginToStudentFeedbackSubmitPage("colin.tmms@FRubricQnUiT.CS2104", "openSession2");
    submitPage.clickRubricRadio(1, 0, 0, 1);
    submitPage.clickRubricRadio(1, 0, 1, 0);
    submitPage.clickSubmitButton();
}
Also used : FeedbackSubmitPage(teammates.test.pageobjects.FeedbackSubmitPage)

Aggregations

FeedbackSubmitPage (teammates.test.pageobjects.FeedbackSubmitPage)7 Test (org.testng.annotations.Test)2 StudentFeedbackResultsPage (teammates.test.pageobjects.StudentFeedbackResultsPage)2 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)1 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 AppUrl (teammates.common.util.AppUrl)1 AdminHomePage (teammates.test.pageobjects.AdminHomePage)1 InstructorCourseDetailsPage (teammates.test.pageobjects.InstructorCourseDetailsPage)1 InstructorCourseEditPage (teammates.test.pageobjects.InstructorCourseEditPage)1 InstructorCourseEnrollPage (teammates.test.pageobjects.InstructorCourseEnrollPage)1 InstructorCourseJoinConfirmationPage (teammates.test.pageobjects.InstructorCourseJoinConfirmationPage)1 InstructorCoursesPage (teammates.test.pageobjects.InstructorCoursesPage)1 InstructorFeedbackResultsPage (teammates.test.pageobjects.InstructorFeedbackResultsPage)1 InstructorHomePage (teammates.test.pageobjects.InstructorHomePage)1 StudentCourseDetailsPage (teammates.test.pageobjects.StudentCourseDetailsPage)1 StudentHomePage (teammates.test.pageobjects.StudentHomePage)1 StudentProfilePage (teammates.test.pageobjects.StudentProfilePage)1