-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test e2e changes * fix: reduce e2e test json file size * fix student key * fix course key * fix instructor keys * fix filepath * fix e2e test * remove extra data from bundle * Add correct removal logic to avoid constraint violation * Fix e2e tests and lint fix reset google id test fix e2e tests fix e2e tests fix tests remove double click fix unknown symbol add toast check change toast verification message remove toast check * fix: add null check * move admin search page e2e test to sql cases * Rename AdminSearchPageE2ETest_SQLEntities.json to AdminSearchPageE2ETest_SqlEntities.json * fix failing test * fix: remove extra null check * fix: add test to e2e sql xml file * fix function call * remove unnecessary changes * create new file for sql entities * revert unnecessary changes * remove trailing whitespace * add teardown for account requests --------- Co-authored-by: Cedric Ong <[email protected]>
- Loading branch information
1 parent
1e9ccb0
commit 84ed244
Showing
8 changed files
with
565 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
src/e2e/java/teammates/e2e/cases/sql/AdminSearchPageE2ETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "[email protected]"; | ||
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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.