diff --git a/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java index b5ce80693f0..b73e82c0808 100644 --- a/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java @@ -31,7 +31,7 @@ protected void prepareTestData() { putDocuments(testData); sqlTestData = loadSqlDataBundle("/AdminSearchPageE2ETest_SqlEntities.json"); removeAndRestoreSqlDataBundle(sqlTestData); - doPutDocumentsSql(sqlTestData); + putSqlDocuments(sqlTestData); } @Test diff --git a/src/e2e/java/teammates/e2e/cases/axe/AdminSearchPageAxeTest.java b/src/e2e/java/teammates/e2e/cases/axe/AdminSearchPageAxeTest.java index d45e1d4e16a..732e06ceed3 100644 --- a/src/e2e/java/teammates/e2e/cases/axe/AdminSearchPageAxeTest.java +++ b/src/e2e/java/teammates/e2e/cases/axe/AdminSearchPageAxeTest.java @@ -25,7 +25,7 @@ protected void prepareTestData() { putDocuments(testData); sqlTestData = loadSqlDataBundle("/AdminSearchPageE2ETest_SqlEntities.json"); removeAndRestoreSqlDataBundle(sqlTestData); - doPutDocumentsSql(sqlTestData); + putSqlDocuments(sqlTestData); } @Test diff --git a/src/e2e/java/teammates/e2e/cases/sql/AdminSearchPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/sql/AdminSearchPageE2ETest.java new file mode 100644 index 00000000000..780b0f212fd --- /dev/null +++ b/src/e2e/java/teammates/e2e/cases/sql/AdminSearchPageE2ETest.java @@ -0,0 +1,185 @@ +package teammates.e2e.cases.sql; + +import java.time.Instant; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +import teammates.common.util.AppUrl; +import teammates.common.util.Const; +import teammates.e2e.pageobjects.AdminSearchPage; +import teammates.e2e.util.TestProperties; +import teammates.storage.sqlentity.AccountRequest; +import teammates.storage.sqlentity.Course; +import teammates.storage.sqlentity.FeedbackSession; +import teammates.storage.sqlentity.Instructor; +import teammates.storage.sqlentity.Student; + +/** + * SUT: {@link Const.WebPageURIs#ADMIN_SEARCH_PAGE}. + */ +public class AdminSearchPageE2ETest extends BaseE2ETestCase { + + @Override + protected void prepareTestData() { + if (!TestProperties.INCLUDE_SEARCH_TESTS) { + return; + } + testData = removeAndRestoreDataBundle(loadSqlDataBundle("/AdminSearchPageE2ESqlTest.json")); + putDocuments(testData); + } + + @Test + @Override + public void testAll() { + if (!TestProperties.INCLUDE_SEARCH_TESTS) { + return; + } + + AppUrl url = createFrontendUrl(Const.WebPageURIs.ADMIN_SEARCH_PAGE); + AdminSearchPage searchPage = loginAdminToPage(url, AdminSearchPage.class); + + Course course = testData.courses.get("typicalCourse1"); + Student student = testData.students.get("student1InCourse1"); + Instructor instructor = testData.instructors.get("instructor1OfCourse1"); + AccountRequest accountRequest = testData.accountRequests.get("instructor1OfCourse1"); + + ______TS("Typical case: Search student email"); + String searchContent = student.getEmail(); + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + String studentDetails = getExpectedStudentDetails(student); + String studentManageAccountLink = getExpectedStudentManageAccountLink(student); + String studentHomePageLink = getExpectedStudentHomePageLink(student); + int numExpandedRows = getExpectedNumExpandedRows(student); + searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink, + studentHomePageLink); + searchPage.verifyStudentExpandedLinks(student, numExpandedRows); + + ______TS("Typical case: Reset student google id"); + searchPage.resetStudentGoogleId(student); + student.setGoogleId(null); + searchPage.verifyStudentRowContentAfterReset(student, course); + + ______TS("Typical case: Regenerate registration key for a course student"); + searchPage.clickExpandStudentLinks(); + String originalJoinLink = searchPage.getStudentJoinLink(student); + searchPage.regenerateStudentKey(student); + searchPage.verifyRegenerateStudentKey(student, originalJoinLink); + searchPage.waitForPageToLoad(); + + ______TS("Typical case: Search for instructor email"); + searchPage.clearSearchBox(); + searchContent = instructor.getEmail(); + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + String instructorManageAccountLink = getExpectedInstructorManageAccountLink(instructor); + String instructorHomePageLink = getExpectedInstructorHomePageLink(instructor); + searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink, + instructorHomePageLink); + searchPage.verifyInstructorExpandedLinks(instructor); + + ______TS("Typical case: Reset instructor google id"); + searchPage.resetInstructorGoogleId(instructor); + searchPage.verifyInstructorRowContentAfterReset(instructor, course); + + ______TS("Typical case: Regenerate registration key for an instructor"); + searchPage.clickExpandInstructorLinks(); + originalJoinLink = searchPage.getInstructorJoinLink(instructor); + searchPage.regenerateInstructorKey(instructor); + searchPage.verifyRegenerateInstructorKey(instructor, originalJoinLink); + searchPage.waitForPageToLoad(); + + ______TS("Typical case: Search for account request by email"); + searchPage.clearSearchBox(); + searchContent = accountRequest.getEmail(); + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + searchPage.verifyAccountRequestRowContent(accountRequest); + searchPage.verifyAccountRequestExpandedLinks(accountRequest); + + ______TS("Typical case: Search common search key"); + searchPage.clearSearchBox(); + searchContent = "Course1"; + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + searchPage.verifyStudentRowContentAfterReset(student, course); + searchPage.verifyInstructorRowContentAfterReset(instructor, course); + searchPage.verifyAccountRequestRowContent(accountRequest); + + ______TS("Typical case: Expand and collapse links"); + searchPage.verifyLinkExpansionButtons(student, instructor, accountRequest); + + ______TS("Typical case: Reset account request successful"); + searchContent = "ASearch.instructor1@gmail.tmt"; + searchPage.clearSearchBox(); + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + searchPage.clickResetAccountRequestButton(accountRequest); + assertNull(BACKDOOR.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute()).getRegisteredAt()); + + ______TS("Typical case: Delete account request successful"); + accountRequest = testData.accountRequests.get("unregisteredInstructor1"); + searchContent = accountRequest.getEmail(); + searchPage.clearSearchBox(); + searchPage.inputSearchContent(searchContent); + searchPage.clickSearchButton(); + searchPage.clickDeleteAccountRequestButton(accountRequest); + assertNull(BACKDOOR.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute())); + } + + private String getExpectedStudentDetails(Student student) { + return String.format("%s [%s] (%s)", student.getCourse().getId(), + student.getSection() == null + ? Const.DEFAULT_SECTION + : student.getSection().getName(), student.getTeam().getName()); + } + + private String getExpectedStudentHomePageLink(Student student) { + return student.isRegistered() ? createFrontendUrl(Const.WebPageURIs.STUDENT_HOME_PAGE) + .withUserId(student.getGoogleId()) + .toAbsoluteString() + : ""; + } + + private String getExpectedStudentManageAccountLink(Student student) { + return student.isRegistered() ? createFrontendUrl(Const.WebPageURIs.ADMIN_ACCOUNTS_PAGE) + .withParam(Const.ParamsNames.INSTRUCTOR_ID, student.getGoogleId()) + .toAbsoluteString() + : ""; + } + + private int getExpectedNumExpandedRows(Student student) { + int expectedNumExpandedRows = 2; + for (FeedbackSession sessions : testData.feedbackSessions.values()) { + if (sessions.getCourse().equals(student.getCourse())) { + expectedNumExpandedRows += 1; + if (sessions.getResultsVisibleFromTime().isBefore(Instant.now())) { + expectedNumExpandedRows += 1; + } + } + } + return expectedNumExpandedRows; + } + + private String getExpectedInstructorHomePageLink(Instructor instructor) { + String googleId = instructor.isRegistered() ? instructor.getGoogleId() : ""; + return createFrontendUrl(Const.WebPageURIs.INSTRUCTOR_HOME_PAGE) + .withUserId(googleId) + .toAbsoluteString(); + } + + private String getExpectedInstructorManageAccountLink(Instructor instructor) { + String googleId = instructor.isRegistered() ? instructor.getGoogleId() : ""; + return createFrontendUrl(Const.WebPageURIs.ADMIN_ACCOUNTS_PAGE) + .withParam(Const.ParamsNames.INSTRUCTOR_ID, googleId) + .toAbsoluteString(); + } + + @AfterClass + public void classTeardown() { + for (AccountRequest request : testData.accountRequests.values()) { + BACKDOOR.deleteAccountRequest(request.getEmail(), request.getInstitute()); + } + } +} diff --git a/src/e2e/java/teammates/e2e/cases/sql/BaseE2ETestCase.java b/src/e2e/java/teammates/e2e/cases/sql/BaseE2ETestCase.java index b61a4a8cf2a..fbfd60ea84b 100644 --- a/src/e2e/java/teammates/e2e/cases/sql/BaseE2ETestCase.java +++ b/src/e2e/java/teammates/e2e/cases/sql/BaseE2ETestCase.java @@ -265,4 +265,18 @@ StudentData getStudent(String courseId, String studentEmailAddress) { protected StudentData getStudent(Student student) { return getStudent(student.getCourseId(), student.getEmail()); } + + /** + * Puts the documents in the database using BACKDOOR. + * @param dataBundle the data to be put in the database + * @return the result of the operation + */ + protected String putDocuments(SqlDataBundle dataBundle) { + try { + return BACKDOOR.putSqlDocuments(dataBundle); + } catch (HttpRequestFailedException e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java index 706e9ab5a20..005b98a026b 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java @@ -18,6 +18,9 @@ import teammates.common.util.Const; import teammates.common.util.StringHelper; import teammates.storage.sqlentity.AccountRequest; +import teammates.storage.sqlentity.Course; +import teammates.storage.sqlentity.Instructor; +import teammates.storage.sqlentity.Student; /** * Represents the admin home page of the website. @@ -93,6 +96,14 @@ public void clickSearchButton() { waitForPageToLoad(); } + public void regenerateStudentKey(Student student) { + WebElement studentRow = getStudentRow(student); + studentRow.findElement(By.xpath("//button[text()='Regenerate key']")).click(); + + waitForConfirmationModalAndClickOk(); + waitForPageToLoad(true); + } + public void regenerateStudentKey(StudentAttributes student) { WebElement studentRow = getStudentRow(student); studentRow.findElement(By.xpath("//button[text()='Regenerate key']")).click(); @@ -101,6 +112,30 @@ public void regenerateStudentKey(StudentAttributes student) { waitForPageToLoad(true); } + public void verifyRegenerateStudentKey(Student student, String originalJoinLink) { + verifyStatusMessage("Student's key for this course has been successfully regenerated," + + " and the email has been sent."); + + String regeneratedJoinLink = getStudentJoinLink(student); + assertNotEquals(regeneratedJoinLink, originalJoinLink); + } + + public void verifyRegenerateStudentKey(StudentAttributes student, String originalJoinLink) { + verifyStatusMessage("Student's key for this course has been successfully regenerated," + + " and the email has been sent."); + + String regeneratedJoinLink = getStudentJoinLink(student); + assertNotEquals(regeneratedJoinLink, originalJoinLink); + } + + public void regenerateInstructorKey(Instructor instructor) { + WebElement instructorRow = getInstructorRow(instructor); + instructorRow.findElement(By.xpath("//button[text()='Regenerate key']")).click(); + + waitForConfirmationModalAndClickOk(); + waitForPageToLoad(true); + } + public void regenerateInstructorKey(InstructorAttributes instructor) { WebElement instructorRow = getInstructorRow(instructor); instructorRow.findElement(By.xpath("//button[text()='Regenerate key']")).click(); @@ -143,6 +178,25 @@ public String removeSpanFromText(String text) { return text.replace("", "").replace("", ""); } + public WebElement getStudentRow(Student student) { + String details = String.format("%s [%s] (%s)", student.getCourse().getId(), + student.getSection() == null + ? Const.DEFAULT_SECTION + : student.getSection().getName(), student.getTeam().getName()); + WebElement table = browser.driver.findElement(By.id("search-table-student")); + List rows = table.findElements(By.tagName("tr")); + for (WebElement row : rows) { + List columns = row.findElements(By.tagName("td")); + if (!columns.isEmpty() && removeSpanFromText(columns.get(STUDENT_COL_DETAILS - 1) + .getAttribute("innerHTML")).contains(details) + && removeSpanFromText(columns.get(STUDENT_COL_NAME - 1) + .getAttribute("innerHTML")).contains(student.getName())) { + return row; + } + } + return null; + } + public WebElement getStudentRow(StudentAttributes student) { String details = String.format("%s [%s] (%s)", student.getCourse(), student.getSection() == null ? Const.DEFAULT_SECTION : student.getSection(), student.getTeam()); @@ -195,11 +249,25 @@ public String getStudentJoinLink(WebElement studentRow) { return getExpandedRowInputValue(studentRow, EXPANDED_ROWS_HEADER_COURSE_JOIN_LINK); } + public String getStudentJoinLink(Student student) { + WebElement studentRow = getStudentRow(student); + return getStudentJoinLink(studentRow); + } + public String getStudentJoinLink(StudentAttributes student) { WebElement studentRow = getStudentRow(student); return getStudentJoinLink(studentRow); } + public void resetStudentGoogleId(Student student) { + WebElement studentRow = getStudentRow(student); + WebElement link = studentRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); + link.click(); + + waitForConfirmationModalAndClickOk(); + waitForElementStaleness(link); + } + public void resetStudentGoogleId(StudentAttributes student) { WebElement studentRow = getStudentRow(student); WebElement link = studentRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); @@ -209,6 +277,21 @@ public void resetStudentGoogleId(StudentAttributes student) { waitForElementStaleness(link); } + public WebElement getInstructorRow(Instructor instructor) { + WebElement table = browser.driver.findElement(By.id("search-table-instructor")); + List rows = table.findElements(By.tagName("tr")); + for (WebElement row : rows) { + List columns = row.findElements(By.tagName("td")); + if (columns.size() >= 3 && (removeSpanFromText(columns.get(2) + .getAttribute("innerHTML")).contains(instructor.getGoogleId()) + || removeSpanFromText(columns.get(1) + .getAttribute("innerHTML")).contains(instructor.getName()))) { + return row; + } + } + return null; + } + public WebElement getInstructorRow(InstructorAttributes instructor) { String courseId = instructor.getCourseId(); List rows = browser.driver.findElements(By.cssSelector("#search-table-instructor tbody tr")); @@ -256,11 +339,25 @@ public String getInstructorJoinLink(WebElement instructorRow) { return getExpandedRowInputValue(instructorRow, EXPANDED_ROWS_HEADER_COURSE_JOIN_LINK); } + public String getInstructorJoinLink(Instructor instructor) { + WebElement instructorRow = getInstructorRow(instructor); + return getInstructorJoinLink(instructorRow); + } + public String getInstructorJoinLink(InstructorAttributes instructor) { WebElement instructorRow = getInstructorRow(instructor); return getInstructorJoinLink(instructorRow); } + public void resetInstructorGoogleId(Instructor instructor) { + WebElement instructorRow = getInstructorRow(instructor); + WebElement link = instructorRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); + link.click(); + + waitForConfirmationModalAndClickOk(); + waitForElementStaleness(link); + } + public void resetInstructorGoogleId(InstructorAttributes instructor) { WebElement instructorRow = getInstructorRow(instructor); WebElement link = instructorRow.findElement(By.linkText(LINK_TEXT_RESET_GOOGLE_ID)); @@ -386,6 +483,32 @@ private String getExpandedRowInputValue(WebElement row, String rowHeader) { } } + public void verifyStudentRowContent(Student student, Course course, + String expectedDetails, String expectedManageAccountLink, + String expectedHomePageLink) { + WebElement studentRow = getStudentRow(student); + String actualDetails = getStudentDetails(studentRow); + String actualName = getStudentName(studentRow); + String actualGoogleId = getStudentGoogleId(studentRow); + String actualHomepageLink = getStudentHomeLink(studentRow); + String actualInstitute = getStudentInstitute(studentRow); + String actualComment = getStudentComments(studentRow); + String actualManageAccountLink = getStudentManageAccountLink(studentRow); + + String expectedName = student.getName(); + String expectedGoogleId = StringHelper.convertToEmptyStringIfNull(student.getGoogleId()); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); + String expectedComment = StringHelper.convertToEmptyStringIfNull(student.getComments()); + + assertEquals(expectedDetails, actualDetails); + assertEquals(expectedName, actualName); + assertEquals(expectedGoogleId, actualGoogleId); + assertEquals(expectedInstitute, actualInstitute); + assertEquals(expectedComment, actualComment); + assertEquals(expectedManageAccountLink, actualManageAccountLink); + assertEquals(expectedHomePageLink, actualHomepageLink); + } + public void verifyStudentRowContent(StudentAttributes student, CourseAttributes course, String expectedDetails, String expectedManageAccountLink, String expectedHomePageLink) { @@ -412,6 +535,35 @@ public void verifyStudentRowContent(StudentAttributes student, CourseAttributes assertEquals(expectedHomePageLink, actualHomepageLink); } + public void verifyStudentRowContentAfterReset(Student student, Course course) { + WebElement studentRow = getStudentRow(student); + String actualName = getStudentName(studentRow); + String actualInstitute = getStudentInstitute(studentRow); + String actualComment = getStudentComments(studentRow); + + String expectedName = student.getName(); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); + String expectedComment = StringHelper.convertToEmptyStringIfNull(student.getComments()); + + assertEquals(expectedName, actualName); + assertEquals(expectedInstitute, actualInstitute); + assertEquals(expectedComment, actualComment); + } + + public void verifyStudentExpandedLinks(Student student, int expectedNumExpandedRows) { + clickExpandStudentLinks(); + WebElement studentRow = getStudentRow(student); + String actualEmail = getStudentEmail(studentRow); + String actualJoinLink = getStudentJoinLink(studentRow); + int actualNumExpandedRows = getNumExpandedRows(studentRow); + + String expectedEmail = student.getEmail(); + + assertEquals(expectedEmail, actualEmail); + assertNotEquals("", actualJoinLink); + assertEquals(expectedNumExpandedRows, actualNumExpandedRows); + } + public void verifyStudentExpandedLinks(StudentAttributes student, int expectedNumExpandedRows) { clickExpandStudentLinks(); WebElement studentRow = getStudentRow(student); @@ -426,6 +578,29 @@ public void verifyStudentExpandedLinks(StudentAttributes student, int expectedNu assertEquals(expectedNumExpandedRows, actualNumExpandedRows); } + public void verifyInstructorRowContent(Instructor instructor, Course course, + String expectedManageAccountLink, String expectedHomePageLink) { + WebElement instructorRow = getInstructorRow(instructor); + String actualCourseId = getInstructorCourseId(instructorRow); + String actualName = getInstructorName(instructorRow); + String actualGoogleId = getInstructorGoogleId(instructorRow); + String actualHomePageLink = getInstructorHomePageLink(instructorRow); + String actualInstitute = getInstructorInstitute(instructorRow); + String actualManageAccountLink = getInstructorManageAccountLink(instructorRow); + + String expectedCourseId = instructor.getCourseId(); + String expectedName = instructor.getName(); + String expectedGoogleId = StringHelper.convertToEmptyStringIfNull(instructor.getGoogleId()); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); + + assertEquals(expectedCourseId, actualCourseId); + assertEquals(expectedName, actualName); + assertEquals(expectedGoogleId, actualGoogleId); + assertEquals(expectedHomePageLink, actualHomePageLink); + assertEquals(expectedInstitute, actualInstitute); + assertEquals(expectedManageAccountLink, actualManageAccountLink); + } + public void verifyInstructorRowContent(InstructorAttributes instructor, CourseAttributes course, String expectedManageAccountLink, String expectedHomePageLink) { WebElement instructorRow = getInstructorRow(instructor); @@ -449,6 +624,33 @@ public void verifyInstructorRowContent(InstructorAttributes instructor, CourseAt assertEquals(expectedManageAccountLink, actualManageAccountLink); } + public void verifyInstructorRowContentAfterReset(Instructor instructor, Course course) { + WebElement instructorRow = getInstructorRow(instructor); + String actualCourseId = getInstructorCourseId(instructorRow); + String actualName = getInstructorName(instructorRow); + String actualInstitute = getInstructorInstitute(instructorRow); + + String expectedCourseId = instructor.getCourseId(); + String expectedName = instructor.getName(); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); + + assertEquals(expectedCourseId, actualCourseId); + assertEquals(expectedName, actualName); + assertEquals(expectedInstitute, actualInstitute); + } + + public void verifyInstructorExpandedLinks(Instructor instructor) { + clickExpandInstructorLinks(); + WebElement instructorRow = getInstructorRow(instructor); + String actualEmail = getInstructorEmail(instructorRow); + String actualJoinLink = getInstructorJoinLink(instructorRow); + + String expectedEmail = instructor.getEmail(); + + assertEquals(expectedEmail, actualEmail); + assertNotEquals("", actualJoinLink); + } + public void verifyInstructorExpandedLinks(InstructorAttributes instructor) { clickExpandInstructorLinks(); WebElement instructorRow = getInstructorRow(instructor); @@ -515,6 +717,43 @@ public void verifyAccountRequestExpandedLinks(AccountRequest accountRequest) { assertFalse(actualRegistrationLink.isBlank()); } + public void verifyLinkExpansionButtons(Student student, + Instructor instructor, AccountRequest accountRequest) { + WebElement studentRow = getStudentRow(student); + WebElement instructorRow = getInstructorRow(instructor); + WebElement accountRequestRow = getAccountRequestRow(accountRequest); + + clickExpandStudentLinks(); + clickExpandInstructorLinks(); + clickExpandAccountRequestLinks(); + int numExpandedStudentRows = getNumExpandedRows(studentRow); + int numExpandedInstructorRows = getNumExpandedRows(instructorRow); + int numExpandedAccountRequestRows = getNumExpandedRows(accountRequestRow); + assertNotEquals(numExpandedStudentRows, 0); + assertNotEquals(numExpandedInstructorRows, 0); + assertNotEquals(numExpandedAccountRequestRows, 0); + + clickCollapseInstructorLinks(); + numExpandedStudentRows = getNumExpandedRows(studentRow); + numExpandedInstructorRows = getNumExpandedRows(instructorRow); + numExpandedAccountRequestRows = getNumExpandedRows(accountRequestRow); + assertNotEquals(numExpandedStudentRows, 0); + assertEquals(numExpandedInstructorRows, 0); + assertNotEquals(numExpandedAccountRequestRows, 0); + + clickExpandInstructorLinks(); + clickCollapseStudentLinks(); + clickCollapseAccountRequestLinks(); + waitUntilAnimationFinish(); + + numExpandedStudentRows = getNumExpandedRows(studentRow); + numExpandedInstructorRows = getNumExpandedRows(instructorRow); + numExpandedAccountRequestRows = getNumExpandedRows(accountRequestRow); + assertEquals(numExpandedStudentRows, 0); + assertNotEquals(numExpandedInstructorRows, 0); + assertEquals(numExpandedAccountRequestRows, 0); + } + public void verifyLinkExpansionButtons(StudentAttributes student, InstructorAttributes instructor, AccountRequestAttributes accountRequest) { WebElement studentRow = getStudentRow(student); @@ -589,11 +828,11 @@ public void verifyLinkExpansionButtons(StudentAttributes student, assertEquals(numExpandedAccountRequestRows, 0); } - public void verifyRegenerateStudentKey(StudentAttributes student, String originalJoinLink) { - verifyStatusMessage("Student's key for this course has been successfully regenerated," + public void verifyRegenerateInstructorKey(Instructor instructor, String originalJoinLink) { + verifyStatusMessage("Instructor's key for this course has been successfully regenerated," + " and the email has been sent."); - String regeneratedJoinLink = getStudentJoinLink(student); + String regeneratedJoinLink = getInstructorJoinLink(instructor); assertNotEquals(regeneratedJoinLink, originalJoinLink); } @@ -604,5 +843,4 @@ public void verifyRegenerateInstructorKey(InstructorAttributes instructor, Strin String regeneratedJoinLink = getInstructorJoinLink(instructor); assertNotEquals(regeneratedJoinLink, originalJoinLink); } - } diff --git a/src/e2e/resources/data/AdminSearchPageE2ESqlTest.json b/src/e2e/resources/data/AdminSearchPageE2ESqlTest.json new file mode 100644 index 00000000000..94b28ae6ad2 --- /dev/null +++ b/src/e2e/resources/data/AdminSearchPageE2ESqlTest.json @@ -0,0 +1,118 @@ +{ + "accounts": { + "instructor1OfCourse1": { + "id": "00000000-0000-4000-8000-000000000001", + "googleId": "tm.e2e.ASearch.instr1", + "name": "Instructor1 of Course1", + "email": "ASearch.instructor1@gmail.tmt" + }, + "instructor2OfCourse1": { + "id": "00000000-0000-4000-8000-000000000002", + "googleId": "tm.e2e.ASearch.instr2", + "name": "Instructor2 of Course1", + "email": "ASearch.instructor2@gmail.tmt" + }, + "student1InCourse1": { + "id": "00000000-0000-4000-8000-000000000003", + "googleId": "tm.e2e.ASearch.student1", + "name": "Student1 in course1", + "email": "ASearch.student@gmail.tmt" + } + }, + "accountRequests": { + "instructor1OfCourse1": { + "name": "Instructor1 of Course1", + "email": "ASearch.instructor1@gmail.tmt", + "institute": "TEAMMATES Test Institute 1", + "createdAt": "2011-01-01T00:00:00Z", + "registeredAt": "1970-02-14T00:00:00Z" + }, + "instructor2OfCourse1": { + "name": "Instructor2 of Course1", + "email": "ASearch.instructor2@gmail.tmt", + "institute": "TEAMMATES Test Institute 1", + "createdAt": "2011-01-01T00:00:00Z", + "registeredAt": "1970-02-14T00:00:00Z" + }, + "unregisteredInstructor1": { + "name": "Typical Instructor Name", + "email": "ASearch.unregisteredinstructor1@gmail.tmt", + "institute": "TEAMMATES Test Institute 1", + "createdAt": "2011-01-01T00:00:00Z" + } + }, + "courses": { + "typicalCourse1": { + "createdAt": "2012-04-01T23:59:00Z", + "id": "00000000-0000-4000-8000-000000000303", + "name": "ASearch Course 1", + "institute": "TEAMMATES Test Institute 0", + "timeZone": "Africa/Johannesburg" + } + }, + "sections": { + "section1InCourse1": { + "id": "00000000-0000-4000-8000-000000000201", + "course": { + "id": "00000000-0000-4000-8000-000000000303" + }, + "name": "Section 1" + } + }, + "teams": { + "team1InCourse1": { + "id": "00000000-0000-4000-8000-000000000301", + "section": { + "id": "00000000-0000-4000-8000-000000000201" + }, + "name": "Team 1" + } + }, + "instructors": { + "instructor1OfCourse1": { + "id": "00000000-0000-4000-8000-000000000501", + "account": { + "id": "00000000-0000-4000-8000-000000000001" + }, + "course": { + "id": "00000000-0000-4000-8000-000000000303" + }, + "name": "Instructor1 of ASearch Course1", + "email": "ASearch.instructor@gmail.tmt", + "role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER", + "isDisplayedToStudents": true, + "displayName": "Instructor", + "privileges": { + "courseLevel": { + "canModifyCourse": true, + "canModifyInstructor": true, + "canModifySession": true, + "canModifyStudent": true, + "canViewStudentInSections": true, + "canViewSessionInSections": true, + "canSubmitSessionInSections": true, + "canModifySessionCommentsInSections": true + }, + "sectionLevel": {}, + "sessionLevel": {} + } + } + }, + "students": { + "student1InCourse1": { + "id": "00000000-0000-4000-8000-000000000601", + "account": { + "id": "00000000-0000-4000-8000-000000000003" + }, + "course": { + "id": "00000000-0000-4000-8000-000000000303" + }, + "team": { + "id": "00000000-0000-4000-8000-000000000301" + }, + "email": "ASearch.student@gmail.tmt", + "name": "Student1 In ASearch Course1", + "comments": "comment for student1Course1" + } + } +} diff --git a/src/e2e/resources/testng-e2e-sql.xml b/src/e2e/resources/testng-e2e-sql.xml index 78dcc2d13a1..40e4bedfad9 100644 --- a/src/e2e/resources/testng-e2e-sql.xml +++ b/src/e2e/resources/testng-e2e-sql.xml @@ -11,6 +11,7 @@ + diff --git a/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java b/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java index 2bd8f2bfb08..50add8e08ff 100644 --- a/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java +++ b/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java @@ -256,12 +256,10 @@ public EmailWrapper generateFeedbackSessionSummaryOfCourse( Course course = coursesLogic.getCourse(courseId); boolean isInstructor = emailType == EmailType.INSTRUCTOR_COURSE_LINKS_REGENERATED; - Student student = null; + Student student = usersLogic.getStudentForEmail(courseId, userEmail); Instructor instructor = null; if (isInstructor) { instructor = usersLogic.getInstructorForEmail(courseId, userEmail); - } else { - student = usersLogic.getStudentForEmail(courseId, userEmail); } List sessions = new ArrayList<>(); @@ -868,11 +866,11 @@ private EmailWrapper generateFeedbackSessionEmailBaseForNotifiedInstructors( } private boolean isYetToJoinCourse(Student student) { - return student.getAccount().getGoogleId() == null || student.getAccount().getGoogleId().isEmpty(); + return student.getAccount() == null || student.getAccount().getGoogleId().isEmpty(); } private boolean isYetToJoinCourse(Instructor instructor) { - return instructor.getAccount().getGoogleId() == null || instructor.getAccount().getGoogleId().isEmpty(); + return instructor.getAccount() == null || instructor.getAccount().getGoogleId().isEmpty(); } /**