Skip to content

chore: add e2e #789

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

Merged
merged 15 commits into from
Nov 15, 2021
Merged

chore: add e2e #789

merged 15 commits into from
Nov 15, 2021

Conversation

tiffafoo
Copy link

@tiffafoo tiffafoo commented Nov 11, 2021

Summary

Add tests for the plugin. Tests for other demo sites (basepath, nx, and more) will follow

  • Default site
  • Preview mode
  • i18n
  • Headers
  • Rewrites/redirects
  • Trailing slash
  • Catch-all/optional catch-all, getxxprops
  • Images
  • Dynamic imports
  • Custom 404/500
  • Static assets in public
  • cookie header locale issue

Test plan

Visit deploy logs to see it being run with the plugin otherwise:

  1. Checkout this branch
  2. Run npm i
  3. Run npm run cy:open
  4. Run all tests
  5. Happy

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal (small picture)

https://github.com/netlify/pod-ecosystem-integrations/issues/33

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@tiffafoo tiffafoo changed the title add e2e chore: add e2e Nov 12, 2021
@tiffafoo tiffafoo added the type: chore work needed to keep the product and development running smoothly label Nov 12, 2021
@tiffafoo tiffafoo marked this pull request as ready for review November 12, 2021 16:02
@tiffafoo tiffafoo requested a review from ascorbic November 12, 2021 16:02
ascorbic
ascorbic previously approved these changes Nov 12, 2021
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Woohoo!

package.json Outdated
@@ -10,8 +10,9 @@
"scripts": {
"build:demo": "next build demo",
"cy:open": "cypress open --config-file cypress/config/all.json",
"cy:run": "cypress run --config-file cypress/config/all.json",
"cy:run": "cypress run --config-file ../cypress/config/ci.json",
Copy link
Contributor

Choose a reason for hiding this comment

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

Having this expect to be run from in the demo directory is quite confusing. Is this required?

Copy link
Author

@tiffafoo tiffafoo Nov 12, 2021

Choose a reason for hiding this comment

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

It is required in order to have the paths point to the correct config files in the ci, since ci uses the demo folder as the root, but I can change the command to be named ci:cypress instead so no one tries to run it locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aaah, ok. This being because demo doesn;t have a package.json of its own

// Set a random page between 1 and 100
const randomPage = Math.floor(Math.random() * 100) + 1
// FIXME: stub out in dev
const server = dev ? `https://api.tvmaze.com/shows?page=${randomPage}` : `https://api.tvmaze.com/shows?page=${randomPage}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

You could find the base server so you can load the stub by checking if document is available, and either getting it from there or otherwise seeing if you can get it from context.req

async redirects() {
return [
{
source: '/redirectme',
Copy link
Contributor

Choose a reason for hiding this comment

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

Not one for this PR, but adding a regex-based rewrite would be good

}
)
cy.visit('/previewTest')
cy.findByText('Number: 3')
Copy link
Contributor

Choose a reason for hiding this comment

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

My preview mode PR changes the text here, so this will need an update


it('should show image using next/image', () => {
cy.visit('/image')
cy.findByRole('img', { name: /shiba inu dog looks through a window/i })
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this check if the image actually loads?

Copy link
Author

Choose a reason for hiding this comment

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

Good call, I'll add the same width/height as the other image test

Co-authored-by: Matt Kane <matt.kane@netlify.com>
@tiffafoo tiffafoo enabled auto-merge (squash) November 15, 2021 15:30
@tiffafoo tiffafoo merged commit 327f46a into main Nov 15, 2021
@tiffafoo tiffafoo deleted the tln/add-e2e branch November 15, 2021 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants