From 959741c7d69c1264ea12a2021fdc41974ddeba48 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 13 Aug 2020 23:04:27 -0500 Subject: [PATCH] Add test case for preloading buildManifest (#16183) --- .../dynamic-routing/test/index.test.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/integration/dynamic-routing/test/index.test.js b/test/integration/dynamic-routing/test/index.test.js index 3982f9f47f7e0a..5537f59208516b 100644 --- a/test/integration/dynamic-routing/test/index.test.js +++ b/test/integration/dynamic-routing/test/index.test.js @@ -561,6 +561,40 @@ function runTests(dev) { expect(res.status).toBe(400) }) + it('should preload buildManifest for auto-export dynamic pages', async () => { + const html = await renderViaHTTP(appPort, '/on-mount/hello') + const $ = cheerio.load(html) + let found = 0 + + for (const el of Array.from($('link[rel="preload"]'))) { + const { href } = el.attribs + if ( + href.includes('_buildManifest.js') || + href.includes('_buildManifest.module.js') + ) { + found++ + } + } + expect(found).toBe(dev ? 2 : 1) + }) + + it('should not preload buildManifest for non-auto export dynamic pages', async () => { + const html = await renderViaHTTP(appPort, '/hello') + const $ = cheerio.load(html) + let found = 0 + + for (const el of Array.from($('link[rel="preload"]'))) { + const { href } = el.attribs + if ( + href.includes('_buildManifest.js') || + href.includes('_buildManifest.module.js') + ) { + found++ + } + } + expect(found).toBe(0) + }) + if (dev) { it('should resolve dynamic route href for page added later', async () => { const browser = await webdriver(appPort, '/')