Skip to content

Commit ae12e63

Browse files
author
LB
authored
todos part 2 (#29414)
* todos part 2 * tests * mock panic * remove obsolete snapshot
1 parent a7c36de commit ae12e63

File tree

6 files changed

+9
-129
lines changed

6 files changed

+9
-129
lines changed

packages/gatsby-plugin-google-gtag/src/__tests__/gatsby-ssr.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,4 @@ describe(`respectDNT`, () => {
7575
DO_NOT_TRACK_STRING
7676
)
7777
})
78-
79-
it(`listens to respectDNT deprecated option`, () => {
80-
const mocks = {
81-
setHeadComponents: jest.fn(),
82-
setPostBodyComponents: jest.fn(),
83-
}
84-
const pluginOptions = {
85-
trackingIds: [`GA_TRACKING_ID`],
86-
respectDNT: true,
87-
pluginConfig: {},
88-
}
89-
90-
onRenderBody(mocks, pluginOptions)
91-
const [, config] = mocks.setPostBodyComponents.mock.calls[0][0]
92-
93-
expect(config.props.dangerouslySetInnerHTML.__html).toContain(
94-
DO_NOT_TRACK_STRING
95-
)
96-
})
9778
})

packages/gatsby-plugin-google-gtag/src/gatsby-ssr.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ exports.onRenderBody = (
4242
? setHeadComponents
4343
: setPostBodyComponents
4444

45-
// TODO: remove pluginOptions.respectDNT in the next major release of this plugin.
46-
// See issue https://github.com/gatsbyjs/gatsby/issues/11159 for the discussion.
47-
const respectDNT = pluginConfig.respectDNT || pluginOptions.respectDNT
48-
4945
const renderHtml = () => `
5046
${
5147
excludeGtagPaths.length
@@ -59,7 +55,7 @@ exports.onRenderBody = (
5955
: ``
6056
}
6157
if(${
62-
respectDNT
58+
pluginConfig.respectDNT
6359
? `!(navigator.doNotTrack == "1" || window.doNotTrack == "1")`
6460
: `true`
6561
}) {

packages/gatsby-plugin-mdx/utils/default-options.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ module.exports = ({ mdPlugins, hastPlugins, ...pluginOptions }) => {
1717
plugins: [],
1818
root: process.cwd(),
1919
gatsbyRemarkPlugins: [],
20-
// TODO: Remove globalScope option in next major as it's deprecated in favor of shortcodes, see https://github.com/ChristopherBiscardi/gatsby-mdx/issues/239#issuecomment-507322221
21-
globalScope: `export default {}`,
2220
shouldBlockNodeFromTransformation: () => false,
2321
},
2422
pluginOptions

packages/gatsby-plugin-netlify/src/__tests__/__snapshots__/build-headers-program.js.snap

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`build-headers-program with badly headers configuration 1`] = `
4-
"## Created with gatsby-plugin-netlify
5-
6-
/*
7-
X-Frame-Options: DENY
8-
X-XSS-Protection: 1; mode=block
9-
X-Content-Type-Options: nosniff
10-
Referrer-Policy: same-origin
11-
X-Frame-Options
12-
sameorigin
13-
/component---node-modules-gatsby-plugin-offline-app-shell-js-78f9e4dea04737fa062d.js
14-
Cache-Control: public, max-age=31536000, immutable
15-
/0-0180cd94ef2497ac7db8.js
16-
Cache-Control: public, max-age=31536000, immutable
17-
/component---src-templates-blog-post-js-517987eae96e75cddbe7.js
18-
Cache-Control: public, max-age=31536000, immutable
19-
/component---src-pages-404-js-53e6c51a5a7e73090f50.js
20-
Cache-Control: public, max-age=31536000, immutable
21-
/component---src-pages-index-js-0bdd01c77ee09ef0224c.js
22-
Cache-Control: public, max-age=31536000, immutable
23-
/webpack-runtime-acaa8994f1f704475e21.js
24-
Cache-Control: public, max-age=31536000, immutable
25-
/styles.1025963f4f2ec7abbad4.css
26-
Cache-Control: public, max-age=31536000, immutable
27-
/styles-565f081c8374bbda155f.js
28-
Cache-Control: public, max-age=31536000, immutable
29-
/app-f33c13590352da20930f.js
30-
Cache-Control: public, max-age=31536000, immutable
31-
/static/*
32-
Cache-Control: public, max-age=31536000, immutable
33-
/sw.js
34-
Cache-Control: no-cache
35-
/offline-plugin-app-shell-fallback/
36-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
37-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
38-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
39-
Link: </component---node-modules-gatsby-plugin-offline-app-shell-js-78f9e4dea04737fa062d.js>; rel=preload; as=script
40-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
41-
Link: </page-data/offline-plugin-app-shell-fallback/page-data.json>; rel=preload; as=fetch; crossorigin
42-
/hi-folks/
43-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
44-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
45-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
46-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
47-
Link: </component---src-templates-blog-post-js-517987eae96e75cddbe7.js>; rel=preload; as=script
48-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
49-
Link: </page-data/hi-folks/page-data.json>; rel=preload; as=fetch; crossorigin
50-
/my-second-post/
51-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
52-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
53-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
54-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
55-
Link: </component---src-templates-blog-post-js-517987eae96e75cddbe7.js>; rel=preload; as=script
56-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
57-
Link: </page-data/my-second-post/page-data.json>; rel=preload; as=fetch; crossorigin
58-
/hello-world/
59-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
60-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
61-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
62-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
63-
Link: </component---src-templates-blog-post-js-517987eae96e75cddbe7.js>; rel=preload; as=script
64-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
65-
Link: </page-data/hello-world/page-data.json>; rel=preload; as=fetch; crossorigin
66-
/404/
67-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
68-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
69-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
70-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
71-
Link: </component---src-pages-404-js-53e6c51a5a7e73090f50.js>; rel=preload; as=script
72-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
73-
Link: </page-data/404/page-data.json>; rel=preload; as=fetch; crossorigin
74-
/
75-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
76-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
77-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
78-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
79-
Link: </component---src-pages-index-js-0bdd01c77ee09ef0224c.js>; rel=preload; as=script
80-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
81-
Link: </page-data/index/page-data.json>; rel=preload; as=fetch; crossorigin
82-
/404.html
83-
Link: </webpack-runtime-acaa8994f1f704475e21.js>; rel=preload; as=script
84-
Link: </styles-565f081c8374bbda155f.js>; rel=preload; as=script
85-
Link: </app-f33c13590352da20930f.js>; rel=preload; as=script
86-
Link: </0-0180cd94ef2497ac7db8.js>; rel=preload; as=script
87-
Link: </component---src-pages-404-js-53e6c51a5a7e73090f50.js>; rel=preload; as=script
88-
Link: </page-data/app-data.json>; rel=preload; as=fetch; crossorigin
89-
Link: </page-data/404.html/page-data.json>; rel=preload; as=fetch; crossorigin
90-
"
91-
`;
92-
933
exports[`build-headers-program with caching headers 1`] = `
944
"## Created with gatsby-plugin-netlify
955

packages/gatsby-plugin-netlify/src/__tests__/build-headers-program.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe(`build-headers-program`, () => {
1616

1717
beforeEach(() => {
1818
reporter = {
19-
warn: jest.fn(),
19+
panic: jest.fn(),
2020
}
2121
fs.existsSync.mockClear()
2222
fs.existsSync.mockReturnValue(true)
@@ -175,7 +175,7 @@ describe(`build-headers-program`, () => {
175175

176176
await buildHeadersProgram(pluginData, pluginOptions, reporter)
177177

178-
expect(reporter.warn).not.toHaveBeenCalled()
178+
expect(reporter.panic).not.toHaveBeenCalled()
179179
const output = await fs.readFile(
180180
pluginData.publicFolder(`_headers`),
181181
`utf8`
@@ -210,7 +210,7 @@ describe(`build-headers-program`, () => {
210210

211211
await buildHeadersProgram(pluginData, pluginOptions, reporter)
212212

213-
expect(reporter.warn).not.toHaveBeenCalled()
213+
expect(reporter.panic).not.toHaveBeenCalled()
214214
const output = await fs.readFile(
215215
pluginData.publicFolder(`_headers`),
216216
`utf8`
@@ -242,7 +242,7 @@ describe(`build-headers-program`, () => {
242242

243243
await buildHeadersProgram(pluginData, pluginOptions, reporter)
244244

245-
expect(reporter.warn).not.toHaveBeenCalled()
245+
expect(reporter.panic).not.toHaveBeenCalled()
246246
const output = await fs.readFile(
247247
pluginData.publicFolder(`_headers`),
248248
`utf8`
@@ -261,7 +261,7 @@ describe(`build-headers-program`, () => {
261261

262262
await buildHeadersProgram(pluginData, pluginOptions, reporter)
263263

264-
expect(reporter.warn).not.toHaveBeenCalled()
264+
expect(reporter.panic).not.toHaveBeenCalled()
265265
expect(
266266
await fs.readFile(pluginData.publicFolder(`_headers`), `utf8`)
267267
).toMatchSnapshot()
@@ -284,7 +284,7 @@ describe(`build-headers-program`, () => {
284284

285285
await buildHeadersProgram(pluginData, pluginOptions, reporter)
286286

287-
expect(reporter.warn).not.toHaveBeenCalled()
287+
expect(reporter.panic).not.toHaveBeenCalled()
288288
expect(
289289
await fs.readFile(pluginData.publicFolder(`_headers`), `utf8`)
290290
).toMatchSnapshot()
@@ -303,10 +303,6 @@ describe(`build-headers-program`, () => {
303303

304304
await buildHeadersProgram(pluginData, pluginOptions, reporter)
305305

306-
expect(reporter.warn).toHaveBeenCalled()
307-
308-
expect(
309-
await fs.readFile(pluginData.publicFolder(`_headers`), `utf8`)
310-
).toMatchSnapshot()
306+
expect(reporter.panic).toHaveBeenCalled()
311307
})
312308
})

packages/gatsby-plugin-netlify/src/build-headers-program.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ function validHeaders(headers, reporter) {
3030
_.every(headersList, header => {
3131
if (_.isString(header)) {
3232
if (!getHeaderName(header)) {
33-
// TODO panic on builds on v3
34-
reporter.warn(
33+
reporter.panic(
3534
`[gatsby-plugin-netlify] ${path} contains an invalid header (${header}). Please check your plugin configuration`
3635
)
3736
}

0 commit comments

Comments
 (0)