(isDev: boolean)
| 18 | let appPort |
| 19 | |
| 20 | const runTests = (isDev: boolean) => { |
| 21 | it('should apply temporary redirect when visited directly for GSSP page', async () => { |
| 22 | const res = await fetchViaHTTP( |
| 23 | appPort, |
| 24 | '/gssp-blog/redirect-1', |
| 25 | undefined, |
| 26 | { |
| 27 | redirect: 'manual', |
| 28 | } |
| 29 | ) |
| 30 | expect(res.status).toBe(307) |
| 31 | |
| 32 | const { pathname } = new URL(res.headers.get('location')) |
| 33 | |
| 34 | expect(pathname).toBe('/404') |
| 35 | }) |
| 36 | |
| 37 | it('should apply permanent redirect when visited directly for GSSP page', async () => { |
| 38 | const res = await fetchViaHTTP( |
| 39 | appPort, |
| 40 | '/gssp-blog/redirect-permanent', |
| 41 | undefined, |
| 42 | { |
| 43 | redirect: 'manual', |
| 44 | } |
| 45 | ) |
| 46 | expect(res.status).toBe(308) |
| 47 | |
| 48 | const { pathname } = new URL(res.headers.get('location')) |
| 49 | |
| 50 | expect(pathname).toBe('/404') |
| 51 | expect(res.headers.get('refresh')).toMatch(/url=\/404/) |
| 52 | }) |
| 53 | |
| 54 | it('should apply statusCode 301 redirect when visited directly for GSSP page', async () => { |
| 55 | const res = await fetchViaHTTP( |
| 56 | appPort, |
| 57 | '/gssp-blog/redirect-statusCode-301', |
| 58 | undefined, |
| 59 | { |
| 60 | redirect: 'manual', |
| 61 | } |
| 62 | ) |
| 63 | expect(res.status).toBe(301) |
| 64 | |
| 65 | const { pathname } = new URL(res.headers.get('location')) |
| 66 | |
| 67 | expect(pathname).toBe('/404') |
| 68 | expect(res.headers.get('refresh')).toBe(null) |
| 69 | }) |
| 70 | |
| 71 | it('should apply statusCode 303 redirect when visited directly for GSSP page', async () => { |
| 72 | const res = await fetchViaHTTP( |
| 73 | appPort, |
| 74 | '/gssp-blog/redirect-statusCode-303', |
| 75 | undefined, |
| 76 | { |
| 77 | redirect: 'manual', |
no test coverage detected