From 4d40e2e99672a9d4ec95dd2138d8be8592604926 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Mon, 1 Jan 2024 13:33:11 +0100 Subject: [PATCH] test: start listening for requests earlier (#24985) --- test/basic.test.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/basic.test.ts b/test/basic.test.ts index df99614149..6c45e2750c 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -1459,9 +1459,10 @@ describe.skipIf(isDev() || isWebpack)('inlining component styles', () => { describe('server components/islands', () => { it('/islands', async () => { const { page } = await renderPage('/islands') + const islandRequest = page.waitForResponse(response => response.url().includes('/__nuxt_island/') && response.status() === 200) await page.locator('#increase-pure-component').click() - await page.waitForResponse(response => response.url().includes('/__nuxt_island/') && response.status() === 200) - + await islandRequest + await page.locator('#slot-in-server').getByText('Slot with in .server component').waitFor() await page.locator('#test-slot').getByText('Slot with name test').waitFor() @@ -1469,11 +1470,12 @@ describe('server components/islands', () => { expect(await page.locator('.fallback-slot-content').all()).toHaveLength(2) // test islands update expect(await page.locator('.box').innerHTML()).toContain('"number": 101,') - await page.locator('#update-server-components').click() - await Promise.all([ + const requests = [ page.waitForResponse(response => response.url().includes('/__nuxt_island/LongAsyncComponent') && response.status() === 200), page.waitForResponse(response => response.url().includes('/__nuxt_island/AsyncServerComponent') && response.status() === 200) - ]) + ] + await page.locator('#update-server-components').click() + await Promise.all(requests) await page.locator('#async-server-component-count').getByText('1').waitFor() await page.locator('#long-async-component-count').getByText('1').waitFor() @@ -1958,11 +1960,12 @@ describe('component islands', () => { // test islands update expect(await page.locator('.box').innerHTML()).toContain('"number": 101,') - await page.locator('#update-server-components').click() - await Promise.all([ + const islandRequests = [ page.waitForResponse(response => response.url().includes('/__nuxt_island/LongAsyncComponent') && response.status() === 200), page.waitForResponse(response => response.url().includes('/__nuxt_island/AsyncServerComponent') && response.status() === 200) - ]) + ] + await page.locator('#update-server-components').click() + await Promise.all(islandRequests) await page.locator('#long-async-component-count').getByText('1').waitFor()