({ isDev = false, isExport = false, isPages404 = false })
| 25 | let app |
| 26 | |
| 27 | function runTests({ isDev = false, isExport = false, isPages404 = false }) { |
| 28 | let notFoundContent = 'custom error' |
| 29 | // let badRequestContent = 'custom error' |
| 30 | |
| 31 | if (isPages404) { |
| 32 | // badRequestContent = 'Bad Request' |
| 33 | notFoundContent = 'custom 404' |
| 34 | } |
| 35 | if (isExport && isPages404) { |
| 36 | notFoundContent = 'custom 404' |
| 37 | // badRequestContent = 'custom 404' |
| 38 | } |
| 39 | |
| 40 | const didNotReload = async (browser) => { |
| 41 | for (let i = 0; i < 4; i++) { |
| 42 | await waitFor(500) |
| 43 | |
| 44 | const result = await browser.eval('window.errorLoad') |
| 45 | |
| 46 | if (result !== true) { |
| 47 | throw new Error( |
| 48 | `did not find window.errorLoad, current url: ${await browser.url()}` |
| 49 | ) |
| 50 | } |
| 51 | |
| 52 | if (isDev) break |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if (!isExport) { |
| 57 | it('should normalize repeated slashes in redirects correctly', async () => { |
| 58 | const res = await fetchViaHTTP( |
| 59 | appPort, |
| 60 | '/redirect-forward-slashes', |
| 61 | undefined, |
| 62 | { |
| 63 | redirect: 'manual', |
| 64 | } |
| 65 | ) |
| 66 | |
| 67 | expect(res.status).toBe(307) |
| 68 | const parsedUrl = new URL(res.headers.get('location')) |
| 69 | |
| 70 | expect(parsedUrl.hostname).toBeOneOf(['localhost', '127.0.0.1']) |
| 71 | expect(parsedUrl.pathname).toBe('/test/google.com') |
| 72 | expect(Object.fromEntries(parsedUrl.searchParams.entries())).toEqual({}) |
| 73 | expect(await res.text()).toBe('/test/google.com') |
| 74 | |
| 75 | const res2 = await fetchViaHTTP( |
| 76 | appPort, |
| 77 | '/redirect-back-slashes', |
| 78 | undefined, |
| 79 | { |
| 80 | redirect: 'manual', |
| 81 | } |
| 82 | ) |
| 83 | |
| 84 | expect(res2.status).toBe(307) |
no test coverage detected