Skip to content

Commit

Permalink
fix(recipes): Fix shadow-file resource for scoped NPM packages & re-e…
Browse files Browse the repository at this point in the history
…nable e2e testing for resources (#23274)

* fix(recipes): Fix shadow-file resource for scoped NPM packages

* WILL SLASH FIX WINDOWS???

* Add missing code block

* Try again

* hmmm joinPath maybe is the problem

* More fixes

* try reenabling tests

* disable colors in diffs

* Fix npm script test

* Why do these keep changing all the time??

* Use parsed value for the plan

* Disable Chalk colors on unit tests so match local ones

* Update packages/gatsby-recipes/src/providers/utils/get-diff.js

Co-Authored-By: John Otander <johnotander@gmail.com>

Co-authored-by: John Otander <johnotander@gmail.com>
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
3 people authored Apr 20, 2020
1 parent d69b217 commit d8fdee6
Show file tree
Hide file tree
Showing 13 changed files with 1,102 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@ jobs:

unit_tests_node10:
executor: node
environment:
FORCE_COLOR: 0
<<: *test_template

unit_tests_node12:
executor:
name: node
image: "12"
environment:
FORCE_COLOR: 0
<<: *test_template

unit_tests_www:
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ Soon will support options.

#### `<GatsbyShadowFile>`

```jsx
<GatsbyShadowFile theme="gatsby-theme-blog" path="src/components/seo.js" />
```

##### props

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`file resource e2e file resource test: File create 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "Hello, world!",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e file resource test: File create plan 1`] = `
Object {
"currentState": "",
"describe": "Write file.txt",
"diff": "- Original - 0
+ Modified + 1
+ Hello, world!",
"newState": "Hello, world!",
}
`;

exports[`file resource e2e file resource test: File destroy 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "Hello, world!1",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e file resource test: File update 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "Hello, world!1",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e file resource test: File update plan 1`] = `
Object {
"currentState": "Hello, world!",
"describe": "Write file.txt",
"diff": "- Original - 1
+ Modified + 1
- Hello, world!
+ Hello, world!1",
"newState": "Hello, world!1",
}
`;

exports[`file resource e2e remote file resource test: File create 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "query {
allGatsbyPlugin {
nodes {
name
options
resolvedOptions
package {
version
}
... on GatsbyTheme {
files {
nodes {
path
}
}
shadowedFiles {
nodes {
path
}
}
}
}
}
}",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e remote file resource test: File create plan 1`] = `
Object {
"currentState": "",
"describe": "Write file.txt",
"diff": "- Original - 0
+ Modified + 24
+ query {
+ allGatsbyPlugin {
+ nodes {
+ name
+ options
+ resolvedOptions
+ package {
+ version
+ }
+ ... on GatsbyTheme {
+ files {
+ nodes {
+ path
+ }
+ }
+ shadowedFiles {
+ nodes {
+ path
+ }
+ }
+ }
+ }
+ }
+ }",
"newState": "query {
allGatsbyPlugin {
nodes {
name
options
resolvedOptions
package {
version
}
... on GatsbyTheme {
files {
nodes {
path
}
}
shadowedFiles {
nodes {
path
}
}
}
}
}
}",
}
`;

exports[`file resource e2e remote file resource test: File destroy 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "https://gist.githubusercontent.com/KyleAMathews/3d763491e5c4c6396e1a6a626b2793ce/raw/545120bfecbe7b0f97f6f021801bc8b6370b5b41/gistfile2.txt",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e remote file resource test: File update 1`] = `
Object {
"_message": "Wrote file file.txt",
"content": "https://gist.githubusercontent.com/KyleAMathews/3d763491e5c4c6396e1a6a626b2793ce/raw/545120bfecbe7b0f97f6f021801bc8b6370b5b41/gistfile2.txt",
"id": "file.txt",
"path": "file.txt",
}
`;

exports[`file resource e2e remote file resource test: File update plan 1`] = `
Object {
"currentState": "query {
allGatsbyPlugin {
nodes {
name
options
resolvedOptions
package {
version
}
... on GatsbyTheme {
files {
nodes {
path
}
}
shadowedFiles {
nodes {
path
}
}
}
}
}
}",
"describe": "Write file.txt",
"diff": "- Original - 23
+ Modified + 3
- query {
- allGatsbyPlugin {
- nodes {
- name
- options
- resolvedOptions
- package {
- version
- }
- ... on GatsbyTheme {
- files {
- nodes {
- path
- }
- }
- shadowedFiles {
- nodes {
- path
- }
- }
- }
- }
- }
+ const options = {
+ key: process.env.WHATEVER
+
}",
"newState": "const options = {
key: process.env.WHATEVER
}",
}
`;
Loading

0 comments on commit d8fdee6

Please sign in to comment.