-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): Adapters #38232
Merged
+5,816
−284
Merged
feat(gatsby): Adapters #38232
Changes from all commits
Commits
Show all changes
170 commits
Select commit
Hold shift + click to select a range
5bc0b1f
initial - cache restoration
pieh 72f6ecd
snapshot
pieh ec6e85b
cache.restore() return comment
pieh 18a6ef8
redirect status
pieh cd8d2c8
note about named wildcard paths
pieh 60dfb1b
don't pass named wildcards to function manifest
pieh c70cebb
fix status code resolution for redirects
pieh 01fb83d
scaffold initial gatsby-adapter-netlify package and use if for dev pu…
pieh 9e6a35a
build adapter package as ESM and load it as such, so we can use ESM-o…
pieh 32670e1
no require in esm world
pieh 671a7d2
add redirect headers
pieh 100c8d1
start scaffolding autoinstallation of adapters
pieh c7676c3
webpack assets + unmanaged assets (start)
pieh ceaf740
static queries, app-data.json, minor refactors and initial setup for …
pieh 62cdff2
move adapter version to 1.0.0
LekoArts 98da13d
generalize get-latest-apis for adapters
LekoArts 1975ae9
handle JS files in get-latest-gatsby-files
LekoArts 606c604
set peerDep
LekoArts 0292cb2
use other testing pkg
LekoArts 7da3c66
get installation, discovery, re-using working
LekoArts a983541
Merge branch 'master' into feat/adapters
LekoArts 3f1659a
update versions
LekoArts ac6ecf3
move adapter init into its own file
LekoArts df07cda
add version checking
LekoArts 818c1ed
adjust comment
LekoArts 19828e9
move stuff around
LekoArts 9499cff
Merge branch 'master' into feat/adapters
LekoArts 207bddf
feat: add headers to gatsby-config
LekoArts c74bd88
misc stuff
LekoArts 89cbde7
initial engine lambda
pieh 6089288
Merge branch 'master' into feat/adapters
LekoArts 0947ec2
start headers utils
LekoArts a9c37fb
Merge branch 'master' into feat/adapters
LekoArts ead3775
update deps
LekoArts afde61d
rewrite util
LekoArts d50aee2
linting
LekoArts ec3c643
convert to obj args
LekoArts f839663
remove todo comment
pieh f46f850
add requiredFiles to functions manifest
pieh a7c3746
make headers default to []
LekoArts 9ac1445
move constants to own file
LekoArts 53be6ec
export rankRoute
LekoArts 0fc101f
delete unneeded util
LekoArts dd2dd60
createHeadersMatcher initial impl
LekoArts 63913a7
use createHeadersMatcher
LekoArts a03b176
Merge branch 'master' into feat/adapters
LekoArts 20e5796
fix types
LekoArts e805df7
add http status code type
LekoArts 3eba52c
improve createHeadersMatcher and add tests
LekoArts 4ca653b
move adapterManager init to initialize func
LekoArts 610d3c0
adjust func args to move reporter and allow adapter options
LekoArts 8bc6351
add "adapter" option to gatsby-config
LekoArts 3916d79
put netlify adapter first in the list - it will only match when env v…
pieh 86429b1
kebabcase function name as function id
pieh b8bc194
export FunctionDefinition type
pieh 8fcca54
req.path -> req.url
pieh 657659a
initial functions wrapping/bundling in gatsby-adapter-netlify
pieh fee841d
remove netlify adapter from gatsby deps, add gatsby as devDep to adap…
pieh be62f1d
fix bundling function files containing [ ]
pieh 90423bf
unify tsconfig for adapter
LekoArts 900ed5e
add joi testing for adapter setting
LekoArts eb9f676
typescript: make bootstrap work again
LekoArts 9d0e6f8
generate redirect/rewrite rules, generate 2 variants of ssr-engine (…
pieh 80c45a4
move routes manifest handling into its own module
pieh b16febb
generate _headers rules
pieh ff7575f
add sorting to routesManifest
LekoArts dcec323
adjust graphql-engine bundling to not leave unreasolvable imports
pieh e2c2ed2
ssr lambda handling when it executes in read-only dir (use tmpdir() t…
pieh 05e82f6
inject functions matchPath into function bundle and generate req.para…
pieh 12410e3
serve api from path prefixed path as well
pieh d603ebb
add path prefix stripping in function wrapper
pieh a3db597
add cache store and restore in gatsby-adapter-netlify
pieh fd1e610
adjust internal 'lambda' name to 'function'
LekoArts 7b05c89
format lambda-handler
LekoArts 591a26b
misc changes
LekoArts d656565
missing rename
pieh d6b252c
compile gatsby-adapter-netlify to cjs
pieh 5f65225
add generator field
pieh 27b1eff
use netlify adpter when NETLIFY or NETLIFY_LOCAL env var is defined
pieh 94b9e9d
use headers from config for ssg/dsg
pieh 80c0142
allow specyfing different lmdb binary than current process, use abi83…
pieh c93dfde
get-route-path tests
LekoArts 0a869b6
manager refactoring + typo fix
LekoArts b46a390
initialize adapters e2e test
LekoArts 8c7d99e
cypress: remove viewPort configs
LekoArts 5f2f652
use next preid for netlify adapter
pieh cc34cc7
remove test adapter from adapters manifest
pieh 8bdaa2e
don't log errors when testing for user installed adapters
pieh 6956ad5
update adapters manifest
pieh a3d4278
cleanup gatsby-adapter-netlify a bit, add more public adapter related…
pieh 083fd85
e2e: update gitignore
LekoArts 0a7b663
resolve lmdb binary from lmdb package and not hardcode the forced path
pieh 5dc6576
gatsby-plugin-image add downlevelIteration
pieh 8ff7b22
fix persisted redux keys
pieh ae403c0
update snapshot and mocks
pieh f5711f3
fix: only run adapters during gatsby build
LekoArts c615f04
resolve netlify functions runtime deps from adapter context
pieh 62a298a
improve public typings
LekoArts 36df358
adding adapter to e2e test so that dev-cli copies stuff over
LekoArts 5aa1126
Merge branch 'master' into feat/adapters
LekoArts f6326af
update babel-preset-gatsby-package dep
LekoArts 9791bd2
e2e: test functions and assets
LekoArts 0fc4bd1
e2e: client-only WIP
LekoArts 047be98
e2e: improve basics
LekoArts c532978
e2e: improve client-only
LekoArts 1740f9e
e2e: redirects
LekoArts 1e31d19
merge _headers and _redirects instead of overwriting it
pieh 58be681
Merge branch 'master' into feat/adapters
LekoArts 30f12b0
apply trailing slash option + pass through trailingSlash & pathPrefix
LekoArts cbd0374
add unit tests for manager
LekoArts f358c43
improve manager tests
LekoArts d5d1720
update types
LekoArts faa4b2a
improve e2e tests
LekoArts 9e2935c
add excludeDatastoreFromEngineFunction flow
pieh 903dd04
normalize path after globbing
pieh d288e86
mock shouldBundleDatastore
pieh 46ee1f3
rename adapter config types to be less confusing with gatsby-config
pieh a00a634
keep same obfuscated path between builds
pieh 140f62f
normalize more paths
pieh ce2f692
support custom 404/500 page for serverless functions
LekoArts 63d3f9d
update snapshot
LekoArts 305e96f
generate relative imports in function
pieh b4e5c56
skip trying to copy data to tmp if we are downloading from cdn
pieh e9624aa
improve TS types
LekoArts e42ab8f
mock uuid
LekoArts ddda443
put requiredFiles in correct place heh
LekoArts 56824a1
typo
LekoArts 3e88e97
snapshot
LekoArts 016d697
handle GATSBY_EXCLUDE_DATASTORE_FROM_BUNDLE env var
pieh 342f2f9
improve README & update types
LekoArts 81780af
code block
LekoArts 6a18b5c
handle partytown routes
pieh bac5412
handle slices (html and slice-data)
pieh 363e6c5
handle chunk-map and webpack.stats
pieh 4ddabf3
feat: add name to functionsManifest & displayName to Netlify
LekoArts e1e2201
update snapshot
LekoArts 9b2e632
rename headers constants
pieh c0a5402
handle image-cdn and file-cdn
pieh d294c7d
update routesManifest test fixture and snapshot
pieh 15ec313
don't log unmanaged static assets anymore
pieh b5ac1e3
handle some TODOs
LekoArts 6496cf9
add 'adapters' to feature list
pieh 6662f45
tmp: make peer dependency allow to use with canaries
pieh 8ba5fae
feat: add 'supports' to config to let adapters provide some capabilit…
pieh 7f1be53
Merge branch 'master' into feat/adapters
LekoArts 2adc306
adjust some text
LekoArts 46cbbff
apply trailingSlash to tests and other stuff, add utils
LekoArts d68acb2
readme and package.json update
LekoArts d1db998
fix ts versions
LekoArts 2cef296
enable typecheck for adapters.js
pieh 24bae2a
don't try to use install adapter if no version matches, install versi…
pieh 6d76ebc
allow adapter to disable prior deployment plugins
pieh f837c54
disable gatsby-plugin-netlify when using gatsby-adapter-netlify
pieh 8bb775e
fix ts
pieh 7d848f6
handle non-alpha-numerc paths
pieh ec8839f
verbose log adapter package that is being installed
pieh f9857be
only try to restore cache if payload provided
pieh 36891f6
memoize cache utils
pieh 6436295
log adapter version
pieh d07fe0d
handle body parsing in produced api functions
pieh 81bc037
Merge remote-tracking branch 'origin/master' into feat/adapters
pieh ce9e7a8
properly handle cases when body parsing already happened and when the…
pieh 902d30f
handle body parsing config in generated function
pieh ca225bf
drop unused
pieh 092b92e
remove redirects created by previous deployment plugins
pieh fa7dc92
properly handle default body for status responses in api functions
pieh 17d4a58
put some dev logs as verbose to limit regular terminal output
pieh 3787d92
put some dev logs as verbose to limit regular terminal output vol2
pieh 3dbe567
maybe deflake function tests
pieh 92a7996
maybe precompile api functions in develop function tests
pieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 @@ | ||
node_modules/ | ||
.cache/ | ||
public | ||
|
||
# Local Netlify folder | ||
.netlify | ||
|
||
# Cypress output | ||
cypress/videos/ | ||
cypress/screenshots/ | ||
|
||
# Custom .yarnrc file for gatsby-dev on Yarn 3 | ||
.yarnrc.yml |
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,27 @@ | ||
# adapters | ||
|
||
E2E testing suite for Gatsby's [adapters](http://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/adapters/) feature. | ||
If possible, run the tests locally with a CLI. Otherwise deploy the site to the target platform and run Cypress on the deployed URL. | ||
|
||
Adapters being tested: | ||
|
||
- [gatsby-adapter-netlify](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-adapter-netlify) | ||
|
||
## Usage | ||
|
||
- To run all tests, use `npm run test` | ||
- To run individual tests, use `npm run test:%NAME` where `test:%NAME` is the script, e.g. `npm run test:netlify` | ||
|
||
If you want to open Cypress locally as a UI, you can run the `:debug` scripts. For example, `npm run test:netlify:debug` to test the Netlify Adapter with Cypress open. | ||
|
||
### Adding a new adapter | ||
|
||
- Add a new Cypress config inside `cypress/configs` | ||
- Add a new `test:` script that should run `start-server-and-test`. You can check what e.g. `test:netlify` is doing. | ||
- Run the Cypress test suites that should work. If you want to exclude a spec, you can use Cypress' [excludeSpecPattern](https://docs.cypress.io/guides/references/configuration#excludeSpecPattern) | ||
|
||
## External adapters | ||
|
||
As mentioned in [Creating an Adapter](https://gatsbyjs.com/docs/how-to/previews-deploys-hosting/creating-an-adapter/#testing) you can use this test suite for your own adapter. | ||
|
||
Copy the whole `adapters` folder, and follow [adding a new adapter](#adding-a-new-adapter). |
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,2 @@ | ||
export const title = "Adapters" | ||
export const siteDescription = "End-to-End tests for Gatsby Adapters" |
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,11 @@ | ||
import { defineConfig } from "cypress" | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: `http://localhost:9000`, | ||
projectId: `4enh4m`, | ||
videoUploadOnPasses: false, | ||
experimentalRunAllSpecs: true, | ||
retries: 2, | ||
}, | ||
}) |
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 { defineConfig } from "cypress" | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: `http://localhost:8888`, | ||
// Netlify doesn't handle trailing slash behaviors really, so no use in testing it | ||
excludeSpecPattern: [`cypress/e2e/trailing-slash.cy.ts`,], | ||
projectId: `4enh4m`, | ||
videoUploadOnPasses: false, | ||
experimentalRunAllSpecs: true, | ||
retries: 2, | ||
}, | ||
}) |
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,44 @@ | ||
import { title } from "../../constants" | ||
|
||
describe('Basics', () => { | ||
beforeEach(() => { | ||
cy.intercept("/gatsby-icon.png").as("static-folder-image") | ||
cy.intercept("/static/astro-**.png").as("img-import") | ||
|
||
cy.visit('/').waitForRouteChange() | ||
}) | ||
|
||
it('should display index page', () => { | ||
cy.get('h1').should('have.text', title) | ||
cy.title().should('eq', 'Adapters E2E') | ||
}) | ||
// If this test fails, run "gatsby build" and retry | ||
it('should serve assets from "static" folder', () => { | ||
cy.wait("@static-folder-image").should(req => { | ||
expect(req.response.statusCode).to.be.gte(200).and.lt(400) | ||
}) | ||
|
||
cy.get('[alt="Gatsby Monogram Logo"]').should('be.visible') | ||
}) | ||
it('should serve assets imported through webpack', () => { | ||
cy.wait("@img-import").should(req => { | ||
expect(req.response.statusCode).to.be.gte(200).and.lt(400) | ||
}) | ||
|
||
cy.get('[alt="Gatsby Astronaut"]').should('be.visible') | ||
}) | ||
it(`should show custom 404 page on invalid URL`, () => { | ||
cy.visit(`/non-existent-page`, { | ||
failOnStatusCode: false, | ||
}) | ||
|
||
cy.get('h1').should('have.text', 'Page not found') | ||
}) | ||
it('should apply CSS', () => { | ||
cy.get(`h1`).should( | ||
`have.css`, | ||
`color`, | ||
`rgb(21, 21, 22)` | ||
) | ||
}) | ||
}) |
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,89 @@ | ||
Cypress.on('uncaught:exception', (err) => { | ||
if (err.message.includes('Minified React error')) { | ||
return false | ||
} | ||
}) | ||
|
||
describe('Sub-Router', () => { | ||
const routes = [ | ||
{ | ||
path: "/routes/sub-router", | ||
marker: "index", | ||
label: "Index route" | ||
}, | ||
{ | ||
path: `/routes/sub-router/page/profile`, | ||
marker: `profile`, | ||
label: `Dynamic route`, | ||
}, | ||
{ | ||
path: `/routes/sub-router/not-found`, | ||
marker: `NotFound`, | ||
label: `Default route (not found)`, | ||
}, | ||
{ | ||
path: `/routes/sub-router/nested`, | ||
marker: `nested-page/index`, | ||
label: `Index route inside nested router`, | ||
}, | ||
{ | ||
path: `/routes/sub-router/nested/foo`, | ||
marker: `nested-page/foo`, | ||
label: `Dynamic route inside nested router`, | ||
}, | ||
{ | ||
path: `/routes/sub-router/static`, | ||
marker: `static-sibling`, | ||
label: `Static route that is a sibling to client only path`, | ||
}, | ||
] as const | ||
|
||
routes.forEach(({ path, marker, label }) => { | ||
it(label, () => { | ||
cy.visit(path).waitForRouteChange() | ||
cy.get(`[data-testid="dom-marker"]`).contains(marker) | ||
|
||
cy.url().should( | ||
`match`, | ||
new RegExp(`^${Cypress.config().baseUrl + path}/?$`) | ||
) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Paths', () => { | ||
const routes = [ | ||
{ | ||
name: 'client-only', | ||
param: 'dune', | ||
}, | ||
{ | ||
name: 'client-only/wildcard', | ||
param: 'atreides/harkonnen', | ||
}, | ||
{ | ||
name: 'client-only/named-wildcard', | ||
param: 'corinno/fenring', | ||
}, | ||
] as const | ||
|
||
for (const route of routes) { | ||
it(`should return "${route.name}" result`, () => { | ||
cy.visit(`/routes/${route.name}${route.param ? `/${route.param}` : ''}`).waitForRouteChange() | ||
cy.get("[data-testid=title]").should("have.text", route.name) | ||
cy.get("[data-testid=params]").should("have.text", route.param) | ||
}) | ||
} | ||
}) | ||
|
||
describe('Prioritize', () => { | ||
it('should prioritize static page over matchPath page with wildcard', () => { | ||
cy.visit('/routes/client-only/prioritize').waitForRouteChange() | ||
cy.get("[data-testid=title]").should("have.text", "client-only/prioritize static") | ||
}) | ||
it('should return result for wildcard on nested prioritized path', () => { | ||
cy.visit('/routes/client-only/prioritize/nested').waitForRouteChange() | ||
cy.get("[data-testid=title]").should("have.text", "client-only/prioritize matchpath") | ||
cy.get("[data-testid=params]").should("have.text", "nested") | ||
}) | ||
}) |
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,14 @@ | ||
import { title } from "../../constants" | ||
|
||
describe("Deferred Static Generation (DSG)", () => { | ||
it("should work correctly", () => { | ||
cy.visit("/routes/dsg/static").waitForRouteChange() | ||
|
||
cy.get("h1").contains("DSG") | ||
}) | ||
it("should work with page queries", () => { | ||
cy.visit("/routes/dsg/graphql-query").waitForRouteChange() | ||
|
||
cy.get(`[data-testid="title"]`).should("have.text", title) | ||
}) | ||
}) |
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,27 @@ | ||
const routes = [ | ||
{ | ||
name: 'static', | ||
param: '', | ||
}, | ||
{ | ||
name: 'param', | ||
param: 'dune', | ||
}, | ||
{ | ||
name: 'wildcard', | ||
param: 'atreides/harkonnen' | ||
}, | ||
{ | ||
name: 'named-wildcard', | ||
param: 'corinno/fenring' | ||
} | ||
] as const | ||
|
||
describe('Functions', () => { | ||
for (const route of routes) { | ||
it(`should return "${route.name}" result`, () => { | ||
cy.request(`/api/${route.name}${route.param ? `/${route.param}` : ''}`).as(`req-${route.name}`) | ||
cy.get(`@req-${route.name}`).its('body').should('contain', `Hello World${route.param ? ` from ${route.param}` : ``}`) | ||
}) | ||
} | ||
}) |
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,57 @@ | ||
import { applyTrailingSlashOption } from "../../utils" | ||
|
||
Cypress.on("uncaught:exception", (err) => { | ||
if (err.message.includes("Minified React error")) { | ||
return false | ||
} | ||
}) | ||
|
||
const TRAILING_SLASH = Cypress.env(`TRAILING_SLASH`) || `never` | ||
|
||
// Those tests won't work using `gatsby serve` because it doesn't support redirects | ||
|
||
describe("Redirects", () => { | ||
it("should redirect from non-existing page to existing", () => { | ||
cy.visit(applyTrailingSlashOption(`/redirect`, TRAILING_SLASH), { | ||
failOnStatusCode: false, | ||
}).waitForRouteChange() | ||
.assertRoute(applyTrailingSlashOption(`/routes/redirect/hit`, TRAILING_SLASH)) | ||
|
||
cy.get(`h1`).should(`have.text`, `Hit`) | ||
}) | ||
it("should respect that pages take precedence over redirects", () => { | ||
cy.visit(applyTrailingSlashOption(`/routes/redirect/existing`, TRAILING_SLASH), { | ||
failOnStatusCode: false, | ||
}).waitForRouteChange() | ||
.assertRoute(applyTrailingSlashOption(`/routes/redirect/existing`, TRAILING_SLASH)) | ||
|
||
cy.get(`h1`).should(`have.text`, `Existing`) | ||
}) | ||
it("should support hash parameter on direct visit", () => { | ||
cy.visit(applyTrailingSlashOption(`/redirect`, TRAILING_SLASH) + `#anchor`, { | ||
failOnStatusCode: false, | ||
}).waitForRouteChange() | ||
|
||
cy.location(`pathname`).should(`equal`, applyTrailingSlashOption(`/routes/redirect/hit`, TRAILING_SLASH)) | ||
cy.location(`hash`).should(`equal`, `#anchor`) | ||
cy.location(`search`).should(`equal`, ``) | ||
}) | ||
it("should support search parameter on direct visit", () => { | ||
cy.visit(applyTrailingSlashOption(`/redirect`, TRAILING_SLASH) + `?query_param=hello`, { | ||
failOnStatusCode: false, | ||
}).waitForRouteChange() | ||
|
||
cy.location(`pathname`).should(`equal`, applyTrailingSlashOption(`/routes/redirect/hit`, TRAILING_SLASH)) | ||
cy.location(`hash`).should(`equal`, ``) | ||
cy.location(`search`).should(`equal`, `?query_param=hello`) | ||
}) | ||
it("should support search & hash parameter on direct visit", () => { | ||
cy.visit(applyTrailingSlashOption(`/redirect`, TRAILING_SLASH) + `?query_param=hello#anchor`, { | ||
failOnStatusCode: false, | ||
}).waitForRouteChange() | ||
|
||
cy.location(`pathname`).should(`equal`, applyTrailingSlashOption(`/routes/redirect/hit`, TRAILING_SLASH)) | ||
cy.location(`hash`).should(`equal`, `#anchor`) | ||
cy.location(`search`).should(`equal`, `?query_param=hello`) | ||
}) | ||
}) |
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,9 @@ | ||
import { siteDescription } from "../../constants" | ||
|
||
describe("Slices", () => { | ||
it("should work correctly", () => { | ||
cy.visit('/').waitForRouteChange() | ||
|
||
cy.get(`footer`).should("have.text", siteDescription) | ||
}) | ||
}) |
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,39 @@ | ||
const staticPath = "/routes/ssr/static" | ||
const paramPath = "/routes/ssr/param" | ||
|
||
describe("Server Side Rendering (SSR)", () => { | ||
it(`direct visit no query params (${staticPath})`, () => { | ||
cy.visit(staticPath).waitForRouteChange() | ||
cy.get(`[data-testid="query"]`).contains(`{}`) | ||
cy.get(`[data-testid="params"]`).contains(`{}`) | ||
}) | ||
|
||
it(`direct visit with query params (${staticPath})`, () => { | ||
cy.visit(staticPath + `?foo=bar`).waitForRouteChange() | ||
cy.get(`[data-testid="query"]`).contains(`{"foo":"bar"}`) | ||
cy.get(`[data-testid="params"]`).contains(`{}`) | ||
}) | ||
|
||
it(`direct visit no query params (${paramPath})`, () => { | ||
cy.visit(paramPath + `/foo`).waitForRouteChange() | ||
cy.get(`[data-testid="query"]`).contains(`{}`) | ||
cy.get(`[data-testid="params"]`).contains(`{"param":"foo"}`) | ||
}) | ||
|
||
it(`direct visit with query params (${paramPath})`, () => { | ||
cy.visit(paramPath + `/foo` + `?foo=bar`).waitForRouteChange() | ||
cy.get(`[data-testid="query"]`).contains(`{"foo":"bar"}`) | ||
cy.get(`[data-testid="params"]`).contains(`{"param":"foo"}`) | ||
}) | ||
|
||
it(`should display custom 500 page`, () => { | ||
const errorPath = `/routes/ssr/error-path` | ||
|
||
cy.visit(errorPath, { failOnStatusCode: false }).waitForRouteChange() | ||
|
||
cy.location(`pathname`) | ||
.should(`equal`, errorPath) | ||
.get(`h1`) | ||
.should(`have.text`, `INTERNAL SERVER ERROR`) | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep