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

467/add cypress testing #515

Merged
merged 46 commits into from
Mar 8, 2024
Merged

467/add cypress testing #515

merged 46 commits into from
Mar 8, 2024

Conversation

Michael-McFaddin
Copy link
Collaborator

@Michael-McFaddin Michael-McFaddin commented Sep 14, 2023

🤺 Summary

This PR covers the implementation of Cypress E2E testing for the Boilerplate React UI:

  • Installed Cypress

  • Created Cypress test coverage for page-level features & CRUD operations:

  • Categories

  • Funding Orgs

  • Boilerplates

  • Grants, including:

  • Copy Grant

  • Grant Sections

  • Grant Overview (Drag&Drop and Preview features)

  • Paste Boilerplate

There is also an associated API branch that covers the creation of seed data for the tests:
feature/cypress/474-add-cypress-db-seeds-v2

Steps to Test:

  • Make sure that you are checked out to the API branch

  • Run rails db:reset to set/reset the test data

  • Install Cypress:
    npm install cypress

  • Run Cypress:
    npm run cypress:open
    (Make sure both rails and react servers are running :))

  • Run all test files in the e2e directory
    npx cypress run -s cypress/e2e/boilerplate-e2e

  • To run specific files, append the file name
    npx cypress run -s cypress/e2e/boilerplate-e2e/

Cypress runs in a separate browser. It should open automatically, and you should see a browser interface. The landing page offers you a choice between E2E and Component Testing.

image

Once you choose E2E testing, it will ask you to select a browser (we're assuming Chrome).

image

Once you click through to Chrome, you should see an index menu that looks a little bit like the menu for Storybook.js. You will see an index of all of the test files; this index is automatically generated and reflects the Cypress test directories in the codebase. You'll also see directories that contain out of the box examples and test recipes, as well as some scratchpads for DnD; we're keeping those for now:

image

You can run tests by clicking on the individual test files.

Once you start running tests, the UI will show a 'speedrun' of the test operations, as in the app:

image

image

The Cypress browser interface also includes a console on the lefthand side that shows a line by line readout of the test run.

You can step back through each line; the screen should show what is happening during that step, with any selected elements highlighted, etc. You can also open up the line-by-line items in the console to see additional info, like data, selectors, etc.

Test steps that pass will show up in the console as green; if the test hits an error, it will halt and you will see a red console printout.

On the righthand side of the screen, there is also a more conventional devtools console; you can use this to run console.logs, etc.

@socket-security
Copy link

socket-security bot commented Sep 14, 2023

@Michael-McFaddin Michael-McFaddin marked this pull request as ready for review September 30, 2023 00:40
Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSource
Install scripts npm/cypress@12.17.4
  • Install script: postinstall
  • Source: node index.js --exec install

View full report↗︎

Next steps

What is an install script?

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/cypress@12.17.4

@Michael-McFaddin Michael-McFaddin merged commit f322fd8 into develop Mar 8, 2024
2 of 3 checks passed
@Michael-McFaddin Michael-McFaddin deleted the 467/add-cypress-testing branch March 8, 2024 01:58
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.

2 participants