|
1 | 1 | const { store } = require(`../../redux`) |
| 2 | +const { graphql } = require(`../../../graphql`) |
2 | 3 | const { build, rebuildWithSitePage } = require(`..`) |
3 | 4 |
|
4 | 5 | jest.mock(`gatsby-cli/lib/reporter`, () => { |
@@ -115,7 +116,7 @@ describe(`build and update schema for SitePage`, () => { |
115 | 116 | expect(sortFieldsEnum.getValue(`context___key`)).toBeDefined() |
116 | 117 | }) |
117 | 118 |
|
118 | | - it(`updates nested types on rebuild`, async () => { |
| 119 | + const testNestedFields = async () => { |
119 | 120 | let fields |
120 | 121 | let inputFields |
121 | 122 |
|
@@ -149,6 +150,25 @@ describe(`build and update schema for SitePage`, () => { |
149 | 150 | .map(value => value.name) |
150 | 151 | expect(fieldsEnum.includes(`fields___oldKey`)).toBeTruthy() |
151 | 152 | expect(fieldsEnum.includes(`fields___key`)).toBeTruthy() |
| 153 | + } |
| 154 | + |
| 155 | + it(`updates nested types on rebuild`, testNestedFields) |
| 156 | + |
| 157 | + it(`updates nested types on rebuild (with query executed before rebuilding)`, async () => { |
| 158 | + // Set a stage for the same test as above but with graphql query executed before updating schema |
| 159 | + // See https://github.com/gatsbyjs/gatsby/issues/30107 |
| 160 | + const result = await graphql( |
| 161 | + schema, |
| 162 | + ` |
| 163 | + { |
| 164 | + __typename |
| 165 | + } |
| 166 | + `, |
| 167 | + null, |
| 168 | + {} |
| 169 | + ) |
| 170 | + expect(result).toEqual({ data: { __typename: `Query` } }) |
| 171 | + await testNestedFields() |
152 | 172 | }) |
153 | 173 |
|
154 | 174 | it(`respects @dontInfer on SitePage`, async () => { |
|
0 commit comments