From aa60ac88670914490d67842cbd861627a22b648e Mon Sep 17 00:00:00 2001 From: marquestye Date: Tue, 26 Mar 2024 17:42:10 +0800 Subject: [PATCH] Migrate num scale e2e --- .../sql/FeedbackNumScaleQuestionE2ETest.java | 119 ++++++++++ .../e2e/pageobjects/FeedbackSubmitPage.java | 13 ++ .../InstructorFeedbackEditPage.java | 10 + .../FeedbackNumScaleQuestionE2ESqlTest.json | 214 ++++++++++++++++++ src/e2e/resources/testng-e2e-sql.xml | 1 + 5 files changed, 357 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..b22fcfd1366 --- /dev/null +++ b/src/e2e/java/teammates/e2e/cases/sql/FeedbackNumScaleQuestionE2ETest.java @@ -0,0 +1,119 @@ +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(); + questionDetails.setMinScale(0); + questionDetails.setStep(1); + questionDetails.setMaxScale(100); + loadedQuestion.setQuestionDetails(questionDetails); + feedbackEditPage.editNumScaleQuestion(2, questionDetails); + feedbackEditPage.waitForPageToLoad(); + + feedbackEditPage.verifyNumScaleQuestionDetails(2, questionDetails); + verifyPresentInDatabase(loadedQuestion); + } + + @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 33f3215d638..fbe6ac54156 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java @@ -332,6 +332,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(); @@ -339,6 +345,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 0b9c3b02b37..dc88a5031f6 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorFeedbackEditPage.java @@ -656,6 +656,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..42bcea34e08 --- /dev/null +++ b/src/e2e/resources/data/FeedbackNumScaleQuestionE2ESqlTest.json @@ -0,0 +1,214 @@ +{ + "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" + } + }, + "sections": { + "ProgrammingLanguageConceptsNone": { + "id": "00000000-0000-4000-8000-000000000101", + "course": { + "id": "tm.e2e.FNumScaleQn.CS2104" + }, + "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-000000000201", + "section": { + "id": "00000000-0000-4000-8000-000000000101" + }, + "name": "Team 2" + } + }, + "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" + } + } +} diff --git a/src/e2e/resources/testng-e2e-sql.xml b/src/e2e/resources/testng-e2e-sql.xml index ed13cbf44f1..e609a1ac796 100644 --- a/src/e2e/resources/testng-e2e-sql.xml +++ b/src/e2e/resources/testng-e2e-sql.xml @@ -7,6 +7,7 @@ +