Skip to content

Commit 501416d

Browse files
committed
chore(e2e-dev-runtime): scope fake-data source plugin data refreshes
1 parent cf4327a commit 501416d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

e2e-tests/development-runtime/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
"test": "npm run start-server-and-test || (npm run reset && exit 1)",
3535
"posttest": "npm run reset",
3636
"reset": "node scripts/reset.js",
37-
"reset:preview": "node plugins/gatsby-source-fake-data/reset.js && npm run update:preview",
37+
"reset:preview": "curl -X POST http://localhost:8000/__refresh",
3838
"update": "node scripts/update.js",
3939
"update:webhook": "node scripts/webhook.js",
40-
"update:preview": "curl -X POST http://localhost:8000/__refresh",
40+
"update:preview": "curl -X POST -d '{ \"fake-data-update\": true }' -H \"Content-Type: application/json\" http://localhost:8000/__refresh",
4141
"start-server-and-test": "start-server-and-test develop http://localhost:8000 cy:run",
4242
"cy:open": "cypress open",
4343
"cy:run": "(is-ci && cypress run --browser chrome --record) || cypress run --browser chrome"

e2e-tests/development-runtime/plugins/gatsby-source-fake-data/gatsby-node.js

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ exports.sourceNodes = async function sourceNodes({
2929
reporter.info(`Webhook data detected; creating nodes`)
3030
webhookBody.items.forEach(node => createNode(api.getNode(node, helpers)))
3131
} else {
32+
if (!(webhookBody && webhookBody[`fake-data-update`])) {
33+
await api.reset()
34+
}
3235
const [updated, deleted = []] = await api.sync(helpers)
3336

3437
updated.forEach(node => createNode(node))

0 commit comments

Comments
 (0)