Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[pull] master from gatsbyjs:master #540

Merged
merged 1 commit into from
May 3, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,191 @@ Object {
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves menus INCREMENTED 1`] = `
Object {
"data": Object {
"allWpMenu": Object {
"nodes": Array [
Object {
"count": 4,
"databaseId": 17,
"id": "dGVybToxNw==",
"menuItems": Object {
"nodes": Array [
Object {
"childItems": Object {
"nodes": Array [],
},
"databaseId": 564,
"id": "cG9zdDo1NjQ=",
"label": "Activity",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/activity/",
},
Object {
"childItems": Object {
"nodes": Array [
Object {
"childItems": Object {
"nodes": Array [
Object {
"label": "test custom link",
"url": "https://google.com",
},
],
},
"connectedNode": Object {
"node": Object {
"featuredImage": Object {
"node": Object {
"title": "84-1000×1000",
},
},
"title": "Hello world! DELTA SYNC",
"uri": "/2020/02/25/hello-world/",
},
},
"databaseId": 566,
"id": "cG9zdDo1NjY=",
"label": "Hello world!",
},
],
},
"databaseId": 565,
"id": "cG9zdDo1NjU=",
"label": "Sample Page",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/sample-page/",
},
Object {
"childItems": Object {
"nodes": Array [
Object {
"childItems": Object {
"nodes": Array [],
},
"connectedNode": null,
"databaseId": 567,
"id": "cG9zdDo1Njc=",
"label": "test custom link",
},
],
},
"databaseId": 566,
"id": "cG9zdDo1NjY=",
"label": "Hello world!",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/2020/02/25/hello-world/",
},
Object {
"childItems": Object {
"nodes": Array [],
},
"databaseId": 567,
"id": "cG9zdDo1Njc=",
"label": "test custom link",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "https://google.com",
},
],
},
"name": "main menu",
},
],
},
},
"extensions": Object {},
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves pages 1`] = `
Object {
"data": Object {
"allWpPage": Object {
"nodes": Array [
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
},
"author": Object {
"node": Object {
"name": "admin",
},
},
"title": "Sample Page",
"uri": "/sample-page/",
"wpChildren": Object {
"nodes": Array [],
},
},
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
},
"author": Object {
"node": Object {
"name": "admin",
},
},
"title": "Activity",
"uri": "/activity/",
"wpChildren": Object {
"nodes": Array [],
},
},
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
},
"author": Object {
"node": Object {
"name": "admin",
},
},
"title": "ACF Field Test",
"uri": "/acf-field-test/",
"wpChildren": Object {
"nodes": Array [],
},
},
],
},
"testPage": Object {
"title": "Sample Page",
},
},
"extensions": Object {},
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves pages INCREMENTED 1`] = `
Object {
"data": Object {
"allWpPage": Object {
"nodes": Array [
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
},
"author": Object {
"node": Object {
"name": "admin",
},
},
"title": "Sample Page DELTA SYNC",
"uri": "/sample-page/",
"wpChildren": Object {
"nodes": Array [],
},
},
Object {
"acfPageFields": Object {
"fieldGroupName": "acfPageFields",
Expand Down Expand Up @@ -223,6 +403,9 @@ Object {
},
],
},
"testPage": Object {
"title": "Sample Page DELTA SYNC",
},
},
"extensions": Object {},
}
Expand Down Expand Up @@ -262,6 +445,40 @@ Object {
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves posts INCREMENTED 1`] = `
Object {
"data": Object {
"allWpPost": Object {
"nodes": Array [
Object {
"author": Object {
"node": Object {
"avatar": Object {
"url": "http://2.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=96&d=mm&r=g",
},
"comments": Object {
"nodes": Array [],
},
},
},
"featuredImage": Object {
"node": Object {
"altText": "",
"sourceUrl": "http://localhost:8001/wp-content/uploads/2020/03/84-1000x1000-1.jpg",
},
},
"title": "Hello world! DELTA SYNC",
},
],
},
"testPost": Object {
"title": "Hello world! DELTA SYNC",
},
},
"extensions": Object {},
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves root fields 1`] = `
Object {
"data": Object {
Expand Down Expand Up @@ -310,6 +527,9 @@ Object {
Object {
"title": "Activity",
},
Object {
"title": "Sample Page",
},
],
},
"posts": Object {
Expand All @@ -330,10 +550,64 @@ Object {
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build data resolution resolves users INCREMENTED 1`] = `
Object {
"data": Object {
"allWpUser": Object {
"nodes": Array [
Object {
"databaseId": 4,
"name": "admin",
"pages": Object {
"nodes": Array [
Object {
"title": "ACF Field Test",
},
Object {
"title": "Activity",
},
Object {
"title": "Sample Page DELTA SYNC",
},
],
},
"posts": Object {
"nodes": Array [
Object {
"title": "Hello world! DELTA SYNC",
},
],
},
},
],
},
"testUser": Object {
"name": "admin",
},
},
"extensions": Object {},
}
`;

exports[`[gatsby-source-wordpress] Run tests on develop build filtered type definitions Date field resolver is working 1`] = `
Object {
"data": Object {
"wpPage": null,
"wpPage": Object {
"databaseId": 2,
"date": "2020-02-25T17:54:21",
"dateGmt": "2020-02-25T17:54:21",
"dayOfMonth": "25",
"dayOfMonthGmt": "25",
"dayOfWeekName": "Tuesday",
"dayOfWeekNameGmt": "Tuesday",
"dayOfWeekNumber": "2",
"dayOfWeekNumberGmt": "2",
"id": "cG9zdDoy",
"month": "February",
"monthGmt": "February",
"year": "2020",
"yearGmt": "2020",
},
},
"extensions": Object {},
}
Expand Down
23 changes: 23 additions & 0 deletions integration-tests/gatsby-source-wordpress/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ const {
gatsbyCleanBeforeAll,
} = require(`../test-fns/test-utils/get-gatsby-process`)

const {
mutateSchema,
resetSchema,
} = require(`../test-fns/test-utils/increment-remote-data`)

jest.setTimeout(100000)

// we run these tests twice in a row
// to make sure everything passes on a warm cache build
// we don't need to re-run some tests the second time,
// so the following allows us to do that:
const isWarmCache = process.env.WARM_CACHE

const testOnColdCacheOnly = isWarmCache ? test.skip : test

describe(`[gatsby-source-wordpress] Build default options`, () => {
Expand Down Expand Up @@ -52,6 +58,23 @@ describe(`[gatsby-source-wordpress] Run tests on develop build`, () => {
await gatsbyCleanBeforeAll()
}

if (isWarmCache && !process.env.WORDPRESS_BASIC_AUTH) {
console.log(
`Please add the env var WORDPRESS_BASIC_AUTH. It should be a string in the following pattern: base64Encode(\`\${username}:\${password}\`)`
)

await new Promise(resolve => setTimeout(resolve, 100))
process.exit(1)
}

if (isWarmCache) {
const response = await mutateSchema()
console.log(response)
} else {
const response = await resetSchema()
console.log(response)
}

gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)

await urling(`http://localhost:8000`)
Expand Down
Loading