From b9ccd4fb42a005822ba785a396699cf2a5005cec Mon Sep 17 00:00:00 2001 From: Marques Tye Jia Jun <97437396+marquestye@users.noreply.github.com> Date: Tue, 9 Apr 2024 20:53:50 +0800 Subject: [PATCH] [#12048] Migrate FeedbackNumScaleQuestionE2ETest (#12940) * Migrate num scale e2e * Fix team id * Fix bugs --- .../sql/FeedbackNumScaleQuestionE2ETest.java | 124 ++++++++ .../e2e/pageobjects/FeedbackSubmitPage.java | 13 + .../InstructorFeedbackEditPage.java | 10 + .../FeedbackNumScaleQuestionE2ESqlTest.json | 268 ++++++++++++++++++ src/e2e/resources/testng-e2e-sql.xml | 1 + 5 files changed, 416 insertions(+) create mode 100644 src/e2e/java/teammates/e2e/cases/sql/FeedbackNumScaleQuestionE2ETest.java create mode 100644 src/e2e/resources/data/FeedbackNumScaleQuestionE2ESqlTest.json diff --git a/src/e2e/java/teammates/e2e/cases/sql/FeedbackNumScaleQuestionE2ETest.java b/src/e2e/java/teammates/e2e/cases/sql/FeedbackNumScaleQuestionE2ETest.java new file mode 100644 index 00000000000..61e4fc619be --- /dev/null +++ b/src/e2e/java/teammates/e2e/cases/sql/FeedbackNumScaleQuestionE2ETest.java @@ -0,0 +1,124 @@ +package teammates.e2e.cases.sql; + +import org.testng.annotations.Test; + +import teammates.common.datatransfer.questions.FeedbackNumericalScaleQuestionDetails; +import teammates.common.datatransfer.questions.FeedbackNumericalScaleResponseDetails; +import teammates.e2e.pageobjects.FeedbackSubmitPage; +import teammates.e2e.pageobjects.InstructorFeedbackEditPage; +import teammates.storage.sqlentity.FeedbackQuestion; +import teammates.storage.sqlentity.FeedbackResponse; +import teammates.storage.sqlentity.Student; + +/** + * SUT: {@link Const.WebPageURIs#INSTRUCTOR_SESSION_EDIT_PAGE}, {@link Const.WebPageURIs#SESSION_SUBMISSION_PAGE} + * specifically for NumScale questions. + */ +public class FeedbackNumScaleQuestionE2ETest extends BaseFeedbackQuestionE2ETest { + + @Override + protected void prepareTestData() { + testData = removeAndRestoreDataBundle(loadSqlDataBundle("/FeedbackNumScaleQuestionE2ESqlTest.json")); + + instructor = testData.instructors.get("instructor"); + course = testData.courses.get("course"); + feedbackSession = testData.feedbackSessions.get("openSession"); + student = testData.students.get("alice.tmms@FNumScaleQn.CS2104"); + } + + @Test + @Override + public void testAll() { + testEditPage(); + logout(); + testSubmitPage(); + } + + @Override + protected void testEditPage() { + InstructorFeedbackEditPage feedbackEditPage = loginToFeedbackEditPage(); + + ______TS("verify loaded question"); + FeedbackQuestion loadedQuestion = testData.feedbackQuestions.get("qn1ForFirstSession"); + FeedbackNumericalScaleQuestionDetails questionDetails = + (FeedbackNumericalScaleQuestionDetails) loadedQuestion.getQuestionDetailsCopy(); + feedbackEditPage.verifyNumScaleQuestionDetails(1, questionDetails); + + ______TS("add new question"); + // add new question exactly like loaded question + loadedQuestion.setQuestionNumber(2); + feedbackEditPage.addNumScaleQuestion(loadedQuestion); + feedbackEditPage.waitUntilAnimationFinish(); + + feedbackEditPage.verifyNumScaleQuestionDetails(2, questionDetails); + verifyPresentInDatabase(loadedQuestion); + + ______TS("copy question"); + FeedbackQuestion copiedQuestion = testData.feedbackQuestions.get("qn1ForSecondSession"); + questionDetails = (FeedbackNumericalScaleQuestionDetails) copiedQuestion.getQuestionDetailsCopy(); + feedbackEditPage.copyQuestion(copiedQuestion.getCourseId(), + copiedQuestion.getQuestionDetailsCopy().getQuestionText()); + copiedQuestion.setQuestionNumber(3); + copiedQuestion.setFeedbackSession(feedbackSession); + + feedbackEditPage.verifyNumScaleQuestionDetails(3, questionDetails); + verifyPresentInDatabase(copiedQuestion); + + ______TS("edit question"); + questionDetails = (FeedbackNumericalScaleQuestionDetails) loadedQuestion.getQuestionDetailsCopy(); + FeedbackNumericalScaleQuestionDetails newQuestionDetails = + (FeedbackNumericalScaleQuestionDetails) questionDetails.getDeepCopy(); + newQuestionDetails.setMinScale(0); + newQuestionDetails.setStep(1); + newQuestionDetails.setMaxScale(100); + loadedQuestion.setQuestionDetails(newQuestionDetails); + feedbackEditPage.editNumScaleQuestion(2, newQuestionDetails); + feedbackEditPage.waitForPageToLoad(); + + feedbackEditPage.verifyNumScaleQuestionDetails(2, newQuestionDetails); + verifyPresentInDatabase(loadedQuestion); + + // reset question details to original + loadedQuestion.setQuestionDetails(questionDetails); + } + + @Override + protected void testSubmitPage() { + FeedbackSubmitPage feedbackSubmitPage = loginToFeedbackSubmitPage(); + + ______TS("verify loaded question"); + FeedbackQuestion question = testData.feedbackQuestions.get("qn1ForFirstSession"); + Student receiver = testData.students.get("benny.tmms@FNumScaleQn.CS2104"); + feedbackSubmitPage.verifyNumScaleQuestion(1, receiver.getTeamName(), + (FeedbackNumericalScaleQuestionDetails) question.getQuestionDetailsCopy()); + + ______TS("submit response"); + FeedbackResponse response = getResponse(question, receiver, 5.4); + feedbackSubmitPage.fillNumScaleResponse(1, receiver.getTeamName(), response); + feedbackSubmitPage.clickSubmitQuestionButton(1); + + // TODO: uncomment when SubmitFeedbackResponse is working + // verifyPresentInDatabase(response); + + // ______TS("check previous response"); + // feedbackSubmitPage = getFeedbackSubmitPage(); + // feedbackSubmitPage.verifyNumScaleResponse(1, receiver.getTeamName(), response); + + // ______TS("edit response"); + // response = getResponse(question, receiver, 10.0); + // feedbackSubmitPage.fillNumScaleResponse(1, receiver.getTeamName(), response); + // feedbackSubmitPage.clickSubmitQuestionButton(1); + + // feedbackSubmitPage = getFeedbackSubmitPage(); + // feedbackSubmitPage.verifyNumScaleResponse(1, receiver.getTeamName(), response); + // verifyPresentInDatabase(response); + } + + private FeedbackResponse getResponse(FeedbackQuestion feedbackQuestion, Student receiver, Double answer) { + FeedbackNumericalScaleResponseDetails details = new FeedbackNumericalScaleResponseDetails(); + details.setAnswer(answer); + return FeedbackResponse.makeResponse( + feedbackQuestion, student.getEmail(), null, receiver.getTeamName(), null, details); + } + +} diff --git a/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java b/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java index e32bbcaaa96..11911490a04 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java @@ -392,6 +392,12 @@ public void fillNumScaleResponse(int qnNumber, String recipient, FeedbackRespons fillTextBox(getNumScaleInput(qnNumber, recipient), Double.toString(responseDetails.getAnswer())); } + public void fillNumScaleResponse(int qnNumber, String recipient, FeedbackResponse response) { + FeedbackNumericalScaleResponseDetails responseDetails = + (FeedbackNumericalScaleResponseDetails) response.getFeedbackResponseDetailsCopy(); + fillTextBox(getNumScaleInput(qnNumber, recipient), Double.toString(responseDetails.getAnswer())); + } + public void verifyNumScaleResponse(int qnNumber, String recipient, FeedbackResponseAttributes response) { FeedbackNumericalScaleResponseDetails responseDetails = (FeedbackNumericalScaleResponseDetails) response.getResponseDetailsCopy(); @@ -399,6 +405,13 @@ public void verifyNumScaleResponse(int qnNumber, String recipient, FeedbackRespo getDoubleString(responseDetails.getAnswer())); } + public void verifyNumScaleResponse(int qnNumber, String recipient, FeedbackResponse response) { + FeedbackNumericalScaleResponseDetails responseDetails = + (FeedbackNumericalScaleResponseDetails) response.getFeedbackResponseDetailsCopy(); + assertEquals(getNumScaleInput(qnNumber, recipient).getAttribute("value"), + getDoubleString(responseDetails.getAnswer())); + } + public void verifyConstSumQuestion(int qnNumber, String recipient, FeedbackConstantSumQuestionDetails questionDetails) { if (!questionDetails.isDistributeToRecipients()) { diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java index f104afcc7ba..8c824ccc1d7 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java @@ -674,6 +674,16 @@ public void addNumScaleQuestion(FeedbackQuestionAttributes feedbackQuestion) { clickSaveNewQuestionButton(); } + public void addNumScaleQuestion(FeedbackQuestion feedbackQuestion) { + addNewQuestion(5); + int questionNum = getNumQuestions(); + inputQuestionDetails(questionNum, feedbackQuestion); + FeedbackNumericalScaleQuestionDetails questionDetails = + (FeedbackNumericalScaleQuestionDetails) feedbackQuestion.getQuestionDetailsCopy(); + inputNumScaleDetails(questionNum, questionDetails); + clickSaveNewQuestionButton(); + } + public void editNumScaleQuestion(int questionNum, FeedbackNumericalScaleQuestionDetails questionDetails) { clickEditQuestionButton(questionNum); inputNumScaleDetails(questionNum, questionDetails); diff --git a/src/e2e/resources/data/FeedbackNumScaleQuestionE2ESqlTest.json b/src/e2e/resources/data/FeedbackNumScaleQuestionE2ESqlTest.json new file mode 100644 index 00000000000..908ecff638c --- /dev/null +++ b/src/e2e/resources/data/FeedbackNumScaleQuestionE2ESqlTest.json @@ -0,0 +1,268 @@ +{ + "accounts": { + "instructorWithSessions": { + "googleId": "tm.e2e.FNumScaleQn.instructor", + "name": "Teammates Test", + "email": "tmms.test@gmail.tmt", + "id": "00000000-0000-4000-8000-000000000001" + }, + "tm.e2e.FNumScaleQn.alice.tmms": { + "googleId": "tm.e2e.FNumScaleQn.alice.tmms", + "name": "Alice Betsy", + "email": "alice.b.tmms@gmail.tmt", + "id": "00000000-0000-4000-8000-000000000002" + } + }, + "accountRequests": {}, + "courses": { + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104", + "name": "Programming Language Concepts", + "institute": "TEAMMATES Test Institute 1", + "timeZone": "Africa/Johannesburg" + }, + "course2": { + "id": "tm.e2e.FNumScaleQn.CS1101", + "name": "Programming Methodology", + "institute": "TEAMMATES Test Institute 1", + "timeZone": "Africa/Johannesburg" + } + }, + "instructors": { + "instructor": { + "account": { + "id": "00000000-0000-4000-8000-000000000001" + }, + "name": "Teammates Test", + "email": "tmms.test@gmail.tmt", + "role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER", + "isDisplayedToStudents": true, + "privileges": { + "courseLevel": { + "canViewStudentInSections": true, + "canSubmitSessionInSections": true, + "canModifySessionCommentsInSections": true, + "canModifyCourse": true, + "canViewSessionInSections": true, + "canModifySession": true, + "canModifyStudent": true, + "canModifyInstructor": true + }, + "sectionLevel": {}, + "sessionLevel": {} + }, + "id": "00000000-0000-4000-8000-000000000501", + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "displayName": "Co-owner" + }, + "instructor2": { + "account": { + "id": "00000000-0000-4000-8000-000000000001" + }, + "name": "Teammates Test", + "email": "tmms.test@gmail.tmt", + "role": "INSTRUCTOR_PERMISSION_ROLE_COOWNER", + "isDisplayedToStudents": true, + "privileges": { + "courseLevel": { + "canViewStudentInSections": true, + "canSubmitSessionInSections": true, + "canModifySessionCommentsInSections": true, + "canModifyCourse": true, + "canViewSessionInSections": true, + "canModifySession": true, + "canModifyStudent": true, + "canModifyInstructor": true + }, + "sectionLevel": {}, + "sessionLevel": {} + }, + "id": "00000000-0000-4000-8000-000000000502", + "course": { + "id": "tm.e2e.FNumScaleQn.CS1101" + }, + "displayName": "Co-owner" + } + }, + "sections": { + "ProgrammingLanguageConceptsNone": { + "id": "00000000-0000-4000-8000-000000000101", + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "name": "None" + }, + "ProgrammingMethodologyNone": { + "id": "00000000-0000-4000-8000-000000000102", + "course": { + "id": "tm.e2e.FNumScaleQn.CS1101" + }, + "name": "None" + } + }, + "teams": { + "ProgrammingLanguageConceptsTeam1": { + "id": "00000000-0000-4000-8000-000000000201", + "section": { + "id": "00000000-0000-4000-8000-000000000101" + }, + "name": "Team 1" + }, + "ProgrammingLanguageConceptsTeam2": { + "id": "00000000-0000-4000-8000-000000000202", + "section": { + "id": "00000000-0000-4000-8000-000000000101" + }, + "name": "Team 2" + }, + "ProgrammingMethodologyTeam1": { + "id": "00000000-0000-4000-8000-000000000203", + "section": { + "id": "00000000-0000-4000-8000-000000000102" + }, + "name": "Team 1" + } + }, + "feedbackSessions": { + "openSession": { + "creatorEmail": "tmms.test@gmail.tmt", + "instructions": "
Instructions for first session
", + "createdTime": "2012-04-01T23:59:00Z", + "startTime": "2012-04-01T22:00:00Z", + "endTime": "2026-04-30T22:00:00Z", + "sessionVisibleFromTime": "2012-04-01T22:00:00Z", + "resultsVisibleFromTime": "2026-05-01T22:00:00Z", + "timeZone": "Africa/Johannesburg", + "gracePeriod": 10, + "sentOpenEmail": false, + "sentClosingEmail": false, + "sentClosedEmail": false, + "sentPublishedEmail": false, + "isOpeningEmailEnabled": true, + "isClosingEmailEnabled": true, + "isPublishedEmailEnabled": true, + "studentDeadlines": {}, + "instructorDeadlines": {}, + "id": "00000000-0000-4000-8000-000000000701", + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "name": "First Session" + }, + "openSession2": { + "creatorEmail": "tmms.test@gmail.tmt", + "instructions": "Instructions for second session
", + "createdTime": "2012-04-01T23:59:00Z", + "startTime": "2012-04-01T22:00:00Z", + "endTime": "2026-04-30T22:00:00Z", + "sessionVisibleFromTime": "2012-04-01T22:00:00Z", + "resultsVisibleFromTime": "2026-05-01T22:00:00Z", + "timeZone": "Africa/Johannesburg", + "gracePeriod": 10, + "sentOpenEmail": false, + "sentClosingEmail": false, + "sentClosedEmail": false, + "sentPublishedEmail": false, + "isOpeningEmailEnabled": true, + "isClosingEmailEnabled": true, + "isPublishedEmailEnabled": true, + "studentDeadlines": {}, + "instructorDeadlines": {}, + "id": "00000000-0000-4000-8000-000000000702", + "course": { + "id": "tm.e2e.FNumScaleQn.CS1101" + }, + "name": "Second Session" + } + }, + "feedbackQuestions": { + "qn1ForFirstSession": { + "id": "00000000-0000-4000-8000-000000000801", + "feedbackSession": { + "id": "00000000-0000-4000-8000-000000000701" + }, + "questionDetails": { + "questionType": "NUMSCALE", + "questionText": "Rate this team's product", + "minScale": 0, + "maxScale": 10, + "step": 0.2 + }, + "description": "Testing description for first session
", + "questionNumber": 1, + "giverType": "STUDENTS", + "recipientType": "TEAMS_EXCLUDING_SELF", + "numOfEntitiesToGiveFeedbackTo": 1, + "showResponsesTo": ["INSTRUCTORS", "RECEIVER"], + "showGiverNameTo": ["INSTRUCTORS"], + "showRecipientNameTo": ["INSTRUCTORS", "RECEIVER"] + }, + "qn1ForSecondSession": { + "id": "00000000-0000-4000-8000-000000000802", + "feedbackSession": { + "id": "00000000-0000-4000-8000-000000000702" + }, + "questionDetails": { + "questionType": "NUMSCALE", + "questionText": "Rate this team's teamwork", + "minScale": 1, + "maxScale": 10, + "step": 0.005 + }, + "description": "Testing description for second session
", + "questionNumber": 1, + "giverType": "STUDENTS", + "recipientType": "TEAMS_EXCLUDING_SELF", + "numOfEntitiesToGiveFeedbackTo": 1, + "showResponsesTo": ["INSTRUCTORS", "RECEIVER"], + "showGiverNameTo": ["INSTRUCTORS"], + "showRecipientNameTo": ["INSTRUCTORS", "RECEIVER"] + } + }, + "notifications": {}, + "readNotifications": {}, + "feedbackResponseComments": {}, + "students": { + "alice.tmms@FNumScaleQn.CS2104": { + "id": "00000000-0000-4000-8000-000000000601", + "account": { + "id": "00000000-0000-4000-8000-000000000002" + }, + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "team": { + "id": "00000000-0000-4000-8000-000000000201" + }, + "email": "alice.b.tmms@gmail.tmt", + "name": "Alice Betsy", + "comments": "This student's name is Alice Betsy" + }, + "benny.tmms@FNumScaleQn.CS2104": { + "id": "00000000-0000-4000-8000-000000000602", + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "team": { + "id": "00000000-0000-4000-8000-000000000202" + }, + "email": "benny.tmms@gmail.tmt", + "name": "Benny Charles", + "comments": "This student's name is Benny Charles" + }, + "charlie.tmms@FNumScaleQn.CS1101": { + "id": "00000000-0000-4000-8000-000000000603", + "course": { + "id": "tm.e2e.FNumScaleQn.CS1101" + }, + "team": { + "id": "00000000-0000-4000-8000-000000000203" + }, + "email": "charlie.tmms@gmail.tmt", + "name": "Charlie Davis", + "comments": "This student's name is Charlie Davis" + } + } +} diff --git a/src/e2e/resources/testng-e2e-sql.xml b/src/e2e/resources/testng-e2e-sql.xml index 40e4bedfad9..61cc506ff93 100644 --- a/src/e2e/resources/testng-e2e-sql.xml +++ b/src/e2e/resources/testng-e2e-sql.xml @@ -9,6 +9,7 @@