Skip to content

Commit

Permalink
chore: Fix tests for WordPress, Contentful & update CircleCI (#33256)
Browse files Browse the repository at this point in the history
Co-authored-by: gatsbybot <[email protected]>
Co-authored-by: Ward Peeters <[email protected]>
Co-authored-by: Tyler Barnes <[email protected]>
  • Loading branch information
4 people authored Sep 22, 2021
1 parent 8c11de4 commit 1d8ebb2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 33 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ executors:
parameters:
image:
type: string
# First 10.x LTS release, but old Yarn
default: "14.17.0"
docker:
- image: cimg/node:<< parameters.image >>
Expand Down Expand Up @@ -86,7 +85,7 @@ aliases:
command: yarn jest --ci --runInBand $(yarn -s jest --listTests | sed 's/\/home\/circleci\/project\///g' | circleci tests split)
environment:
NODE_OPTIONS: --max-old-space-size=2048
GENERATE_JEST_REPORT: true
GENERATE_JEST_REPORT: "true"
JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/
JEST_JUNIT_OUTPUT_NAME: results.xml
- store_test_results:
Expand Down Expand Up @@ -145,7 +144,7 @@ commands:
condition: << parameters.condition >>
steps:
- slack/status:
channel: eng-react-integration-status
channel: eng-react-integration-status

e2e-test:
parameters:
Expand Down Expand Up @@ -244,7 +243,8 @@ jobs:
<<: *test_template

integration_tests_gatsby_source_wordpress:
machine: true
machine:
image: "ubuntu-2004:202107-02"
steps:
- run:
command: |
Expand All @@ -253,7 +253,7 @@ jobs:
- run: nvm install v14
- run: nvm alias default v14
- run: nvm use v14
- run: npm i -g [email protected].10
- run: npm i -g [email protected].11
- e2e-test:
test_path: integration-tests/gatsby-source-wordpress

Expand Down Expand Up @@ -551,7 +551,7 @@ jobs:
command: yarn jest --ci --runInBand ((yarn jest --listTests) | Foreach-Object {$_ -replace '.*\\packages', 'packages'} | Foreach-Object {$_ -replace '\\', '/'} | circleci tests split --split-by=timings)
environment:
NODE_OPTIONS: --max-old-space-size=2048
GENERATE_JEST_REPORT: true
GENERATE_JEST_REPORT: "true"
JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/
JEST_JUNIT_OUTPUT_NAME: results.xml
- store_test_results:
Expand Down
7 changes: 0 additions & 7 deletions integration-tests/gatsby-source-wordpress/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ const wpPluginOptions = !process.env.DEFAULT_PLUGIN_OPTIONS
50
: // and we don't actually need more than 1000 in production
1000,

beforeChangeNode: ({ remoteNode }) => {
console.log(`Hi from an inline fn!`)
remoteNode.beforeChangeNodeTest = `TEST-${remoteNode.id}`

return remoteNode
},
},
// excluding this because it causes Gatsby to throw errors
BlockEditorContentNode: { exclude: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,13 @@ describe(`data resolution`, () => {
beforeChangeNodeTest
}
}
# inline fn in gatsby-config.js
# support for this will be removed in future versions
allWpPost {
nodes {
id
beforeChangeNodeTest
}
}
}
`,
})

result.data.allWpPage.nodes.forEach(node => {
expect(node.beforeChangeNodeTest).toBe(`TEST-${node.id}`)
})
result.data.allWpPost.nodes.forEach(node => {
expect(node.beforeChangeNodeTest).toBe(`TEST-${node.id}`)
})
})

it(`resolves root fields`, async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,16 @@ describe(`contentful extend node type`, () => {
}
test(`keeps image format`, async () => {
const result = await getBase64Image(imageProps)
expect(result).toMatch(
`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAMAAAC5ge+kAAAAllBMVEUAAABHl745rOE7tOc7tOcqMDkqMDkqMDkqMDnfzG9Pm7o7tOc7tOcqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDn4wF/eXWDtXGjtXGgqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDkqMDnbVmDpWGbtXGjtXGh1tTylAAAAMnRSTlMATd3gVSUjTCDgHRIscF+MeqB8qpqbk4ienYAxr+AeEipyZI9/aW+No4WJeWuuTdzgVnu3oiUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQflCBQANxNx70pyAAAAMklEQVQI12NkBII/DCDA+htIsDEy/mBj4WDEBCwiyLwnIpyMjL/ZWASB7PMMMPAZTAIALlUHKTqI1/MAAAAASUVORK5CYII=`
)
const regex = /data:image\/png;base64,[a-zA-Z0-9/+]+=*/g
expect(result.match(regex)).not.toBe(null)
})
test(`uses given image format`, async () => {
const result = await getBase64Image({
...imageProps,
options: { ...imageProps.options, toFormat: `jpg` },
})
expect(result).toMatch(
`data:image/jpg;base64,/9j/4AAQSkZJRgABAQIAHAAcAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCAAEABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBv/EACQQAAIBAgQHAQAAAAAAAAAAAAECAAMRBBITJAUUFSFBUWHB/8QAFQEBAQAAAAAAAAAAAAAAAAAAAgH/xAAXEQEBAQEAAAAAAAAAAAAAAAABAAIx/9oADAMBAAIRAxEAPwDV4NObWqM70dOoVvROUt9Psy7pYud5jO/jWiJM8lsDSFB+Do+Xe4xQosAtW35ERFC//9k=`
)
const regex = /data:image\/jpg;base64,[a-zA-Z0-9/+]+=*/g
expect(result.match(regex)).not.toBe(null)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import isInteger from "lodash/isInteger"
import { IPluginOptions } from "~/models/gatsby-api"
import { GatsbyNodeApiHelpers } from "~/utils/gatsby-types"
import { usingGatsbyV4OrGreater } from "~/utils/gatsby-version"
import { cloneDeep } from "lodash"

interface IProcessorOptions {
userPluginOptions: IPluginOptions
helpers: GatsbyNodeApiHelpers
Expand Down Expand Up @@ -136,9 +138,7 @@ export const processAndValidatePluginOptions = (
helpers: GatsbyNodeApiHelpers,
pluginOptions: IPluginOptions
): IPluginOptions => {
let userPluginOptions = {
...pluginOptions,
}
let userPluginOptions = cloneDeep(pluginOptions)

optionsProcessors.forEach(({ test, processor, name }) => {
if (!name) {
Expand Down

0 comments on commit 1d8ebb2

Please sign in to comment.