Skip to content

Commit

Permalink
fix: fix e2e static regeneration test code (#2398)
Browse files Browse the repository at this point in the history
  • Loading branch information
KensukeTakahara committed Mar 15, 2022
1 parent 416adf1 commit e13e821
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -5,12 +5,19 @@ describe("ISR Tests", () => {
describe("SSG Redirect", () => {
it("non existing user redirects to home", () => {
const path = "/en/revalidated-ssg-pages/106";
cy.ensureRouteHasStatusCode(path, 307);
cy.request({ url: path }).then((response) => {
expect(response.status).to.equal(200);

const redirectedPath = "/";

// Verify redirect response
cy.verifyRedirect(path, redirectedPath, 307);
const redirectedPath = "/";
// Verify redirect response
expect(response.body).to.deep.equal({
pageProps: {
__N_REDIRECT: redirectedPath,
__N_REDIRECT_STATUS: 307
},
__N_SSG: true
});
});
});
});
describe("SSG page", () => {
Expand Down
1 change: 1 addition & 0 deletions packages/libs/core/src/handle/redirect.ts
Expand Up @@ -13,6 +13,7 @@ export const redirectByPageProps = (event: Event, route: RedirectRoute) => {
"cache-control",
route.headers?.cacheControl?.join(":") ?? ""
);
event.res.setHeader("Content-Type", "application/json");
event.res.statusCode = 200;

const body = {
Expand Down

0 comments on commit e13e821

Please sign in to comment.