-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/get-request-headers' of https://github.com/gatsbyj…
…s/gatsby into feat/get-request-headers
- Loading branch information
Showing
131 changed files
with
1,130 additions
and
772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../development-runtime/cypress/integration/gatsby-script/gatsby-script-duplicate-scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe(`duplicate scripts`, () => { | ||
beforeEach(() => { | ||
cy.visit(`/gatsby-script-duplicate-scripts/`) | ||
}) | ||
|
||
it(`should execute load callbacks of duplicate scripts`, () => { | ||
cy.get(`[data-on-load-result=duplicate-1]`).should(`have.length`, 1) | ||
cy.get(`[data-on-load-result=duplicate-2]`).should(`have.length`, 1) | ||
cy.get(`[data-on-load-result=duplicate-3]`).should(`have.length`, 1) | ||
}) | ||
|
||
it(`should execute error callbacks of duplicate scripts`, () => { | ||
cy.get(`[data-on-error-result=duplicate-1]`).should(`have.length`, 1) | ||
cy.get(`[data-on-error-result=duplicate-2]`).should(`have.length`, 1) | ||
cy.get(`[data-on-error-result=duplicate-3]`).should(`have.length`, 1) | ||
}) | ||
}) |
61 changes: 61 additions & 0 deletions
61
e2e-tests/development-runtime/src/pages/gatsby-script-duplicate-scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from "react" | ||
import { Script } from "gatsby" | ||
import { scripts } from "../../gatsby-script-scripts" | ||
import { onLoad, onError } from "../utils/gatsby-script-callbacks" | ||
|
||
const DuplicateScripts = () => { | ||
const [onLoadScriptLoaded, setOnLoadScriptLoaded] = useState(false) | ||
const [onErrorScriptLoaded, setOnErrorScriptLoaded] = useState(false) | ||
|
||
return ( | ||
<main> | ||
<h1>Script component e2e test</h1> | ||
|
||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-1`) | ||
}} | ||
/> | ||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-2`) | ||
setOnLoadScriptLoaded(true) | ||
}} | ||
/> | ||
{onLoadScriptLoaded && ( | ||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-3`) | ||
}} | ||
/> | ||
)} | ||
|
||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-1`) | ||
}} | ||
/> | ||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-2`) | ||
setOnErrorScriptLoaded(true) | ||
}} | ||
/> | ||
{onErrorScriptLoaded && ( | ||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-3`) | ||
}} | ||
/> | ||
)} | ||
</main> | ||
) | ||
} | ||
|
||
export default DuplicateScripts |
19 changes: 19 additions & 0 deletions
19
e2e-tests/production-runtime/cypress/integration/gatsby-script-duplicate-scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Cypress.config(`defaultCommandTimeout`, 30000) // Since we're asserting network requests | ||
|
||
describe(`duplicate scripts`, () => { | ||
beforeEach(() => { | ||
cy.visit(`/gatsby-script-duplicate-scripts/`) | ||
}) | ||
|
||
it(`should execute load callbacks of duplicate scripts`, () => { | ||
cy.get(`[data-on-load-result=duplicate-1]`).should(`have.length`, 1) | ||
cy.get(`[data-on-load-result=duplicate-2]`).should(`have.length`, 1) | ||
cy.get(`[data-on-load-result=duplicate-3]`).should(`have.length`, 1) | ||
}) | ||
|
||
it(`should execute error callbacks of duplicate scripts`, () => { | ||
cy.get(`[data-on-error-result=duplicate-1]`).should(`have.length`, 1) | ||
cy.get(`[data-on-error-result=duplicate-2]`).should(`have.length`, 1) | ||
cy.get(`[data-on-error-result=duplicate-3]`).should(`have.length`, 1) | ||
}) | ||
}) |
61 changes: 61 additions & 0 deletions
61
e2e-tests/production-runtime/src/pages/gatsby-script-duplicate-scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from "react" | ||
import { Script } from "gatsby" | ||
import { scripts } from "../../gatsby-script-scripts" | ||
import { onLoad, onError } from "../utils/gatsby-script-callbacks" | ||
|
||
const DuplicateScripts = () => { | ||
const [onLoadScriptLoaded, setOnLoadScriptLoaded] = useState(false) | ||
const [onErrorScriptLoaded, setOnErrorScriptLoaded] = useState(false) | ||
|
||
return ( | ||
<main> | ||
<h1>Script component e2e test</h1> | ||
|
||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-1`) | ||
}} | ||
/> | ||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-2`) | ||
setOnLoadScriptLoaded(true) | ||
}} | ||
/> | ||
{onLoadScriptLoaded && ( | ||
<Script | ||
src={scripts.marked} | ||
onLoad={() => { | ||
onLoad(`duplicate-3`) | ||
}} | ||
/> | ||
)} | ||
|
||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-1`) | ||
}} | ||
/> | ||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-2`) | ||
setOnErrorScriptLoaded(true) | ||
}} | ||
/> | ||
{onErrorScriptLoaded && ( | ||
<Script | ||
src="/non-existent-script.js" | ||
onError={() => { | ||
onError(`duplicate-3`) | ||
}} | ||
/> | ||
)} | ||
</main> | ||
) | ||
} | ||
|
||
export default DuplicateScripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.