Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion e2e-tests/adapters/cypress/e2e/client-only.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 22 additions & 0 deletions e2e-tests/adapters/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/`,
Expand Down
15 changes: 15 additions & 0 deletions e2e-tests/adapters/src/templates/match-path-with-gatsby-node.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react"
import Layout from "../components/layout"

const ClientOnlyParamsCreatedWithGatsbyNode = props => (
<Layout>
<h1 data-testid="title">{props.pageContext.title}</h1>
<p data-testid="params">{props.params.id}</p>
</Layout>
)

export const Head = () => (
<title>Client-Only Params created with gatsby-node</title>
)

export default ClientOnlyParamsCreatedWithGatsbyNode
Loading