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

chore(e2e-dev-runtime): bump @testing-library/cypress and adjust current data updates testing setup #26500

Merged
merged 3 commits into from Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,17 +15,17 @@ describe(`Gatsby Preview (Updating)`, () => {
it(`displays initial data`, () => {
cy.get(`li:eq(0) a`).click().waitForRouteChange()

cy.queryByText(`Hello World (1)`).should(`exist`)
cy.findByText(`Hello World (1)`).should(`exist`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's one of breaking changes in @testing-library/cypress@6 - https://github.com/testing-library/cypress-testing-library/releases/tag/v6.0.0

This comment applies to all replacements like that here


cy.queryByText(`0`).should(`exist`)
cy.findByText(`0`).should(`exist`)
})

it(`updates and hot-reloads changes to content`, () => {
cy.get(`li:eq(0) a`).click().waitForRouteChange()

update()

cy.queryByText(`1`).should(`exist`)
cy.findByText(`1`).should(`exist`)
})

it(`updates and hot-reloads new content`, () => {
Expand All @@ -45,13 +45,9 @@ describe(`Gatsby Preview (Updating)`, () => {
cy.get(`li`).its(`length`).should(`be`, 1)
})

/*
* TODO: get this test passing in CI
* https://github.com/testing-library/cypress-testing-library/issues/23
*/
it.skip(`can be triggered with webhook data`, () => {
it(`can be triggered with webhook data`, () => {
cy.exec(`npm run update:webhook`)

cy.queryByText(`Hello World from a Webhook (999)`).should(`exist`)
cy.findByText(`Hello World from a Webhook (999)`).should(`exist`)
})
})
Expand Up @@ -51,11 +51,11 @@ describe(`redirect`, () => {
// this is sanity check for this group
it(`make sure 404 is present`, () => {
cy.visit(`/______not_existing_page`).waitForRouteChange()
cy.queryByText("Preview custom 404 page").click()
cy.queryByText("A custom 404 page wasn't detected", {
cy.findByText("Preview custom 404 page").click()
cy.findByText("A custom 404 page wasn't detected", {
exact: false,
}).should(`not.exist`)
cy.queryByText(
cy.findByText(
"You just hit a route that does not exist... the sadness."
).should(`exist`)
})
Expand Down Expand Up @@ -83,11 +83,11 @@ describe(`redirect`, () => {

it(`make sure 404 is NOT present`, () => {
cy.visit(`/______not_existing_page`).waitForRouteChange()
cy.queryByText("Preview custom 404 page").click()
cy.queryByText("A custom 404 page wasn't detected", {
cy.findByText("Preview custom 404 page").click()
cy.findByText("A custom 404 page wasn't detected", {
exact: false,
}).should(`exist`)
cy.queryByText(
cy.findByText(
"You just hit a route that does not exist... the sadness.",
{ exact: false }
).should(`not.exist`)
Expand Down
9 changes: 6 additions & 3 deletions e2e-tests/development-runtime/package.json
Expand Up @@ -34,16 +34,16 @@
"test": "npm run start-server-and-test || (npm run reset && exit 1)",
"posttest": "npm run reset",
"reset": "node scripts/reset.js",
"reset:preview": "node plugins/gatsby-source-fake-data/reset.js && npm run update:preview",
"reset:preview": "curl -X POST http://localhost:8000/__refresh",
"update": "node scripts/update.js",
"update:webhook": "node scripts/webhook.js",
"update:preview": "curl -X POST http://localhost:8000/__refresh",
"update:preview": "curl -X POST -d '{ \"fake-data-update\": true }' -H \"Content-Type: application/json\" http://localhost:8000/__refresh",
"start-server-and-test": "start-server-and-test develop http://localhost:8000 cy:run",
"cy:open": "cypress open",
"cy:run": "(is-ci && cypress run --browser chrome --record) || cypress run --browser chrome"
},
"devDependencies": {
"@testing-library/cypress": "^4.0.4",
"@testing-library/cypress": "^6.0.0",
"cross-env": "^5.2.0",
"cypress": "3.4.1",
"fs-extra": "^7.0.1",
Expand All @@ -56,5 +56,8 @@
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby"
},
"resolutions": {
"cypress": "3.4.1"
Comment on lines +59 to +61
Copy link
Contributor Author

@pieh pieh Aug 17, 2020

Choose a reason for hiding this comment

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

Fix/workaround for https://app.circleci.com/pipelines/github/gatsbyjs/gatsby/48158/workflows/3227d59e-b7ae-4eeb-b109-06a9712b44c2/jobs/491859 ( because of deps spaghetti it tries to install 2 instances of cypress and cypress use single tmp location for binary download and this results in 2 different downloads writing things to same filepath which corrupts it). This is somewhat forcing single instance of cypress to workaround this problem

Some existing tickets about this problem:

}
}
Expand Up @@ -29,6 +29,9 @@ exports.sourceNodes = async function sourceNodes({
reporter.info(`Webhook data detected; creating nodes`)
webhookBody.items.forEach(node => createNode(api.getNode(node, helpers)))
} else {
if (!(webhookBody && webhookBody[`fake-data-update`])) {
await api.reset()
}
Comment on lines +32 to +34
Copy link
Contributor Author

@pieh pieh Aug 17, 2020

Choose a reason for hiding this comment

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

This is meant to result in "initial" data state, unless we want to trigger refresh/update explicitly for this plugin

const [updated, deleted = []] = await api.sync(helpers)

updated.forEach(node => createNode(node))
Expand Down