diff --git a/e2e-tests/adapters/cypress/e2e/client-only.cy.ts b/e2e-tests/adapters/cypress/e2e/client-only.cy.ts index fa323d77c59b3..3b50f0d7ceaa2 100644 --- a/e2e-tests/adapters/cypress/e2e/client-only.cy.ts +++ b/e2e-tests/adapters/cypress/e2e/client-only.cy.ts @@ -65,10 +65,42 @@ describe("Paths", () => { name: "client-only/named-wildcard", param: "corinno/fenring", }, + { + name: "client-only-created-with-gatsby-node", + // matching on page.path + param: "", + }, + { + name: "client-only-created-with-gatsby-node", + // matching on page.matchPath + param: "match-path", + }, + { + name: "client-only-param-created-with-gatsby-node", + // matching on page.path + param: "", + }, + { + name: "client-only-param-created-with-gatsby-node", + // matching on page.matchPath + param: "single-param", + }, + { + name: "client-only-wildcard-created-with-gatsby-node", + // matching on page.path + param: "", + }, + { + name: "client-only-wildcard-created-with-gatsby-node", + // matching on page.matchPath + param: "deeply/nested/path", + }, ] as const for (const route of routes) { - it(`should return "${route.name}" result`, () => { + it(`should return "${route.name}${ + route.param ? `/${route.param}` : "" + }" result`, () => { cy.visit( `/routes/${route.name}${route.param ? `/${route.param}` : ""}` ).waitForRouteChange() diff --git a/e2e-tests/adapters/gatsby-node.ts b/e2e-tests/adapters/gatsby-node.ts index f0c6697d1f932..386051df4f52d 100644 --- a/e2e-tests/adapters/gatsby-node.ts +++ b/e2e-tests/adapters/gatsby-node.ts @@ -53,6 +53,28 @@ export const createPages: GatsbyNode["createPages"] = async ({ } `) + createPage({ + path: applyTrailingSlashOption( + `/routes/client-only-param-created-with-gatsby-node`, + TRAILING_SLASH + ), + matchPath: `/routes/client-only-param-created-with-gatsby-node/:id`, + component: path.resolve(`./src/templates/match-path-with-gatsby-node.jsx`), + context: { + title: `client-only-param-created-with-gatsby-node`, + }, + }) + createPage({ + path: applyTrailingSlashOption( + `/routes/client-only-wildcard-created-with-gatsby-node`, + TRAILING_SLASH + ), + matchPath: `/routes/client-only-wildcard-created-with-gatsby-node/*id`, + component: path.resolve(`./src/templates/match-path-with-gatsby-node.jsx`), + context: { + title: `client-only-wildcard-created-with-gatsby-node`, + }, + }) createPage({ path: applyTrailingSlashOption( `/routes/ssg/remote-file-data-from-context/`, diff --git a/e2e-tests/adapters/src/templates/match-path-with-gatsby-node.jsx b/e2e-tests/adapters/src/templates/match-path-with-gatsby-node.jsx new file mode 100644 index 0000000000000..0d5a1b73e6501 --- /dev/null +++ b/e2e-tests/adapters/src/templates/match-path-with-gatsby-node.jsx @@ -0,0 +1,15 @@ +import React from "react" +import Layout from "../components/layout" + +const ClientOnlyParamsCreatedWithGatsbyNode = props => ( + +

{props.pageContext.title}

+

{props.params.id}

+
+) + +export const Head = () => ( + Client-Only Params created with gatsby-node +) + +export default ClientOnlyParamsCreatedWithGatsbyNode