Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#9536] Instructor Feedback Sessions Page E2E Test #10521

Merged
merged 15 commits into from
Aug 19, 2020

Conversation

jtankw3
Copy link
Contributor

@jtankw3 jtankw3 commented Aug 2, 2020

Part of #9536

Outline of Solution

  • Add methods to BaseE2ETestCase to verify downloaded files exist
  • Add methods to BaseE2ETestCase to compare emails sent
  • Add InstructorFeedbackSessionsPage to represent instructor sessions page
  • Add relevant backdoor methods to compare feedback session data in datastore
  • Add InstructorFeedbackSessionsPageE2ETest to test:
    • verify loaded data
    • verify response rate
    • add new session
    • add new copied session
    • copy session
    • publish results
    • send reminder email
    • resend results link
    • unpublish results
    • download results
    • soft delete session
    • restore session
    • permanently delete session
    • restore all session
    • delete all session

@jtankw3 jtankw3 added the s.ToReview The PR is waiting for review(s) label Aug 2, 2020
@rrtheonlyone rrtheonlyone self-assigned this Aug 8, 2020
…instructor-sessions-e2e

# Conflicts:
#	src/web/app/components/session-edit-form/session-edit-form.component.html
#	src/web/app/components/sessions-recycle-bin-table/sessions-recycle-bin-table.component.html
#	src/web/app/pages-instructor/instructor-sessions-page/instructor-sessions-page.component.html
…instructor-sessions-e2e

# Conflicts:
#	src/e2e/java/teammates/e2e/pageobjects/AppPage.java
#	src/e2e/java/teammates/e2e/util/BackDoor.java
#	src/e2e/resources/testng-e2e.xml
#	src/test/java/teammates/test/cases/BaseTestCaseWithDatastoreAccess.java
#	src/web/app/components/session-edit-form/session-edit-form.component.html
try {
String expectedFilePath = getTestResultsFolder() + expectedFileName;
String actualFilePath = getTestDownloadsFolder() + actualFileName;
assertEquals(FileHelper.readFile(expectedFilePath), FileHelper.readFile(actualFilePath));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but we don't really need to do a full check (otherwise we need to also maintain these test files). Just doing a quick sanity check (file name and maybe a few representative lines) is good enough.

Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done in general, some changes suggested.

while (!actual && retryLimit > 0) {
retryLimit--;
ThreadHelper.waitFor(1000);
actual = emailAccount.isEmailWithSubjectPresent(subject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen a lot of this kind of operation, and it's not just on this PR. Is it possible to build some kind of abstraction for them? Or perhaps use the RetryManager class? But don't need to do on this PR.


______TS("download results");
feedbackSessionsPage.downloadResults(openSession);
ThreadHelper.waitFor(5000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use retries here, where the success condition is the existence of downloaded file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it to the verifyDownloadedFile method

.stream()
.filter(fs -> fs.getFeedbackSessionName().equals(feedbackSessionName))
.findFirst()
.orElse(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is because I realized it is the only method with a different indentation level. Should I not include it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should normally count as unrelated change, but I can close one eye.


if (feedbackSession == null) {
return new JsonResult("No feedback session with name " + feedbackSessionName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

protected void verifyDownloadedFile(String expectedContent, String expectedFileName) {
try {
String filePath = getTestDownloadsFolder() + expectedFileName;
assertTrue(FileHelper.readFile(filePath).contains(expectedContent));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, just checking one line may not be enough. Let's make expectedContent a list.

…instructor-sessions-e2e

# Conflicts:
#	src/web/app/components/sessions-table/__snapshots__/sessions-table.component.spec.ts.snap
#	src/web/app/components/sessions-table/sessions-table.component.html
#	src/web/app/pages-instructor/instructor-home-page/__snapshots__/instructor-home-page.component.spec.ts.snap
Copy link
Member

@wkurniawan07 wkurniawan07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

.stream()
.filter(fs -> fs.getFeedbackSessionName().equals(feedbackSessionName))
.findFirst()
.orElse(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should normally count as unrelated change, but I can close one eye.

@wkurniawan07 wkurniawan07 added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging and removed s.ToReview The PR is waiting for review(s) labels Aug 19, 2020
@jtankw3 jtankw3 merged commit 1ebe7a9 into TEAMMATES:master Aug 19, 2020
@jtankw3 jtankw3 deleted the instructor-sessions-e2e branch August 19, 2020 04:45
@madanalogy madanalogy added this to the v7.0.1 milestone Aug 22, 2020
@madanalogy madanalogy added the c.Feature User-facing feature; can be new feature or enhancement to existing feature label Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Feature User-facing feature; can be new feature or enhancement to existing feature s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants