-
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
* fix GetFeedbackQuestionsAction bug * migrate over getEntity and verifyEquals * migrate FeedbackTextQuestionE2ETesty * fix lint * fix lint --------- Co-authored-by: Wei Qing <[email protected]>
- Loading branch information
1 parent
affcc46
commit fdba184
Showing
9 changed files
with
618 additions
and
21 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
src/e2e/java/teammates/e2e/cases/sql/BaseFeedbackQuestionE2ETest.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,58 @@ | ||
package teammates.e2e.cases.sql; | ||
|
||
import teammates.common.util.AppUrl; | ||
import teammates.common.util.Const; | ||
import teammates.e2e.pageobjects.FeedbackSubmitPage; | ||
import teammates.e2e.pageobjects.InstructorFeedbackEditPage; | ||
import teammates.storage.sqlentity.Course; | ||
import teammates.storage.sqlentity.FeedbackSession; | ||
import teammates.storage.sqlentity.Instructor; | ||
import teammates.storage.sqlentity.Student; | ||
|
||
/** | ||
* Base class for all feedback question related browser tests. | ||
* | ||
* <p>SUT: {@link Const.WebPageURIs#INSTRUCTOR_SESSION_EDIT_PAGE}, {@link Const.WebPageURIs#SESSION_SUBMISSION_PAGE}. | ||
* | ||
* <p>Only UI-intensive operations, e.g. question creation and response submission, are tested separately. | ||
* This is so that if any part of the testing fails (due to regression or inherent instability), only the | ||
* specific test for the specific feedback question needs to be re-run. | ||
* | ||
* <p>For the above reason, viewing feedback responses/results is not considered to be under this test case. | ||
* This is because viewing results is a fast action and combining all question types together under one test case | ||
* will save some testing time. | ||
*/ | ||
public abstract class BaseFeedbackQuestionE2ETest extends BaseE2ETestCase { | ||
Instructor instructor; | ||
Course course; | ||
FeedbackSession feedbackSession; | ||
Student student; | ||
|
||
abstract void testEditPage(); | ||
|
||
abstract void testSubmitPage(); | ||
|
||
InstructorFeedbackEditPage loginToFeedbackEditPage() { | ||
AppUrl url = createFrontendUrl(Const.WebPageURIs.INSTRUCTOR_SESSION_EDIT_PAGE) | ||
.withCourseId(course.getId()) | ||
.withSessionName(feedbackSession.getName()); | ||
|
||
return loginToPage(url, InstructorFeedbackEditPage.class, instructor.getGoogleId()); | ||
} | ||
|
||
FeedbackSubmitPage loginToFeedbackSubmitPage() { | ||
AppUrl url = createFrontendUrl(Const.WebPageURIs.STUDENT_SESSION_SUBMISSION_PAGE) | ||
.withCourseId(student.getCourse().getId()) | ||
.withSessionName(feedbackSession.getName()); | ||
|
||
return loginToPage(url, FeedbackSubmitPage.class, student.getGoogleId()); | ||
} | ||
|
||
FeedbackSubmitPage getFeedbackSubmitPage() { | ||
AppUrl url = createFrontendUrl(Const.WebPageURIs.STUDENT_SESSION_SUBMISSION_PAGE) | ||
.withCourseId(student.getCourse().getId()) | ||
.withSessionName(feedbackSession.getName()); | ||
|
||
return getNewPageInstance(url, FeedbackSubmitPage.class); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
src/e2e/java/teammates/e2e/cases/sql/FeedbackTextQuestionE2ETest.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,111 @@ | ||
package teammates.e2e.cases.sql; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.questions.FeedbackTextQuestionDetails; | ||
import teammates.common.datatransfer.questions.FeedbackTextResponseDetails; | ||
import teammates.e2e.pageobjects.FeedbackSubmitPage; | ||
import teammates.e2e.pageobjects.InstructorFeedbackEditPage; | ||
import teammates.storage.sqlentity.FeedbackQuestion; | ||
import teammates.storage.sqlentity.FeedbackResponse; | ||
import teammates.storage.sqlentity.Instructor; | ||
|
||
/** | ||
* SUT: {@link Const.WebPageURIs#INSTRUCTOR_SESSION_EDIT_PAGE}, {@link Const.WebPageURIs#SESSION_SUBMISSION_PAGE} | ||
* specifically for text questions. | ||
*/ | ||
public class FeedbackTextQuestionE2ETest extends BaseFeedbackQuestionE2ETest { | ||
|
||
@Override | ||
protected void prepareTestData() { | ||
testData = removeAndRestoreDataBundle(loadSqlDataBundle("/FeedbackTextQuestionE2ESqlTest.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"); | ||
FeedbackTextQuestionDetails questionDetails = (FeedbackTextQuestionDetails) loadedQuestion.getQuestionDetailsCopy(); | ||
feedbackEditPage.verifyTextQuestionDetails(1, questionDetails); | ||
|
||
______TS("add new question"); | ||
// add new question exactly like loaded question | ||
loadedQuestion.setQuestionNumber(2); | ||
feedbackEditPage.addTextQuestion(loadedQuestion); | ||
|
||
feedbackEditPage.verifyTextQuestionDetails(2, questionDetails); | ||
verifyPresentInDatabase(loadedQuestion); | ||
|
||
______TS("copy question"); | ||
FeedbackQuestion copiedQuestion = testData.feedbackQuestions.get("qn1ForSecondSession"); | ||
questionDetails = (FeedbackTextQuestionDetails) copiedQuestion.getQuestionDetailsCopy(); | ||
feedbackEditPage.copyQuestion(copiedQuestion.getCourseId(), | ||
copiedQuestion.getQuestionDetailsCopy().getQuestionText()); | ||
copiedQuestion.setQuestionNumber(3); | ||
copiedQuestion.setFeedbackSession(feedbackSession); | ||
|
||
feedbackEditPage.verifyTextQuestionDetails(3, questionDetails); | ||
verifyPresentInDatabase(copiedQuestion); | ||
|
||
______TS("edit question"); | ||
questionDetails.setRecommendedLength(200); | ||
copiedQuestion.setQuestionDetails(questionDetails); | ||
feedbackEditPage.editTextQuestion(3, questionDetails); | ||
|
||
feedbackEditPage.verifyTextQuestionDetails(3, questionDetails); | ||
verifyPresentInDatabase(copiedQuestion); | ||
} | ||
|
||
@Override | ||
protected void testSubmitPage() { | ||
FeedbackSubmitPage feedbackSubmitPage = loginToFeedbackSubmitPage(); | ||
|
||
______TS("verify loaded question"); | ||
FeedbackQuestion question = testData.feedbackQuestions.get("qn1ForFirstSession"); | ||
Instructor receiver = testData.instructors.get("instructor"); | ||
question.setQuestionNumber(1); | ||
feedbackSubmitPage.verifyTextQuestion(1, (FeedbackTextQuestionDetails) question.getQuestionDetailsCopy()); | ||
|
||
______TS("submit response"); | ||
FeedbackResponse response = getResponse(question, receiver, "<p>This is the response for qn 1</p>"); | ||
feedbackSubmitPage.fillTextResponse(1, receiver.getName(), response); | ||
feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// TODO: uncomment when SubmitFeedbackResponse is working | ||
// verifyPresentInDatabase(response); | ||
|
||
// ______TS("check previous response"); | ||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyTextResponse(1, receiver.getName(), response); | ||
|
||
// ______TS("edit response"); | ||
// FeedbackResponse editedResponse = getResponse(question, receiver, "<p><strong>Edited response</strong></p>"); | ||
// feedbackSubmitPage.fillTextResponse(1, receiver.getName(), editedResponse); | ||
// feedbackSubmitPage.clickSubmitQuestionButton(1); | ||
|
||
// feedbackSubmitPage = getFeedbackSubmitPage(); | ||
// feedbackSubmitPage.verifyTextResponse(1, receiver.getName(), response); | ||
// verifyPresentInDatabase(editedResponse); | ||
} | ||
|
||
private FeedbackResponse getResponse(FeedbackQuestion feedbackQuestion, Instructor instructor, String answer) { | ||
FeedbackTextResponseDetails details = new FeedbackTextResponseDetails(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.