Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12048] Migrate StudentCourseDetailsPageE2ETest #13012

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package teammates.e2e.cases.sql;

import org.testng.annotations.Test;

import teammates.common.util.AppUrl;
import teammates.common.util.Const;
import teammates.e2e.pageobjects.StudentCourseDetailsPage;
import teammates.storage.sqlentity.Instructor;
import teammates.storage.sqlentity.Student;

/**
* SUT: {@link Const.WebPageURIs#STUDENT_COURSE_DETAILS_PAGE}.
*/
public class StudentCourseDetailsPageE2ETest extends BaseE2ETestCase {

@Override
protected void prepareTestData() {
testData = removeAndRestoreDataBundle(
loadSqlDataBundle("/StudentCourseDetailsPageE2ETestSql.json"));
}

@Test
@Override
public void testAll() {

AppUrl url = createFrontendUrl(Const.WebPageURIs.STUDENT_COURSE_DETAILS_PAGE)
.withCourseId("tm.e2e.SCDet.CS2104");
StudentCourseDetailsPage detailsPage = loginToPage(url, StudentCourseDetailsPage.class,
testData.accounts.get("SCDet.alice").getGoogleId());

______TS("verify loaded data");
Instructor[] instructors = { testData.instructors.get("SCDet.instr"),
testData.instructors.get("SCDet.instr2") };
Student[] teammates = { testData.students.get("SCDet.benny"),
testData.students.get("SCDet.charlie") };

detailsPage.verifyCourseDetails(testData.courses.get("SCDet.CS2104"));
detailsPage.verifyInstructorsDetails(instructors);
detailsPage.verifyStudentDetails(testData.students.get("SCDet.alice"));
detailsPage.sortTeammatesByName();
detailsPage.verifyTeammatesDetails(teammates);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import teammates.common.datatransfer.attributes.InstructorAttributes;
import teammates.common.datatransfer.attributes.StudentAttributes;
import teammates.e2e.util.TestProperties;
import teammates.storage.sqlentity.Course;
import teammates.storage.sqlentity.Instructor;
import teammates.storage.sqlentity.Student;

/**
* Page Object Model for student course details page.
Expand Down Expand Up @@ -59,6 +62,12 @@ public void verifyCourseDetails(CourseAttributes courseDetails) {
assertEquals(courseDetails.getInstitute(), courseInstituteField.getText());
}

public void verifyCourseDetails(Course courseDetails) {
assertEquals(courseDetails.getName(), courseNameField.getText());
assertEquals(courseDetails.getId(), courseIdField.getText());
assertEquals(courseDetails.getInstitute(), courseInstituteField.getText());
}

public void verifyInstructorsDetails(InstructorAttributes[] instructorDetails) {
String[] actualInstructors = instructorsList.getText().split(TestProperties.LINE_SEPARATOR);
for (int i = 0; i < instructorDetails.length; i++) {
Expand All @@ -68,13 +77,29 @@ public void verifyInstructorsDetails(InstructorAttributes[] instructorDetails) {
}
}

public void verifyInstructorsDetails(Instructor[] instructorDetails) {
String[] actualInstructors = instructorsList.getText().split(TestProperties.LINE_SEPARATOR);
for (int i = 0; i < instructorDetails.length; i++) {
Instructor expected = instructorDetails[i];
assertEquals(expected.getDisplayName() + ": " + expected.getName() + " (" + expected.getEmail() + ")",
actualInstructors[i]);
}
}

public void verifyStudentDetails(StudentAttributes studentDetails) {
assertEquals(studentDetails.getName(), studentNameField.getText());
assertEquals(studentDetails.getSection(), studentSectionField.getText());
assertEquals(studentDetails.getTeam(), studentTeamField.getText());
assertEquals(studentDetails.getEmail(), studentEmailField.getText());
}

public void verifyStudentDetails(Student studentDetails) {
assertEquals(studentDetails.getName(), studentNameField.getText());
assertEquals(studentDetails.getSectionName(), studentSectionField.getText());
assertEquals(studentDetails.getTeamName(), studentTeamField.getText());
assertEquals(studentDetails.getEmail(), studentEmailField.getText());
}

public void verifyTeammatesDetails(StudentAttributes[] teammates) {
int numTables = teammates.length;

Expand All @@ -89,6 +114,20 @@ public void verifyTeammatesDetails(StudentAttributes[] teammates) {
}
}

public void verifyTeammatesDetails(Student[] teammates) {
int numTables = teammates.length;

for (int i = 0; i < numTables; i++) {
List<String> profileItems = new ArrayList<>();
profileItems.add("Name: " + teammates[i].getName());
profileItems.add("Email: " + teammates[i].getEmail());

WebElement actualProfile = browser.driver.findElement(By.id("teammates-details-" + i));
assertEquals(profileItems.stream().collect(Collectors.joining(TestProperties.LINE_SEPARATOR)),
actualProfile.getText());
}
}

public void sortTeammatesByName() {
click(browser.driver.findElement(By.id("sort-name")));
}
Expand Down
152 changes: 152 additions & 0 deletions src/e2e/resources/data/StudentCourseDetailsPageE2ETestSql.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"accounts": {
"SCDet.instr": {
"googleId": "tm.e2e.SCDet.instr",
"name": "Instructor",
"email": "[email protected]",
"id": "00000000-0000-4000-8000-000000000001"
},
"SCDet.alice": {
"googleId": "tm.e2e.SCDet.alice",
"email": "[email protected]",
"name": "Alice Betsy",
"id": "00000000-0000-4000-8000-000000000002"
}
},
"accountRequests": {},
"courses": {
"SCDet.CS2104": {
"id": "tm.e2e.SCDet.CS2104",
"name": "Programming Language Concepts",
"timeZone": "UTC",
"institute": "TEAMMATES Test Institute 1",
"createdAt": "2012-04-02T11:00:00Z"
}
},
"sections": {
"tm.e2e.SCDet.CS2104-None": {
"id": "00000000-0000-4000-8000-000000000201",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"name": "None"
}
},
"teams": {
"tm.e2e.SCDet.CS2104-None-Team1": {
"id": "00000000-0000-4000-8000-000000000301",
"section": {
"id": "00000000-0000-4000-8000-000000000201"
},
"name": "Team 1"
}
},
"deadlineExtensions": {},
"instructors": {
"SCDet.instr": {
"isDisplayedToStudents": true,
"displayName": "Instructor",
"role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER",
"privileges": {
"courseLevel": {
"canModifyCourse": true,
"canModifyInstructor": true,
"canModifySession": true,
"canModifyStudent": true,
"canViewStudentInSections": true,
"canViewSessionInSections": true,
"canSubmitSessionInSections": true,
"canModifySessionCommentsInSections": true
},
"sectionLevel": {},
"sessionLevel": {}
},
"id": "00000000-0000-4000-8000-000000000501",
"courseId": "tm.e2e.SCDet.CS2104",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"account": {
"id": "00000000-0000-4000-8000-000000000001"
},
"name": "Teammates Test",
"email": "[email protected]"
},
"SCDet.instr2": {
"isDisplayedToStudents": true,
"displayName": "Instructor",
"role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER",
"privileges": {
"courseLevel": {
"canModifyCourse": true,
"canModifyInstructor": true,
"canModifySession": true,
"canModifyStudent": true,
"canViewStudentInSections": true,
"canViewSessionInSections": true,
"canSubmitSessionInSections": true,
"canModifySessionCommentsInSections": true
},
"sectionLevel": {},
"sessionLevel": {}
},
"id": "00000000-0000-4000-8000-000000000502",
"courseId": "tm.e2e.SCDet.CS2104",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"name": "Teammates Test 2",
"email": "[email protected]"
}
},
"students": {
"SCDet.alice": {
"comments": "This student's name is Alice Betsy",
"id": "00000000-0000-4000-8000-000000000601",
"courseId": "tm.e2e.SCDet.CS2104",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"team": {
"id": "00000000-0000-4000-8000-000000000301"
},
"account": {
"id": "00000000-0000-4000-8000-000000000002"
},
"name": "Alice Betsy",
"email": "[email protected]"
},
"SCDet.benny": {
"comments": "This student's name is Benny Charles",
"id": "00000000-0000-4000-8000-000000000602",
"courseId": "tm.e2e.SCDet.CS2104",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"team": {
"id": "00000000-0000-4000-8000-000000000301"
},
"name": "Benny Charles",
"email": "[email protected]"
},
"SCDet.charlie": {
"comments": "This student's name is Charlie Davis",
"id": "00000000-0000-4000-8000-000000000603",
"courseId": "tm.e2e.SCDet.CS2104",
"course": {
"id": "tm.e2e.SCDet.CS2104"
},
"team": {
"id": "00000000-0000-4000-8000-000000000301"
},
"name": "Charlie Davis",
"email": "[email protected]"
}
},
"feedbackSessions": {},
"feedbackQuestions": {},
"feedbackResponses": {},
"feedbackResponseComments": {},
"notifications": {},
"readNotifications": {}
}
1 change: 1 addition & 0 deletions src/e2e/resources/testng-e2e-sql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<class name="teammates.e2e.cases.sql.FeedbackRankOptionQuestionE2ETest" />
<class name="teammates.e2e.cases.sql.InstructorHomePageE2ETest" />
<class name="teammates.e2e.cases.sql.InstructorNotificationsPageE2ETest" />
<class name="teammates.e2e.cases.sql.StudentCourseDetailsPageE2ETest" />
<class name="teammates.e2e.cases.sql.RequestPageE2ETest" />
</classes>
</test>
Expand Down
Loading