Skip to content

Commit

Permalink
Fix e2e tests and lint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
domoberzin committed Feb 25, 2024
1 parent 09df7f1 commit 3bdccdd
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 71 deletions.
74 changes: 32 additions & 42 deletions src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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;
import teammates.storage.sqlentity.FeedbackSession;

/**
* SUT: {@link Const.WebPageURIs#ADMIN_SEARCH_PAGE}.
Expand All @@ -26,10 +26,9 @@ protected void prepareTestData() {
return;
}
testData = loadDataBundle("/AdminSearchPageE2ETest.json");
sqlTestData =
removeAndRestoreSqlDataBundle(
sqlTestData = removeAndRestoreSqlDataBundle(
loadSqlDataBundle("/AdminSearchPageE2ETest_SQLEntities.json"));
putDocumentsSQL(sqlTestData);
putDocumentsSql(sqlTestData);
removeAndRestoreDataBundle(testData);
putDocuments(testData);
}
Expand Down Expand Up @@ -61,18 +60,14 @@ public void testAll() {
studentHomePageLink);
searchPage.verifyStudentExpandedLinks(student, numExpandedRows);

// ______TS("Typical case: Reset student google id");
// searchPage.resetStudentGoogleId(student);
// student.setGoogleId(null);
// studentManageAccountLink = getExpectedStudentManageAccountLink(student);
// studentHomePageLink = getExpectedStudentHomePageLink(student);
// searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink,
// studentHomePageLink);
______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();
Expand All @@ -88,18 +83,13 @@ public void testAll() {
instructorHomePageLink);
searchPage.verifyInstructorExpandedLinks(instructor);

// ______TS("Typical case: Reset instructor google id");
// searchPage.resetInstructorGoogleId(instructor);
// instructor.setGoogleId(null);
// instructorManageAccountLink = getExpectedInstructorManageAccountLink(instructor);
// instructorHomePageLink = getExpectedInstructorHomePageLink(instructor);
// searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink,
// instructorHomePageLink);
______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();
Expand All @@ -112,27 +102,25 @@ public void testAll() {
searchPage.verifyAccountRequestRowContent(accountRequest);
searchPage.verifyAccountRequestExpandedLinks(accountRequest);

// ______TS("Typical case: Search common search key");
// searchPage.clearSearchBox();
// searchContent = "Course1";
// searchPage.inputSearchContent(searchContent);
// searchPage.clickSearchButton();
// searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink,
// studentHomePageLink);
// searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink,
// instructorHomePageLink);
// searchPage.verifyAccountRequestRowContent(accountRequest);

// ______TS("Typical case: Expand and collapse links");
// searchPage.verifyLinkExpansionButtons(student, instructor, accountRequest);

// ______TS("Typical case: Reset account request successful");
// searchContent = "unregisteredinstructor1";
// searchPage.clearSearchBox();
// searchPage.inputSearchContent(searchContent);
// searchPage.clickSearchButton();
// searchPage.clickResetAccountRequestButton(accountRequest);
// assertNull(BACKDOOR.getAccountRequest(accountRequest.getEmail(), accountRequest.getInstitute()).getRegisteredAt());
______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 = "unregisteredinstructor1";
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 = sqlTestData.accountRequests.get("unregisteredInstructor1");
Expand All @@ -146,7 +134,9 @@ public void testAll() {

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());
student.getSection() == null
? Const.DEFAULT_SECTION
: student.getSection().getName(), student.getTeam().getName());
}

private String getExpectedStudentHomePageLink(Student student) {
Expand Down
45 changes: 39 additions & 6 deletions src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import teammates.common.util.Const;
import teammates.common.util.StringHelper;
import teammates.storage.sqlentity.AccountRequest;
import teammates.storage.sqlentity.Course;
Expand Down Expand Up @@ -147,8 +146,10 @@ public WebElement getStudentRow(Student student) {
List<WebElement> rows = table.findElements(By.tagName("tr"));
for (WebElement row : rows) {
List<WebElement> columns = row.findElements(By.tagName("td"));
if (columns.size() >= 3 && removeSpanFromText(columns.get(2)
.getAttribute("innerHTML")).contains(student.getGoogleId())) {
if (columns.size() >= 3 && (removeSpanFromText(columns.get(2)
.getAttribute("innerHTML")).contains(student.getGoogleId())
|| removeSpanFromText(columns.get(1)
.getAttribute("innerHTML")).contains(student.getName()))) {
return row;
}
}
Expand Down Expand Up @@ -210,8 +211,10 @@ public WebElement getInstructorRow(Instructor instructor) {
List<WebElement> rows = table.findElements(By.tagName("tr"));
for (WebElement row : rows) {
List<WebElement> columns = row.findElements(By.tagName("td"));
if (columns.size() >= 3 && removeSpanFromText(columns.get(2)
.getAttribute("innerHTML")).contains(instructor.getGoogleId())) {
if (columns.size() >= 3 && (removeSpanFromText(columns.get(2)
.getAttribute("innerHTML")).contains(instructor.getGoogleId())
|| removeSpanFromText(columns.get(1)
.getAttribute("innerHTML")).contains(instructor.getName()))) {
return row;
}
}
Expand Down Expand Up @@ -271,7 +274,7 @@ public WebElement getAccountRequestRow(AccountRequest accountRequest) {
for (WebElement row : rows) {
List<WebElement> columns = row.findElements(By.tagName("td"));
if (columns.size() >= 2 && removeSpanFromText(columns.get(1)
.getAttribute("innerHTML")).contains(email)) {
.getAttribute("innerHTML")).contains(email)) {
return row;
}
}
Expand Down Expand Up @@ -372,6 +375,21 @@ public void verifyStudentRowContent(Student student, Course course,
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);
Expand Down Expand Up @@ -409,6 +427,21 @@ public void verifyInstructorRowContent(Instructor instructor, Course course,
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);
Expand Down
11 changes: 6 additions & 5 deletions src/e2e/resources/data/AdminSearchPageE2ETest_SQLEntities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"accounts": {
"instructor1OfCourse1": {
"id": "00000000-0000-4000-8000-000000000001",
"googleId": "tm.e2e.ASearch.instr1",
"googleId": "tm.e2e.ASearch.instr",
"name": "Instructor 1",
"email": "[email protected]"
},
"unregisteredInstructor1": {
"id": "00000000-0000-4000-8000-000000000006",
"googleId": "unregisteredInstructor1",
"googleId": "unregisteredInstructor",
"name": "Unregistered Instructor 1 of Course1",
"email": "[email protected]"
},
"student1InCourse1": {
"id": "00000000-0000-4000-8000-000000000101",
"googleId": "tm.e2e.ASearch.student1",
"googleId": "tm.e2e.ASearch.student",
"name": "Student1 in course1",
"email": "[email protected]"
}
Expand All @@ -25,7 +25,8 @@
"googleId": "unregisteredInstructor1",
"name": "Unregistered Instructor 1 of Course1",
"email": "[email protected]",
"institute":"TEAMMATES Test Institute 0"
"institute":"TEAMMATES Test Institute 0",
"registeredAt": "2010-02-14T00:00:00Z"
}
},
"courses": {
Expand Down Expand Up @@ -65,7 +66,7 @@
"id": "course-1"
},
"name": "Instructor1 of Course1",
"email": "ASearch.instructor1@gmail.tmt",
"email": "ASearch.instructor@gmail.tmt",
"role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER",
"isDisplayedToStudents": true,
"displayName": "Instructor",
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<FeedbackSession> sessions = new ArrayList<>();
Expand Down Expand Up @@ -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();
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/teammates/sqllogic/core/DataBundleLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,6 @@ public void removeDataBundle(SqlDataBundle dataBundle) throws InvalidParametersE
throw new InvalidParametersException("Data bundle is null");
}

dataBundle.feedbackResponseComments.values().forEach(responseComment -> {
frcLogic.deleteFeedbackResponseComment(responseComment.getId());
});

dataBundle.feedbackSessions.values().forEach(session -> {
fsLogic.deleteFeedbackSessionCascade(session.getName(), session.getCourse().getId());
});

dataBundle.feedbackQuestions.values().forEach(question -> {
fqLogic.deleteFeedbackQuestionCascade(question.getId());
});

dataBundle.courses.values().forEach(course -> {
coursesLogic.deleteCourseCascade(course.getId());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected SqlDataBundle removeAndRestoreSqlDataBundle(SqlDataBundle testData) {

protected abstract SqlDataBundle doRemoveAndRestoreSqlDataBundle(SqlDataBundle testData);

protected void putDocumentsSQL(SqlDataBundle testData) {
protected void putDocumentsSql(SqlDataBundle testData) {
int retryLimit = OPERATION_RETRY_COUNT;
boolean isOperationSuccess = doPutDocuments(testData);
while (!isOperationSuccess && retryLimit > 0) {
Expand Down

0 comments on commit 3bdccdd

Please sign in to comment.