-
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.
feat(gatsby): enable local themes (#15856)
- Loading branch information
1 parent
c2ed766
commit bd85555
Showing
35 changed files
with
342 additions
and
61 deletions.
There are no files selected for viewing
30 changes: 24 additions & 6 deletions
30
e2e-tests/themes/development-runtime/cypress/integration/components.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 |
---|---|---|
@@ -1,12 +1,30 @@ | ||
/* global cy */ | ||
|
||
describe(`Components`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`date`).contains(`6/28/1993`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`date`).contains(`6/28/1993`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/shadowed-local`).waitForRouteChange() | ||
cy.getTestElement(`header`).contains( | ||
`This is component to test shadowing of local theme` | ||
) | ||
}) | ||
}) | ||
it(`added by themes can be shadowed`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`time`).contains(`2:39:07 PM`) | ||
describe(`added by themes can be shadowed`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`time`).contains(`2:39:07 PM`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/shadowed-local`).waitForRouteChange() | ||
cy.getTestElement(`pre`).contains(`This is in main site`) | ||
cy.getTestElement(`pre`).should( | ||
`not.contain`, | ||
`This is in gatsby-theme-local` | ||
) | ||
}) | ||
}) | ||
}) |
29 changes: 21 additions & 8 deletions
29
e2e-tests/themes/development-runtime/cypress/integration/pages.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 |
---|---|---|
@@ -1,14 +1,27 @@ | ||
/* global cy */ | ||
|
||
describe(`Pages`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/about`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/about`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/page-from-local`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Page from local theme`) | ||
}) | ||
}) | ||
it(`added by themes can be shadowed`, () => { | ||
cy.visit(`/contact`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains( | ||
`A title since the theme didn't have one` | ||
) | ||
describe(`added by themes can be shadowed`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/contact`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains( | ||
`A title since the theme didn't have one` | ||
) | ||
}) | ||
|
||
it(`local theme`, () => { | ||
cy.visit(`/page-from-local-overwrite`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Overwritten page from local theme`) | ||
}) | ||
}) | ||
}) |
24 changes: 18 additions & 6 deletions
24
e2e-tests/themes/development-runtime/cypress/integration/site-metadata.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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
/* global cy */ | ||
|
||
describe(`Site Metadata`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`description`).contains(`Description placeholder`) | ||
}) | ||
}) | ||
it(`added by themes can be overridden`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`author`).contains(`Sidhartha Chatterjee`) | ||
describe(`added by themes can be overridden`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`author`).contains(`Sidhartha Chatterjee`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`social_twitter`).contains(`chatsidhartha`) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
module.exports = { | ||
siteMetadata: { | ||
author: `Sidhartha Chatterjee`, | ||
social: { | ||
twitter: `chatsidhartha`, | ||
}, | ||
}, | ||
plugins: [`gatsby-theme-about`], | ||
plugins: [`gatsby-theme-about`, `gatsby-theme-local`], | ||
} |
16 changes: 16 additions & 0 deletions
16
e2e-tests/themes/development-runtime/plugins/gatsby-theme-local/gatsby-config.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,16 @@ | ||
module.exports = { | ||
siteMetadata: { | ||
description: `Description placeholder`, | ||
social: { | ||
twitter: `twitter placeholder`, | ||
}, | ||
}, | ||
plugins: [ | ||
{ | ||
resolve: `gatsby-plugin-page-creator`, | ||
options: { | ||
path: `${__dirname}/src/pages`, | ||
}, | ||
}, | ||
], | ||
} |
1 change: 1 addition & 0 deletions
1
e2e-tests/themes/development-runtime/plugins/gatsby-theme-local/index.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 @@ | ||
// no-op |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/development-runtime/plugins/gatsby-theme-local/package.json
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,3 @@ | ||
{ | ||
"name": "gatsby-theme-local" | ||
} |
13 changes: 13 additions & 0 deletions
13
...s/themes/development-runtime/plugins/gatsby-theme-local/src/components/shadowing-local.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,13 @@ | ||
import React from "react" | ||
import ToBeShadowed from "./to-be-shadowed" | ||
|
||
export default () => ( | ||
<> | ||
<header data-testid="header"> | ||
This is component to test shadowing of local theme | ||
</header> | ||
<pre data-testid="pre"> | ||
<ToBeShadowed /> | ||
</pre> | ||
</> | ||
) |
3 changes: 3 additions & 0 deletions
3
...ts/themes/development-runtime/plugins/gatsby-theme-local/src/components/to-be-shadowed.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <>This is in gatsby-theme-local</> |
3 changes: 3 additions & 0 deletions
3
...mes/development-runtime/plugins/gatsby-theme-local/src/pages/page-from-local-overwrite.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <h1 data-testid="title">Page from local theme</h1> |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/development-runtime/plugins/gatsby-theme-local/src/pages/page-from-local.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <h1 data-testid="title">Page from local theme</h1> |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/development-runtime/src/gatsby-theme-local/components/to-be-shadowed.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <>This is in main site</> |
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
5 changes: 5 additions & 0 deletions
5
e2e-tests/themes/development-runtime/src/pages/page-from-local-overwrite.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,5 @@ | ||
import React from "react" | ||
|
||
export default () => ( | ||
<h1 data-testid="title">Overwritten page from local theme</h1> | ||
) |
5 changes: 5 additions & 0 deletions
5
e2e-tests/themes/development-runtime/src/pages/shadowed-local.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,5 @@ | ||
import React from "react" | ||
|
||
import LocalShadowingComponent from "../../plugins/gatsby-theme-local/src/components/shadowing-local" | ||
|
||
export default () => <LocalShadowingComponent /> |
30 changes: 24 additions & 6 deletions
30
e2e-tests/themes/production-runtime/cypress/integration/components.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 |
---|---|---|
@@ -1,12 +1,30 @@ | ||
/* global cy */ | ||
|
||
describe(`Components`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`date`).contains(`6/28/1993`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`date`).contains(`6/28/1993`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/shadowed-local`).waitForRouteChange() | ||
cy.getTestElement(`header`).contains( | ||
`This is component to test shadowing of local theme` | ||
) | ||
}) | ||
}) | ||
it(`added by themes can be shadowed`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`time`).contains(`2:39:07 PM`) | ||
describe(`added by themes can be shadowed`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/shadowed`).waitForRouteChange() | ||
cy.getTestElement(`time`).contains(`2:39:07 PM`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/shadowed-local`).waitForRouteChange() | ||
cy.getTestElement(`pre`).contains(`This is in main site`) | ||
cy.getTestElement(`pre`).should( | ||
`not.contain`, | ||
`This is in gatsby-theme-local` | ||
) | ||
}) | ||
}) | ||
}) |
29 changes: 21 additions & 8 deletions
29
e2e-tests/themes/production-runtime/cypress/integration/pages.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 |
---|---|---|
@@ -1,14 +1,27 @@ | ||
/* global cy */ | ||
|
||
describe(`Pages`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/about`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/about`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/page-from-local`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Page from local theme`) | ||
}) | ||
}) | ||
it(`added by themes can be shadowed`, () => { | ||
cy.visit(`/contact`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains( | ||
`A title since the theme didn't have one` | ||
) | ||
describe(`added by themes can be shadowed`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/contact`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains( | ||
`A title since the theme didn't have one` | ||
) | ||
}) | ||
|
||
it(`local theme`, () => { | ||
cy.visit(`/page-from-local-overwrite`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Overwritten page from local theme`) | ||
}) | ||
}) | ||
}) |
24 changes: 18 additions & 6 deletions
24
e2e-tests/themes/production-runtime/cypress/integration/site-metadata.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 |
---|---|---|
@@ -1,12 +1,24 @@ | ||
/* global cy */ | ||
|
||
describe(`Site Metadata`, () => { | ||
it(`can be added by themes`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
describe(`can be added by themes`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`title`).contains(`Blog Title Placeholder`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`description`).contains(`Description placeholder`) | ||
}) | ||
}) | ||
it(`added by themes can be overridden`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`author`).contains(`Sidhartha Chatterjee`) | ||
describe(`added by themes can be overridden`, () => { | ||
it(`installed theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`author`).contains(`Sidhartha Chatterjee`) | ||
}) | ||
it(`local theme`, () => { | ||
cy.visit(`/`).waitForRouteChange() | ||
cy.getTestElement(`social_twitter`).contains(`chatsidhartha`) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
module.exports = { | ||
siteMetadata: { | ||
author: `Sidhartha Chatterjee`, | ||
social: { | ||
twitter: `chatsidhartha`, | ||
}, | ||
}, | ||
plugins: [`gatsby-theme-about`], | ||
plugins: [`gatsby-theme-about`, `gatsby-theme-local`], | ||
} |
16 changes: 16 additions & 0 deletions
16
e2e-tests/themes/production-runtime/plugins/gatsby-theme-local/gatsby-config.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,16 @@ | ||
module.exports = { | ||
siteMetadata: { | ||
description: `Description placeholder`, | ||
social: { | ||
twitter: `twitter placeholder`, | ||
}, | ||
}, | ||
plugins: [ | ||
{ | ||
resolve: `gatsby-plugin-page-creator`, | ||
options: { | ||
path: `${__dirname}/src/pages`, | ||
}, | ||
}, | ||
], | ||
} |
1 change: 1 addition & 0 deletions
1
e2e-tests/themes/production-runtime/plugins/gatsby-theme-local/index.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 @@ | ||
// no-op |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/production-runtime/plugins/gatsby-theme-local/package.json
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,3 @@ | ||
{ | ||
"name": "gatsby-theme-local" | ||
} |
13 changes: 13 additions & 0 deletions
13
...ts/themes/production-runtime/plugins/gatsby-theme-local/src/components/shadowing-local.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,13 @@ | ||
import React from "react" | ||
import ToBeShadowed from "./to-be-shadowed" | ||
|
||
export default () => ( | ||
<> | ||
<header data-testid="header"> | ||
This is component to test shadowing of local theme | ||
</header> | ||
<pre data-testid="pre"> | ||
<ToBeShadowed /> | ||
</pre> | ||
</> | ||
) |
3 changes: 3 additions & 0 deletions
3
...sts/themes/production-runtime/plugins/gatsby-theme-local/src/components/to-be-shadowed.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <>This is in gatsby-theme-local</> |
3 changes: 3 additions & 0 deletions
3
...emes/production-runtime/plugins/gatsby-theme-local/src/pages/page-from-local-overwrite.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <h1 data-testid="title">Page from local theme</h1> |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/production-runtime/plugins/gatsby-theme-local/src/pages/page-from-local.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <h1 data-testid="title">Page from local theme</h1> |
3 changes: 3 additions & 0 deletions
3
e2e-tests/themes/production-runtime/src/gatsby-theme-local/components/to-be-shadowed.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,3 @@ | ||
import React from "react" | ||
|
||
export default () => <>This is in main site</> |
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
5 changes: 5 additions & 0 deletions
5
e2e-tests/themes/production-runtime/src/pages/page-from-local-overwrite.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,5 @@ | ||
import React from "react" | ||
|
||
export default () => ( | ||
<h1 data-testid="title">Overwritten page from local theme</h1> | ||
) |
5 changes: 5 additions & 0 deletions
5
e2e-tests/themes/production-runtime/src/pages/shadowed-local.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,5 @@ | ||
import React from "react" | ||
|
||
import LocalShadowingComponent from "../../plugins/gatsby-theme-local/src/components/shadowing-local" | ||
|
||
export default () => <LocalShadowingComponent /> |
Oops, something went wrong.