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

Cypress testing suite for hidden features / bugs #543

Merged
merged 37 commits into from
Nov 9, 2021

Conversation

willespencer
Copy link
Member

@willespencer willespencer commented Oct 15, 2021

Summary

This pull request adds Cypress front-end tests to test a number of features & bugs that can pop up without devs noticing, especially ones that have happened in the past and could be repeated.

  • Added tests to run through Onboarding and Walkthrough modals as a new user (involves deleting the testing email's firestore data). The walkthrough modal has frequently been modified without noticing (Sort by semester #537) as it only shows up for new users, so having a test will ensure it does not break from a PR without knowing.
  • Added a test to check that CUReviews data is being returned and not 'N/A'. The API has changed in the past without notice, so having this test will let us know in the future if their data or API changes again (Handle updated CUReviews json #123)
  • Added a test to confirm that the "+ New Semester" buttons are mutually exclusive. As brought up in Implement minimize/expand semester feature #536, there are two different buttons depending on if there are semesters in a plan or not for styling reason. This test ensures that two buttons will never show up at once.
  • Added a test to ensure clicking outside modals works as expected, as this functionality often breaks. Also added a check to ensure onboarding cannot be clicked outside for new users (Allow for clicks outside modal to close it #314, [EZ Bug Fix] Close onboarding bug #403)
  • Added a test to confirm the mobile navbar shows up on top of the plan, as there have been frequent z-index issues (Dynamic z index #430)
  • Resolve tests failing because the CI does not have permissions to delete the test user's Firestore data. See solution explanation below

Remaining TODOs:

Test Plan

Confirm that the CI tests pass - this means that all the existing and newly written Cypress tests also pass

Additionally, change the URL used for accessing CUReviews data locally and confirm that Cypress test would fail were CUReviews API to break or change routes.
CUReviews Test

Notes

Resolving the Firestore permissions error took a long time - but the issue ended up being related to the service account secret on GitHub. @SamChou19815 suspects that it was in multiline form which could have been causing the issue of insufficient permissions on the CI. Resetting it fixed the issue, for both using Firestore calls in Cypress, and also when writing separate scripts to edit user data before running cypress (see individual commits).

This new spec file will delete the semester and onboarding collections for the test email, which could affect other tests if this new file does not run completely and these documents are not recreated.

@dti-github-bot
Copy link
Member

dti-github-bot commented Oct 15, 2021

[diff-counting] Significant lines: 269.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 2021

Visit the preview URL for this PR (updated for commit 575bfe7):

https://cornelldti-courseplan-dev--pr543-hidden-feature-unit-swbuk23f.web.app

(expires Tue, 16 Nov 2021 22:12:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@willespencer willespencer changed the title Hidden feature unit testing Cypress testing suite for hidden features / bugs Oct 15, 2021
@zachary-kent zachary-kent marked this pull request as ready for review November 1, 2021 00:58
@zachary-kent zachary-kent requested a review from a team as a code owner November 1, 2021 00:58
Copy link
Contributor

@SamChou19815 SamChou19815 left a comment

Choose a reason for hiding this comment

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

O9vpKoN

@willespencer willespencer requested review from hahnbeelee, benjamin-shen and a team November 9, 2021 15:48
Copy link
Collaborator

@benjamin-shen benjamin-shen left a comment

Choose a reason for hiding this comment

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

YAY!!!!! amazing 🌟

// Test to confirm that only one "+New Semester" button shows up at once
// Due to front-end styling issues, there are two different buttons in different components
// Only one should be visible at a time (from semesterView if there are 0 semesters, from semester otherwise)
it('Test that only one semester button shows', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to have this test be perpetual (i.e. throughout the other tests, ensure the invariant holds) rather than for one specific set of steps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! I think I can add an afterEach hook to run it after every test that we have. It will require reworking things a bit, so the test only checks for buttons and does not actually click anything, and also needs to ensure that the site is in a state where this can be checked. Adding it to my other item!

Copy link
Collaborator

@benjamin-shen benjamin-shen Nov 9, 2021

Choose a reason for hiding this comment

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

and also needs to ensure that the site is in a state where this can be checked.

I think this can just be done by making the invariant "there is max 1 button" instead of "there is exactly 1 button". So if no buttons exist, the test passes.

"There is exactly 1 button" is not an invariant and not related to the bug itself so it can be another test if we want.

cy.visit('localhost:8080/login');
cy.login(Cypress.env('TEST_UID'));

const TEST_EMAIL = '[email protected]';
Copy link
Collaborator

Choose a reason for hiding this comment

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

😍
Should we refactor this Firestore reset and call it for every integration test?
Or at least store TEST_EMAIL in a constants file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Going to put TEST_EMAIL in a constants file now!

Copy link
Member Author

Choose a reason for hiding this comment

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

I however do not think we want to do the Firestore reset in every integration test because then we have to go through Onboarding/walkthrough every time. It might make sense though to do a more simple data reset (instead of deleting data, set to only required/basic data) so that tests are not reliant on each other. Making an item for this!

Copy link
Contributor

@hahnbeelee hahnbeelee left a comment

Choose a reason for hiding this comment

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

This is truly amazing. I appreciate this so much! This is truly your baby. Looks amazing and I'm glad we have these reinsure these basic things don't break.

@hahnbeelee
Copy link
Contributor

hahnbeelee commented Nov 9, 2021

^ also went through the entire test plan and everything worked as expected:

  • tests ran perfectly
  • changed the url for CUReviews & it broke (then i changed it back and it was back to normal)
  • Looked through the code and i don't have any comments about it - seemed quite straight forward to me.

@willespencer willespencer merged commit 7471be6 into master Nov 9, 2021
@willespencer willespencer deleted the hidden-feature-unit-testing branch November 9, 2021 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants