Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add inline flight response reuse test #34364

Merged
merged 7 commits into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,6 +30,18 @@ export default function (context, { runtime, env }) {
expect(homeHTML).toContain('foo.client')
})

it('should reuse the inline flight response without sending extra requests', async () => {
let hasFlightRequest = false
const browser = await webdriver(context.appPort, '/')
browser.on('request', (request) => {
const url = request.url()
if (/__flight__=1/.test(url)) {
hasFlightRequest = true
}
})
expect(hasFlightRequest).toBe(false)
huozhi marked this conversation as resolved.
Show resolved Hide resolved
})

it('should support multi-level server component imports', async () => {
const html = await renderViaHTTP(context.appPort, '/multi')
expect(html).toContain('bar.server.js:')
Expand Down Expand Up @@ -127,14 +139,13 @@ export default function (context, { runtime, env }) {
const content = 'custom-404-page'
const page404HTML = await renderViaHTTP(context.appPort, '/404')
const pageUnknownHTML = await renderViaHTTP(context.appPort, '/no.where')
let browser = await webdriver(context.appPort, '/404')
const hydrated404Content = await browser.waitForElementByCss(id).text()
browser = await webdriver(context.appPort, '/no.where')
const hydratedUnknownContent = await browser.waitForElementByCss(id).text()

const page404Browser = await webdriver(context.appPort, '/404')
const pageUnknownBrowser = await webdriver(context.appPort, '/no.where')

expect(await page404Browser.waitForElementByCss(id).text()).toBe(content)
expect(await pageUnknownBrowser.waitForElementByCss(id).text()).toBe(
content
)
expect(hydrated404Content).toBe(content)
expect(hydratedUnknownContent).toBe(content)

expect(getNodeBySelector(page404HTML, id).text()).toBe(content)
expect(getNodeBySelector(pageUnknownHTML, id).text()).toBe(content)
Expand Down
2 changes: 1 addition & 1 deletion test/lib/browsers/base.ts
Expand Up @@ -72,7 +72,7 @@ export class BrowserInterface {
}
on(event: Event, cb: (...args: any[]) => void) {}
off(event: Event, cb: (...args: any[]) => void) {}
async loadPage(url: string, { disableCache: boolean }): Promise<any> {}
async loadPage(url: string, { disableCache: boolean }): Promise<void> {}
async get(url: string): Promise<void> {}

async getValue(): Promise<any> {}
Expand Down