-
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
* Initial commit * Fix lint * Follow convention and add test * Change file path * Fix requested changes * Fixed testcases * Fix lint * Add deepcopy * Fixed e2e test --------- Co-authored-by: Wei Qing <[email protected]> Co-authored-by: Cedric Ong <[email protected]>
- Loading branch information
1 parent
11b8b81
commit 0cfadef
Showing
6 changed files
with
477 additions
and
4 deletions.
There are no files selected for viewing
128 changes: 128 additions & 0 deletions
128
src/e2e/java/teammates/e2e/cases/sql/FeedbackRankOptionQuestionE2ETest.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,128 @@ | ||
package teammates.e2e.cases.sql; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.questions.FeedbackRankOptionsQuestionDetails; | ||
import teammates.common.datatransfer.questions.FeedbackRankOptionsResponseDetails; | ||
import teammates.common.datatransfer.questions.FeedbackRankQuestionDetails; | ||
import teammates.common.util.Const; | ||
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 RankOption questions. | ||
*/ | ||
public class FeedbackRankOptionQuestionE2ETest extends BaseFeedbackQuestionE2ETest { | ||
|
||
@Override | ||
protected void prepareTestData() { | ||
testData = removeAndRestoreDataBundle(loadSqlDataBundle("/FeedbackRankOptionQuestionE2ESqlTest.json")); | ||
|
||
instructor = testData.instructors.get("instructor"); | ||
course = testData.courses.get("course"); | ||
feedbackSession = testData.feedbackSessions.get("openSession"); | ||
student = testData.students.get("[email protected]"); | ||
} | ||
|
||
@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") | ||
.makeDeepCopy(feedbackSession); | ||
FeedbackRankOptionsQuestionDetails questionDetails = (FeedbackRankOptionsQuestionDetails) loadedQuestion | ||
.getQuestionDetailsCopy(); | ||
feedbackEditPage.verifyRankQuestionDetails(1, questionDetails); | ||
|
||
______TS("add new question"); | ||
// add new question exactly like loaded question | ||
loadedQuestion.setQuestionNumber(2); | ||
feedbackEditPage.addRankOptionsQuestion(loadedQuestion); | ||
|
||
feedbackEditPage.verifyRankQuestionDetails(2, questionDetails); | ||
verifyPresentInDatabase(loadedQuestion); | ||
|
||
______TS("copy question"); | ||
FeedbackQuestion copiedQuestion = testData.feedbackQuestions.get("qn1ForSecondSession"); | ||
questionDetails = (FeedbackRankOptionsQuestionDetails) copiedQuestion.getQuestionDetailsCopy(); | ||
feedbackEditPage.copyQuestion(copiedQuestion.getCourseId(), | ||
copiedQuestion.getQuestionDetailsCopy().getQuestionText()); | ||
copiedQuestion.setFeedbackSession(feedbackSession); | ||
copiedQuestion.setQuestionNumber(3); | ||
|
||
feedbackEditPage.verifyRankQuestionDetails(3, questionDetails); | ||
verifyPresentInDatabase(copiedQuestion); | ||
|
||
______TS("edit question"); | ||
questionDetails = (FeedbackRankOptionsQuestionDetails) loadedQuestion.getQuestionDetailsCopy(); | ||
List<String> options = questionDetails.getOptions(); | ||
options.remove(0); | ||
options.set(1, "Edited option."); | ||
questionDetails.setOptions(options); | ||
questionDetails.setAreDuplicatesAllowed(true); | ||
questionDetails.setMaxOptionsToBeRanked(Const.POINTS_NO_VALUE); | ||
questionDetails.setMinOptionsToBeRanked(1); | ||
loadedQuestion.setQuestionDetails(questionDetails); | ||
feedbackEditPage.editRankQuestion(2, questionDetails); | ||
feedbackEditPage.waitForPageToLoad(); | ||
|
||
feedbackEditPage.verifyRankQuestionDetails(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("[email protected]"); | ||
feedbackSubmitPage.verifyRankQuestion(1, receiver.getName(), | ||
(FeedbackRankQuestionDetails) question.getQuestionDetailsCopy()); | ||
|
||
______TS("submit response"); | ||
FeedbackResponse response = getResponse(question, receiver, Arrays.asList(2, 1, 3, | ||
Const.POINTS_NOT_SUBMITTED)); | ||
feedbackSubmitPage.fillRankOptionResponse(1, receiver.getName(), response); | ||
feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// verifyPresentInDatabase(response); | ||
|
||
// ______TS("check previous response"); | ||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyRankOptionResponse(1, receiver.getName(), response); | ||
|
||
// ______TS("edit response"); | ||
// response = getResponse(questionId, receiver, | ||
// Arrays.asList(Const.POINTS_NOT_SUBMITTED, 1, 3, 2)); | ||
// feedbackSubmitPage.fillRankOptionResponse(1, receiver.getName(), response); | ||
// feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyRankOptionResponse(1, receiver.getName(), response); | ||
// verifyPresentInDatabase(response); | ||
} | ||
|
||
private FeedbackResponse getResponse(FeedbackQuestion question, Student receiver, List<Integer> answers) { | ||
FeedbackRankOptionsResponseDetails details = new FeedbackRankOptionsResponseDetails(); | ||
details.setAnswers(answers); | ||
return FeedbackResponse.makeResponse(question, student.getEmail(), null, receiver.getEmail(), null, details); | ||
} | ||
} |
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
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.