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

Add tests to tips example #833

Merged
merged 15 commits into from
Jul 26, 2022
Merged

Add tests to tips example #833

merged 15 commits into from
Jul 26, 2022

Conversation

Etesam913
Copy link
Contributor

@Etesam913 Etesam913 commented Jul 17, 2022

Overview

Adds three cypress end to end tests for the static-react-task-with-tips task example.

  1. 0-static_react_task_with_tips_pre_tip_submission.cy
  2. 1-static_react_task_with_tips_feedback_submission.cy
  3. static_react_task_with_tips_post_tip_submission.cy

Pre-tip submission

This tests if the tips popup can be opened. It does error checking by typing messages that are too long. It also submits three tips and checks if the server response is correct.

Video:

pre-tip-submission.mp4

Feedback submission

Checks if the correct elements are present and submits answers to the two feedback questions in the example.

Video:

feedback-submission.mov

Post-tip submission

After the pre-tip submission test there are three tips that need to be reviewed. Prior to running the post-tip submission test make sure to run python review_tips_for_task.py and accept the first tip and reject the other two tips.

The test checks to see if the first submitted tip from the pre-tip submission test is present.

Video:

post-tip-submission.mov

GitHub action file

Adds a new job to run the cypress test above.

  1. Installs dependencies and uninstalls detoxify(it is too slow for the GitHub action)
  2. Link to local version of mephisto-task and mephisto-worker-addons packages.
  3. Runs the pre-tip submission cypress test and the feedback_submission cypress test
    • The numbers in the file names of these two tests are set the order that the tests are ran in.
  4. Kills the python and node server
    • This is supposed to happen automatically after cypress finishes, but this does not happen so I have to do it manually.
  5. The first two units that are launched are expired by running the expire_all_units.py script
    • Again, this should happen automatically from shutting down the server, but it doesn't seem to happen in the GitHub action.
    • Expiring the units is important because this state is required for the reviewing steps later on.
  6. First and second tips are accepted, while the third tip is rejected.
    • This is done by running the review_tips_for_task.py script.
  7. Second tip is removed by running remove_accepted_tip.py.
  8. Reviews the feedback by running review_feedback_for_task.py
  9. The post-tip submission test is ran

ℹ️ It tests if the tips is loaded and can be opened.
Then it submits three tips and sees if it gets the
correct response.
⏰ Added time to toxicity detection timeout as the test
is not passing reliably in the github action
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 17, 2022
@Etesam913 Etesam913 changed the base branch from main to improve-cli-for-feedback-review July 17, 2022 23:20
@codecov-commenter
Copy link

codecov-commenter commented Jul 17, 2022

Codecov Report

Merging #833 (c8a673d) into main (7201ee5) will decrease coverage by 0.12%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #833      +/-   ##
==========================================
- Coverage   64.61%   64.48%   -0.13%     
==========================================
  Files         107      107              
  Lines        9281     9281              
==========================================
- Hits         5997     5985      -12     
- Misses       3284     3296      +12     
Impacted Files Coverage Δ
...tractions/architects/channels/websocket_channel.py 67.96% <0.00%> (-8.60%) ⬇️
mephisto/data_model/unit.py 77.59% <0.00%> (-0.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7201ee5...c8a673d. Read the comment docs.

@Etesam913 Etesam913 changed the title Add tests to tips example [WIP] Add tests to tips example Jul 18, 2022
Copy link
Contributor

@JackUrb JackUrb left a comment

Choose a reason for hiding this comment

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

Overall the test here seems great, thanks for adding it! One note on the added script

@@ -0,0 +1,24 @@
from mephisto.abstractions.databases.local_database import LocalMephistoDB
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this should go in a gh_actions folder

@Etesam913 Etesam913 changed the base branch from improve-cli-for-feedback-review to main July 21, 2022 17:08
Copy link
Contributor

@pringshia pringshia left a comment

Choose a reason for hiding this comment

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

a few comments, but overall LGTM

pip install -e .
pip uninstall detoxify <<EOF
y
EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

protip: there's a command called yes that you can use here instead:

yes | pip uninstall detoxify

NAME
     yes – be repetitively affirmative

SYNOPSIS
     yes [expletive]

DESCRIPTION
     The yes utility outputs expletive, or, by default, “y”, forever.

cy.get('[data-cy="directions-container"]');
cy.get('[data-cy="task-data-text"]');
cy.get('[data-cy="good-button"]');
cy.get('[data-cy="bad-button"]');
Copy link
Contributor

Choose a reason for hiding this comment

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

i think these could be suffixed with .should('exist') for readability and clearer assertions. this also bakes in some retry semantics...

another option is .should('be.visible') if we want to also check for cases where the element is visible (and not being pushed off screen or hidden by CSS)

Copy link
Contributor

Choose a reason for hiding this comment

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

that said, i realize that .get by itself does error out if the element isn't found, so perhaps it's not as necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't think it is necessary. I mainly use cy.should('not.exist') to check for content that is not on the page, but I don't really know the point of using cy.should('exist')

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah it seems it's redundant, it maybe just indicates intention that an assertion is taking place. i'm fine with keeping it as is


"""
This script should not be used locally.
It is only used in a GitHub action as it does not automatically expire units.
Copy link
Contributor

Choose a reason for hiding this comment

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

this script seems very "one-off"-y. is there no other case we may want to intentionally force expire units? I assume it could be useful? I would consider parametizing the task_name below and having this be a general script?

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'm not aware of any situation outside of the GitHub action where you would want to run a script to expire units. Usually you would expire units by just doing ctrl-c two or three times on your mephisto task.

Copy link
Contributor

Choose a reason for hiding this comment

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

"Force expiring" units is generally done with a cleanup script, which is provider-associated. This only updates the local status, and is a particular anti-pattern outside of the context of eval scripts.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it... if this script is really needed for a test, I guess I'm okay with keeping it then

@Etesam913 Etesam913 merged commit 43d40b2 into main Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants