-
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
* Add teammates.e2e.cases.sql.InstructorCourseDetailsPageE2ETest * Remove data properly to prevent clashes * Add SQL data bundle * Verify loaded details * Use email address when getting a student row * Check student links * Verify the sending of invites * Verify the reminding of all students to join * Remove SQL data properly to prevent clashes * Verify the downloading of the student list * Implement helper methods for Student * Add BaseTestCaseWithSqlDatabaseAccess::verifyAbsentInDatabase * Add to testng-e2e-sql.xml * Verify the deleting of students * Verify the deleting of all the students * Fix lint * Remove duplicate equality check for students
- Loading branch information
1 parent
20df6b6
commit a9423da
Showing
7 changed files
with
443 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
|
@@ -77,26 +78,26 @@ public void testAll() { | |
StudentAttributes studentToView = testData.students.get("[email protected]"); | ||
|
||
InstructorCourseStudentDetailsViewPage studentDetailsViewPage = | ||
detailsPage.clickViewStudent(studentToView); | ||
detailsPage.clickViewStudent(studentToView.getEmail()); | ||
studentDetailsViewPage.verifyIsCorrectPage(course.getId(), studentToView.getEmail()); | ||
studentDetailsViewPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("link: edit student details page"); | ||
|
||
InstructorCourseStudentDetailsEditPage studentDetailsEditPage = | ||
detailsPage.clickEditStudent(studentToView); | ||
detailsPage.clickEditStudent(studentToView.getEmail()); | ||
studentDetailsEditPage.verifyIsCorrectPage(course.getId(), studentToView.getEmail()); | ||
studentDetailsEditPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("link: view all records page"); | ||
|
||
InstructorStudentRecordsPage studentRecordsPage = | ||
detailsPage.clickViewAllRecords(studentToView); | ||
detailsPage.clickViewAllRecords(studentToView.getEmail()); | ||
studentRecordsPage.verifyIsCorrectPage(course.getId(), studentToView.getName()); | ||
studentRecordsPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("send invite"); | ||
detailsPage.sendInvite(student); | ||
detailsPage.sendInvite(student.getEmail()); | ||
|
||
detailsPage.verifyStatusMessage("An email has been sent to " + student.getEmail()); | ||
String expectedEmailSubject = "TEAMMATES: Invitation to join course [" | ||
|
@@ -121,7 +122,7 @@ public void testAll() { | |
detailsPage.sortByName(); | ||
detailsPage.sortByStatus(); | ||
StudentAttributes[] studentsAfterDelete = { students[0], students[3], students[1] }; | ||
detailsPage.deleteStudent(student); | ||
detailsPage.deleteStudent(student.getEmail()); | ||
|
||
detailsPage.verifyStatusMessage("Student is successfully deleted from course \"" | ||
+ course.getId() + "\""); | ||
|
@@ -139,6 +140,11 @@ public void testAll() { | |
} | ||
} | ||
|
||
@AfterClass | ||
public void classTearDown() { | ||
BACKDOOR.removeDataBundle(testData); | ||
} | ||
|
||
private void verifyCourseDetails(InstructorCourseDetailsPage detailsPage, CourseAttributes course, | ||
InstructorAttributes[] instructors, StudentAttributes[] students) { | ||
Set<String> sections = new HashSet<>(); | ||
|
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
139 changes: 139 additions & 0 deletions
139
src/e2e/java/teammates/e2e/cases/sql/InstructorCourseDetailsPageE2ETest.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,139 @@ | ||
package teammates.e2e.cases.sql; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.util.AppUrl; | ||
import teammates.common.util.Const; | ||
import teammates.e2e.pageobjects.InstructorCourseDetailsPage; | ||
import teammates.e2e.pageobjects.InstructorCourseStudentDetailsEditPage; | ||
import teammates.e2e.pageobjects.InstructorCourseStudentDetailsViewPage; | ||
import teammates.e2e.pageobjects.InstructorStudentRecordsPage; | ||
import teammates.e2e.util.TestProperties; | ||
import teammates.storage.sqlentity.Course; | ||
import teammates.storage.sqlentity.Instructor; | ||
import teammates.storage.sqlentity.Student; | ||
|
||
/** | ||
* SUT: {@link Const.WebPageURIs#INSTRUCTOR_COURSE_DETAILS_PAGE}. | ||
*/ | ||
public class InstructorCourseDetailsPageE2ETest extends BaseE2ETestCase { | ||
private Course course; | ||
private Student student3; | ||
private String downloadedFileName; | ||
|
||
@Override | ||
protected void prepareTestData() { | ||
testData = loadSqlDataBundle("/InstructorCourseDetailsPageE2ESqlTest.json"); | ||
student3 = testData.students.get("[email protected]"); | ||
student3.setEmail(TestProperties.TEST_EMAIL); | ||
removeAndRestoreDataBundle(testData); | ||
course = testData.courses.get("ICDet.CS2104"); | ||
downloadedFileName = "/" + course.getId() + "_studentList.csv"; | ||
} | ||
|
||
@BeforeClass | ||
public void classSetup() { | ||
deleteDownloadsFile(downloadedFileName); | ||
} | ||
|
||
@AfterClass | ||
public void classTearDown() { | ||
deleteDownloadsFile(downloadedFileName); | ||
BACKDOOR.removeSqlDataBundle(testData); | ||
} | ||
|
||
@Test | ||
@Override | ||
protected void testAll() { | ||
Instructor instructor1 = testData.instructors.get("ICDet.instr"); | ||
AppUrl detailsPageUrl = createFrontendUrl(Const.WebPageURIs.INSTRUCTOR_COURSE_DETAILS_PAGE) | ||
.withCourseId(course.getId()); | ||
InstructorCourseDetailsPage detailsPage = | ||
loginToPage(detailsPageUrl, InstructorCourseDetailsPage.class, instructor1.getGoogleId()); | ||
|
||
______TS("verify loaded details"); | ||
List<Instructor> instructors = Arrays.asList(instructor1, testData.instructors.get("ICDet.instr2")); | ||
List<Student> students = Arrays.asList( | ||
testData.students.get("[email protected]"), | ||
testData.students.get("[email protected]"), | ||
testData.students.get("[email protected]"), | ||
testData.students.get("[email protected]") | ||
); | ||
Set<String> sectionNames = new HashSet<>(); | ||
Set<String> teamNames = new HashSet<>(); | ||
students.forEach(student -> { | ||
sectionNames.add(student.getSectionName()); | ||
teamNames.add(student.getTeamName()); | ||
}); | ||
detailsPage.verifyCourseDetails(course, instructors, sectionNames.size(), teamNames.size(), students.size()); | ||
detailsPage.verifyNumStudents(students.size()); | ||
detailsPage.verifyStudentDetails(students); | ||
|
||
______TS("link: view student details page"); | ||
Student studentToView = testData.students.get("[email protected]"); | ||
InstructorCourseStudentDetailsViewPage studentDetailsViewPage = | ||
detailsPage.clickViewStudent(studentToView.getEmail()); | ||
studentDetailsViewPage.verifyIsCorrectPage(course.getId(), studentToView.getEmail()); | ||
studentDetailsViewPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("link: edit student details page"); | ||
InstructorCourseStudentDetailsEditPage studentDetailsEditPage = | ||
detailsPage.clickEditStudent(studentToView.getEmail()); | ||
studentDetailsEditPage.verifyIsCorrectPage(course.getId(), studentToView.getEmail()); | ||
studentDetailsEditPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("link: view all records page"); | ||
InstructorStudentRecordsPage studentRecordsPage = | ||
detailsPage.clickViewAllRecords(studentToView.getEmail()); | ||
studentRecordsPage.verifyIsCorrectPage(course.getId(), studentToView.getName()); | ||
studentRecordsPage.closeCurrentWindowAndSwitchToParentWindow(); | ||
|
||
______TS("send invite"); | ||
detailsPage.sendInvite(student3.getEmail()); | ||
detailsPage.verifyStatusMessage("An email has been sent to " + student3.getEmail()); | ||
String expectedEmailSubject = "TEAMMATES: Invitation to join course [" | ||
+ course.getName() + "][Course ID: " + course.getId() + "]"; | ||
verifyEmailSent(student3.getEmail(), expectedEmailSubject); | ||
|
||
______TS("remind all students to join"); | ||
detailsPage.remindAllToJoin(); | ||
detailsPage.verifyStatusMessage("Emails have been sent to unregistered students."); | ||
verifyEmailSent(student3.getEmail(), expectedEmailSubject); | ||
|
||
______TS("download student list"); | ||
detailsPage.downloadStudentList(); | ||
String status = "Yet to Join"; | ||
String[] studentInfo = { student3.getTeamName(), student3.getName(), status, student3.getEmail() }; | ||
List<String> expectedContent = Arrays.asList("Course ID," + course.getId(), | ||
"Course Name," + course.getName(), String.join(",", studentInfo)); | ||
verifyDownloadedFile(downloadedFileName, expectedContent); | ||
|
||
______TS("delete student"); | ||
detailsPage.sortByName(); | ||
detailsPage.sortByStatus(); | ||
List<Student> studentsAfterDelete = Arrays.asList( | ||
testData.students.get("[email protected]"), | ||
testData.students.get("[email protected]"), | ||
testData.students.get("[email protected]") | ||
); | ||
detailsPage.deleteStudent(student3.getEmail()); | ||
detailsPage.verifyStatusMessage("Student is successfully deleted from course \"" | ||
+ course.getId() + "\""); | ||
detailsPage.verifyNumStudents(studentsAfterDelete.size()); | ||
detailsPage.verifyStudentDetails(studentsAfterDelete); | ||
verifyAbsentInDatabase(student3); | ||
|
||
______TS("delete all students"); | ||
detailsPage.deleteAllStudents(); | ||
detailsPage.verifyStatusMessage("All the students have been removed from the course"); | ||
detailsPage.verifyNumStudents(0); | ||
studentsAfterDelete.forEach(this::verifyAbsentInDatabase); | ||
} | ||
} |
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.