-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat(gatsby): trailingSlash config option
#34268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 65 commits
49f1672
1e7646c
db532e4
0f8f353
55d47aa
248877f
396f986
40aea6f
d590d4f
d4a149c
dae6ddb
5e02152
8949a3e
6648b77
992c6d6
9b2acc5
b6fdb4d
429c75e
ba4dbd9
07f9343
3909933
aeec8fd
9a89baa
abd7c02
c539129
7213133
be16962
6c8e3bc
0623374
1074661
531d42a
b062129
3a5c0a4
8147f56
97e6a3c
5a81041
0708e46
a5c77da
d7963af
10996bd
5cab2e4
f8b9d2e
a370934
0a522d4
a6244b4
d2477bb
917d2be
1b3b47f
1887b51
ecdfa26
1bd7cca
94b1e78
267f6cd
a583544
84fb2cf
3cb65ed
bb9b1d8
0970fbf
43537d8
3cf0dc2
0a8dfc0
257febb
8b448ce
60ff0ab
b3f4783
a501683
4ee7ff6
159969b
dd8cc06
9bffe80
820bba8
8f034c6
8235639
50f1ae5
ad04771
caafd5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Project dependencies | ||
| .cache | ||
| node_modules | ||
| yarn-error.log | ||
|
|
||
| # Build assets | ||
| /public | ||
| .DS_Store | ||
| /assets | ||
|
|
||
| # Cypress output | ||
| cypress/videos/ | ||
| cypress/screenshots/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # trailing-slash E2E Test | ||
|
|
||
| This Cypress suite tests the `trailingSlash` option inside `gatsby-config` and its various different settings it takes. When you want to work on it, start watching packages inside the `packages` and start `gatsby-dev-cli` in this E2E test suite. | ||
|
|
||
| Locally you can run for development: | ||
|
|
||
| ```shell | ||
| TRAILING_SLASH=your-option yarn debug:develop | ||
| ``` | ||
|
|
||
| And for a build + serve: | ||
|
|
||
| ```shell | ||
| TRAILING_SLASH=your-option yarn build && yarn debug:build | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "videoUploadOnPasses": false, | ||
| "chromeWebSecurity": false | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "Using fixtures to represent data", | ||
| "email": "[email protected]", | ||
| "body": "Fixtures are a great way to mock data for responses to routes" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| describe(`always`, () => { | ||
| beforeEach(() => { | ||
| cy.visit(`/`).waitForRouteChange() | ||
| }) | ||
| it(`page-creator without slash`, () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel strongly about this, so feel free to ignore it. We could parameterize a large amount of these tests to clean them up a bit. Something like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that could be a good follow-up for some time |
||
| cy.getTestElement(`page-creator-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/`) | ||
| }) | ||
| it(`page-creator with slash`, () => { | ||
| cy.getTestElement(`page-creator-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page with slash`, () => { | ||
| cy.getTestElement(`create-page-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/create-page/with/`) | ||
| }) | ||
| it(`create-page without slash`, () => { | ||
| cy.getTestElement(`create-page-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/create-page/without/`) | ||
| }) | ||
| it(`fs-api with slash`, () => { | ||
| cy.getTestElement(`fs-api-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api/with/`) | ||
| }) | ||
| it(`fs-api without slash`, () => { | ||
| cy.getTestElement(`fs-api-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api/without/`) | ||
| }) | ||
| it(`fs-api-simple with slash`, () => { | ||
| cy.getTestElement(`fs-api-simple-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api-simple/with/`) | ||
| }) | ||
| it(`fs-api-simple without slash`, () => { | ||
| cy.getTestElement(`fs-api-simple-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api-simple/without/`) | ||
| }) | ||
| it(`gatsbyPath works`, () => { | ||
| cy.getTestElement(`gatsby-path-1`).should( | ||
| "have.attr", | ||
| "href", | ||
| "/fs-api-simple/with/" | ||
| ) | ||
| cy.getTestElement(`gatsby-path-2`).should( | ||
| "have.attr", | ||
| "href", | ||
| "/fs-api-simple/without/" | ||
| ) | ||
| }) | ||
| it(`hash`, () => { | ||
| cy.getTestElement(`hash`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/#anchor`) | ||
| }) | ||
| it(`hash trailing`, () => { | ||
| cy.getTestElement(`hash-trailing`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/#anchor`) | ||
| }) | ||
| it(`query-param`, () => { | ||
| cy.getTestElement(`query-param`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/?query_param=hello`) | ||
| }) | ||
| it(`query-param-hash`, () => { | ||
| cy.getTestElement(`query-param-hash`).click() | ||
| cy.waitForRouteChange().assertRoute(`/page-2/?query_param=hello#anchor`) | ||
| }) | ||
| it(`client-only-simple without slash`, () => { | ||
| cy.getTestElement(`client-only-simple-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/client-only/without/`) | ||
| cy.getTestElement(`title`).should(`have.text`, `without`) | ||
| }) | ||
| it(`client-only-simple with slash`, () => { | ||
| cy.getTestElement(`client-only-simple-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/client-only/with/`) | ||
| cy.getTestElement(`title`).should(`have.text`, `with`) | ||
| }) | ||
| it(`client-only without slash`, () => { | ||
| cy.getTestElement(`client-only-without`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api/without/without/`) | ||
| cy.getTestElement(`title`).should(`have.text`, `without`) | ||
| }) | ||
| it(`client-only with slash`, () => { | ||
| cy.getTestElement(`client-only-with`).click() | ||
| cy.waitForRouteChange().assertRoute(`/fs-api/with/with/`) | ||
| cy.getTestElement(`title`).should(`have.text`, `with`) | ||
| }) | ||
| }) | ||
|
|
||
| describe(`always (direct visits)`, () => { | ||
| beforeEach(() => { | ||
| cy.visit(`/`).waitForRouteChange() | ||
| }) | ||
| it(`page-creator`, () => { | ||
| cy.visit(`/page-2`).waitForRouteChange().assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page with`, () => { | ||
| cy.visit(`/create-page/with/`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/create-page/with/`) | ||
| }) | ||
| it(`create-page without`, () => { | ||
| cy.visit(`/create-page/without`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/create-page/without/`) | ||
| }) | ||
| it(`fs-api-simple with`, () => { | ||
| cy.visit(`/fs-api-simple/with/`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/fs-api-simple/with/`) | ||
| }) | ||
| it(`fs-api-simple without`, () => { | ||
| cy.visit(`/fs-api-simple/without`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/fs-api-simple/without/`) | ||
| }) | ||
| it(`client-only-simple with`, () => { | ||
| cy.visit(`/client-only/with/`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/client-only/with/`) | ||
| }) | ||
| it(`client-only-simple without`, () => { | ||
| cy.visit(`/client-only/without`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/client-only/without/`) | ||
| }) | ||
| it(`client-only with`, () => { | ||
| cy.visit(`/fs-api/with/with/`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/fs-api/with/with/`) | ||
| }) | ||
| it(`client-only without`, () => { | ||
| cy.visit(`/fs-api/without/without`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/fs-api/without/without/`) | ||
| }) | ||
| it(`query-param-hash with`, () => { | ||
| cy.visit(`/page-2/?query_param=hello#anchor`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello#anchor`) | ||
| }) | ||
| it(`query-param-hash without`, () => { | ||
| cy.visit(`/page-2?query_param=hello#anchor`) | ||
| .waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello#anchor`) | ||
| }) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.