-
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
* Migrate MCQ E2E * Fix lint * Fix lint * Update xml --------- Co-authored-by: Cedric Ong <[email protected]>
- Loading branch information
1 parent
0cfadef
commit e51132e
Showing
6 changed files
with
435 additions
and
1 deletion.
There are no files selected for viewing
140 changes: 140 additions & 0 deletions
140
src/e2e/java/teammates/e2e/cases/sql/FeedbackMcqQuestionE2ETest.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,140 @@ | ||
package teammates.e2e.cases.sql; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.questions.FeedbackMcqQuestionDetails; | ||
import teammates.common.datatransfer.questions.FeedbackMcqResponseDetails; | ||
import teammates.e2e.pageobjects.FeedbackSubmitPage; | ||
import teammates.e2e.pageobjects.InstructorFeedbackEditPage; | ||
import teammates.storage.sqlentity.FeedbackQuestion; | ||
import teammates.storage.sqlentity.FeedbackResponse; | ||
|
||
/** | ||
* SUT: {@link Const.WebPageURIs#INSTRUCTOR_SESSION_EDIT_PAGE}, | ||
* {@link Const.WebPageURIs#SESSION_SUBMISSION_PAGE} | ||
* specifically for MCQ questions. | ||
*/ | ||
public class FeedbackMcqQuestionE2ETest extends BaseFeedbackQuestionE2ETest { | ||
|
||
@Override | ||
protected void prepareTestData() { | ||
testData = removeAndRestoreDataBundle(loadSqlDataBundle("/FeedbackMcqQuestionE2ESqlTest.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"); | ||
FeedbackMcqQuestionDetails questionDetails = (FeedbackMcqQuestionDetails) loadedQuestion | ||
.getQuestionDetailsCopy(); | ||
feedbackEditPage.verifyMcqQuestionDetails(1, questionDetails); | ||
|
||
______TS("add new question"); | ||
// add new question exactly like loaded question | ||
loadedQuestion.setQuestionNumber(2); | ||
feedbackEditPage.addMcqQuestion(loadedQuestion); | ||
|
||
feedbackEditPage.verifyMcqQuestionDetails(2, questionDetails); | ||
verifyPresentInDatabase(loadedQuestion); | ||
|
||
______TS("copy question"); | ||
FeedbackQuestion copiedQuestion = testData.feedbackQuestions.get("qn1ForSecondSession"); | ||
questionDetails = (FeedbackMcqQuestionDetails) copiedQuestion.getQuestionDetailsCopy(); | ||
feedbackEditPage.copyQuestion(copiedQuestion.getCourseId(), | ||
copiedQuestion.getQuestionDetailsCopy().getQuestionText()); | ||
copiedQuestion.setFeedbackSession(feedbackSession); | ||
copiedQuestion.setQuestionNumber(3); | ||
|
||
feedbackEditPage.verifyMcqQuestionDetails(3, questionDetails); | ||
verifyPresentInDatabase(copiedQuestion); | ||
|
||
______TS("edit question"); | ||
questionDetails = (FeedbackMcqQuestionDetails) loadedQuestion.getQuestionDetailsCopy(); | ||
questionDetails.setHasAssignedWeights(false); | ||
questionDetails.setMcqWeights(new ArrayList<>()); | ||
questionDetails.setOtherEnabled(false); | ||
questionDetails.setQuestionDropdownEnabled(false); | ||
questionDetails.setMcqOtherWeight(0); | ||
List<String> choices = questionDetails.getMcqChoices(); | ||
choices.add("Edited choice"); | ||
questionDetails.setMcqChoices(choices); | ||
loadedQuestion = testData.feedbackQuestions.get("qn1ForFirstSession").makeDeepCopy(feedbackSession); | ||
loadedQuestion.setQuestionDetails(questionDetails); | ||
feedbackEditPage.editMcqQuestion(2, questionDetails); | ||
feedbackEditPage.waitForPageToLoad(); | ||
|
||
feedbackEditPage.verifyMcqQuestionDetails(2, questionDetails); | ||
verifyPresentInDatabase(loadedQuestion); | ||
} | ||
|
||
@Override | ||
protected void testSubmitPage() { | ||
FeedbackSubmitPage feedbackSubmitPage = loginToFeedbackSubmitPage(); | ||
|
||
______TS("verify loaded question"); | ||
FeedbackQuestion question = testData.feedbackQuestions.get("qn1ForFirstSession"); | ||
feedbackSubmitPage.verifyMcqQuestion(1, "", | ||
(FeedbackMcqQuestionDetails) question.getQuestionDetailsCopy()); | ||
|
||
______TS("verify question with generated options"); | ||
feedbackSubmitPage.verifyGeneratedMcqQuestion(3, "", getGeneratedStudentOptions()); | ||
|
||
______TS("submit response"); | ||
FeedbackResponse response = getResponse(question, false, "UI"); | ||
feedbackSubmitPage.fillMcqResponse(1, "", response); | ||
feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// verifyPresentInDatabase(response); | ||
|
||
// ______TS("check previous response"); | ||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyMcqResponse(1, "", response); | ||
|
||
// ______TS("edit response"); | ||
// response = getResponse(questionId, true, "This is the edited response."); | ||
// feedbackSubmitPage.fillMcqResponse(1, "", response); | ||
// feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyMcqResponse(1, "", response); | ||
// verifyPresentInDatabase(response); | ||
} | ||
|
||
private List<String> getGeneratedStudentOptions() { | ||
return testData.students.values().stream() | ||
.filter(s -> s.getCourse().equals(student.getCourse())) | ||
.map(s -> s.getName() + " (" + s.getTeam().getName() + ")") | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private FeedbackResponse getResponse(FeedbackQuestion feedbackQuestion, boolean isOther, String answer) { | ||
FeedbackMcqResponseDetails details = new FeedbackMcqResponseDetails(); | ||
if (isOther) { | ||
details.setOther(true); | ||
details.setOtherFieldContent(answer); | ||
} else { | ||
details.setAnswer(answer); | ||
} | ||
return FeedbackResponse.makeResponse(feedbackQuestion, student.getEmail(), null, instructor.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.