forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic smoke test for per-segment fetching
We can't test per-segment fetching end-to-end yet because the client behavior hasn't been implemented. These are basic smoke tests to demonstrate that the server correctly responds to a request. We will replace them with proper e2e tests once more of the feature has been implemented.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
test/e2e/app-dir/ppr-navigations/simple/per-segment-prefetching.test.ts
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,46 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('per segment prefetching', () => { | ||
if ((global as any).isNextDev) { | ||
test('ppr is disabled in dev', () => {}) | ||
return | ||
} | ||
|
||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
// This feature is only partially implemented; the client does not yet issue | ||
// these types of requests. This tests that the server responds correctly. | ||
// TODO: Replace with e2e tests once more is implemented. | ||
|
||
it('prefetch an individual segment', async () => { | ||
const response = await next.fetch('/en', { | ||
headers: { | ||
RSC: '1', | ||
'Next-Router-Prefetch': '1', | ||
'Next-Router-Segment-Prefetch': '/', | ||
}, | ||
}) | ||
expect(response.status).toBe(200) | ||
const responseText = await response.text() | ||
expect(responseText.trim()).toBe( | ||
// The actual data is not yet generated, but this indicates that the | ||
// request was handled correctly. | ||
'TODO (Per Segment Prefetching): Not yet implemented' | ||
) | ||
}) | ||
|
||
it('respond with 404 if the segment does not have prefetch data', async () => { | ||
const response = await next.fetch('/en', { | ||
headers: { | ||
RSC: '1', | ||
'Next-Router-Prefetch': '1', | ||
'Next-Router-Segment-Prefetch': '/does-not-exist', | ||
}, | ||
}) | ||
expect(response.status).toBe(404) | ||
const responseText = await response.text() | ||
expect(responseText.trim()).toBe('') | ||
}) | ||
}) |