diff --git a/e2e-tests/production-runtime/cypress/integration/redirects.js b/e2e-tests/production-runtime/cypress/integration/redirects.js index 9d6252a2b2971..49229e27fa8dc 100644 --- a/e2e-tests/production-runtime/cypress/integration/redirects.js +++ b/e2e-tests/production-runtime/cypress/integration/redirects.js @@ -9,6 +9,7 @@ describe(`Redirects`, () => { cy.get(`h1`).invoke(`text`).should(`contain`, `Hi from the long page`) }) + it(`are case sensitive when ignoreCase is set to false`, () => { cy.visit(`/PAGINA-larga`, { failOnStatusCode: false }).waitForRouteChange() @@ -57,4 +58,67 @@ describe(`Redirects`, () => { }) }) }) + + it(`should support hash parameter with Link component`, () => { + cy.visit(`/`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.getTestElement(`redirect-two-anchor`).click().waitForRouteChange() + cy.location(`pathname`).should(`equal`, `/redirect-search-hash`) + cy.location(`hash`).should(`equal`, `#anchor`) + cy.location(`search`).should(`equal`, ``) + }) + + it(`should support hash parameter on direct visit`, () => { + cy.visit(`/redirect-two#anchor`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.location(`pathname`).should(`equal`, `/redirect-search-hash/`) + cy.location(`hash`).should(`equal`, `#anchor`) + cy.location(`search`).should(`equal`, ``) + }) + + it(`should support search parameter with Link component`, () => { + cy.visit(`/`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.getTestElement(`redirect-two-search`).click().waitForRouteChange() + cy.location(`pathname`).should(`equal`, `/redirect-search-hash`) + cy.location(`hash`).should(`equal`, ``) + cy.location(`search`).should(`equal`, `?query_param=hello`) + }) + + it(`should support search parameter on direct visit`, () => { + cy.visit(`/redirect-two?query_param=hello`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.location(`pathname`).should(`equal`, `/redirect-search-hash/`) + cy.location(`hash`).should(`equal`, ``) + cy.location(`search`).should(`equal`, `?query_param=hello`) + }) + + it(`should support search & hash parameter with Link component`, () => { + cy.visit(`/`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.getTestElement(`redirect-two-search-anchor`).click().waitForRouteChange() + cy.location(`pathname`).should(`equal`, `/redirect-search-hash`) + cy.location(`hash`).should(`equal`, `#anchor`) + cy.location(`search`).should(`equal`, `?query_param=hello`) + }) + + it(`should support search & hash parameter on direct visit`, () => { + cy.visit(`/redirect-two?query_param=hello#anchor`, { + failOnStatusCode: false, + }).waitForRouteChange() + + cy.location(`pathname`).should(`equal`, `/redirect-search-hash/`) + cy.location(`hash`).should(`equal`, `#anchor`) + cy.location(`search`).should(`equal`, `?query_param=hello`) + }) }) diff --git a/e2e-tests/production-runtime/gatsby-node.js b/e2e-tests/production-runtime/gatsby-node.js index f17913e6bd4ac..88768d87d0fa9 100644 --- a/e2e-tests/production-runtime/gatsby-node.js +++ b/e2e-tests/production-runtime/gatsby-node.js @@ -145,6 +145,13 @@ exports.createPages = ({ actions: { createPage, createRedirect } }) => { redirectInBrowser: true, ignoreCase: true, }) + + createRedirect({ + fromPath: `/redirect-two`, + toPath: `/redirect-search-hash`, + isPermanent: true, + redirectInBrowser: true, + }) } exports.onCreatePage = ({ page, actions }) => { diff --git a/e2e-tests/production-runtime/package.json b/e2e-tests/production-runtime/package.json index 5a8df9551cb00..546fb23aca7d2 100644 --- a/e2e-tests/production-runtime/package.json +++ b/e2e-tests/production-runtime/package.json @@ -33,7 +33,7 @@ "build": "cross-env CYPRESS_SUPPORT=y gatsby build", "build:offline": "cross-env TEST_PLUGIN_OFFLINE=y CYPRESS_SUPPORT=y gatsby build", "develop": "gatsby develop", - "format": "prettier --write '**/*.js'", + "format": "prettier --write '**/*.js' --ignore-path .gitignore", "serve": "gatsby serve", "start": "npm run develop", "test": "npm run build && npm run start-server-and-test && npm run test-env-vars", diff --git a/e2e-tests/production-runtime/src/pages/index.js b/e2e-tests/production-runtime/src/pages/index.js index d23c2feabd487..51e4116090862 100644 --- a/e2e-tests/production-runtime/src/pages/index.js +++ b/e2e-tests/production-runtime/src/pages/index.js @@ -92,6 +92,27 @@ const IndexPage = ({ pageContext }) => ( Go to client route splat (splat: blah/blah/blah) +
This should be a page that also has search & hash
+