mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
rip. you served a purpose once, but now you're just getting in the way. this improves typesafety quite a bit, because `BrowserInterface` had a whole bunch of random `any`s everywhere also - removes `evalAsync`. no idea why that was needed, but we're happily using promises in normal eval, so it can be dropped - adds more safety to `chain`
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('rsc-query-routing', () => {
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should contain rsc query in rsc request when redirect the page', async () => {
|
|
const browser = await next.browser('/redirect')
|
|
|
|
const rscRequestUrls: string[] = []
|
|
browser.on('request', (req) => {
|
|
if (req.url().includes('?_rsc=')) {
|
|
rscRequestUrls.push(req.url())
|
|
}
|
|
})
|
|
|
|
// Click redirect link
|
|
const link = await browser.elementByCss('a')
|
|
await link.click()
|
|
|
|
// Wait for the page load to be completed
|
|
await retry(async () => {
|
|
expect(await browser.elementByCss('h1').text()).toBe('Redirect Dest')
|
|
})
|
|
|
|
// The redirect source and dest urls should both contain the rsc query
|
|
expect(rscRequestUrls[0]).toContain('/redirect/source')
|
|
expect(rscRequestUrls[1]).toContain('/redirect/dest')
|
|
})
|
|
|
|
it('should contain rsc query in rsc request when rewrite the page', async () => {
|
|
const browser = await next.browser('/rewrite')
|
|
|
|
const rscRequestUrls: string[] = []
|
|
browser.on('request', (req) => {
|
|
if (req.url().includes('?_rsc=')) {
|
|
rscRequestUrls.push(req.url())
|
|
}
|
|
})
|
|
|
|
// Click redirect link
|
|
const link = await browser.elementByCss('a')
|
|
await link.click()
|
|
|
|
// Wait for the page load to be completed
|
|
await retry(async () => {
|
|
expect(await browser.elementByCss('h1').text()).toBe('Rewrite Dest')
|
|
})
|
|
|
|
// The rewrite source url should contain the rsc query
|
|
expect(rscRequestUrls[0]).toContain('/rewrite/source')
|
|
})
|
|
})
|