From b4e4df7edcb76bccf8c5ed4f36d473c561f9ab46 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 5 Nov 2025 16:31:18 +0800 Subject: [PATCH 1/2] test(e2e): enable native HTML implementation --- e2e/cases/html/app-icon/index.test.ts | 32 +++++++++++++-------------- e2e/cases/html/favicon/index.test.ts | 20 ++++++++--------- packages/core/src/defaultConfig.ts | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/e2e/cases/html/app-icon/index.test.ts b/e2e/cases/html/app-icon/index.test.ts index d595dd5c27..0c04839c80 100644 --- a/e2e/cases/html/app-icon/index.test.ts +++ b/e2e/cases/html/app-icon/index.test.ts @@ -18,7 +18,7 @@ test('should emit apple-touch-icon to dist path', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); }); @@ -47,13 +47,13 @@ test('should emit manifest.webmanifest to dist path', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); // do not generate apple-touch-icon for large images expect(html).not.toContain( - '', + '', ); - expect(html).toContain(''); + expect(html).toContain(''); expect(JSON.parse(files[manifestPath])).toEqual({ name: 'My Website', @@ -84,9 +84,9 @@ test('should allow to specify URL as icon', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); - expect(html).toContain(''); + expect(html).toContain(''); expect(JSON.parse(files[manifestPath])).toEqual({ name: 'My Website', @@ -145,16 +145,16 @@ test('should allow to specify target for each icon', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); // do not generate apple-touch-icon for large images expect(html).not.toContain( - '', + '', ); expect(html).not.toContain( - '', + '', ); - expect(html).toContain(''); + expect(html).toContain(''); expect(JSON.parse(files[manifestPath])).toEqual({ name: 'My Website', @@ -235,7 +235,7 @@ test('should allow to customize manifest filename', async ({ build }) => { const manifestPath = findFile(files, 'manifest.json'); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); expect(JSON.parse(files[manifestPath])).toEqual({ name: 'My Website', @@ -275,10 +275,10 @@ test('should append dev.assetPrefix to icon URL', async ({ dev }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); expect(html).toContain( - '', + '', ); expect(JSON.parse(files[manifestPath])).toEqual({ @@ -326,10 +326,10 @@ test('should append output.assetPrefix to icon URL', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); expect(html).toContain( - '', + '', ); expect(JSON.parse(files[manifestPath])).toEqual({ @@ -373,6 +373,6 @@ test('should apply asset prefix to apple-touch-icon URL', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); }); diff --git a/e2e/cases/html/favicon/index.test.ts b/e2e/cases/html/favicon/index.test.ts index 26e265dd24..cfb1e56d9e 100644 --- a/e2e/cases/html/favicon/index.test.ts +++ b/e2e/cases/html/favicon/index.test.ts @@ -16,7 +16,7 @@ test('should emit local favicon to dist path', async ({ build }) => { expect(icon.endsWith('/icon.png')).toBeTruthy(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); }); test('should allow `html.favicon` to be an absolute path', async ({ @@ -35,7 +35,7 @@ test('should allow `html.favicon` to be an absolute path', async ({ expect(icon.endsWith('/icon.png')).toBeTruthy(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); }); test('should add type attribute for SVG favicon', async ({ build }) => { @@ -53,7 +53,7 @@ test('should add type attribute for SVG favicon', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); }); @@ -73,7 +73,7 @@ test('should apply asset prefix to favicon URL', async ({ build }) => { const html = getFileContent(files, 'index.html'); expect(html).toContain( - '', + '', ); }); @@ -88,7 +88,7 @@ test('should allow favicon to be a CDN URL', async ({ build }) => { const files = rsbuild.getDistFiles(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); }); test('should generate favicon via function correctly', async ({ build }) => { @@ -116,12 +116,12 @@ test('should generate favicon via function correctly', async ({ build }) => { const fooHtml = getFileContent(files, 'foo.html'); expect(fooHtml).toContain( - '', + '', ); const barHtml = getFileContent(files, 'bar.html'); expect(barHtml).toContain( - '', + '', ); }); @@ -146,7 +146,7 @@ test('should allow to custom favicon dist path with a relative path', async ({ expect(faviconFile.endsWith('/static/favicon/icon.png')).toBeTruthy(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); }); test('should allow to custom favicon dist path with a relative path starting with ./', async ({ @@ -170,7 +170,7 @@ test('should allow to custom favicon dist path with a relative path starting wit expect(faviconFile.endsWith('/custom/icon.png')).toBeTruthy(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(''); + expect(html).toContain(''); }); for (const filename of ['favicon.ico', 'favicon.png', 'favicon.svg']) { @@ -195,6 +195,6 @@ for (const filename of ['favicon.ico', 'favicon.png', 'favicon.svg']) { expect(faviconFile.endsWith(`/${filename}`)).toBeTruthy(); const html = getFileContent(files, 'index.html'); - expect(html).toContain(` ({ crossorigin: false, outputStructure: 'flat', scriptLoading: 'defer', - implementation: 'js', + implementation: 'native', }); const getDefaultSecurityConfig = (): NormalizedSecurityConfig => ({ From 46556af723e5518fe4a9322b6040f72731fa4f56 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 5 Nov 2025 16:42:07 +0800 Subject: [PATCH 2/2] fix --- e2e/cases/assets/asset-prefix/index.test.ts | 3 +-- e2e/cases/assets/asset-prefix/src/template.html | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/e2e/cases/assets/asset-prefix/index.test.ts b/e2e/cases/assets/asset-prefix/index.test.ts index b79fefd017..90d694e6b4 100644 --- a/e2e/cases/assets/asset-prefix/index.test.ts +++ b/e2e/cases/assets/asset-prefix/index.test.ts @@ -80,8 +80,7 @@ test('should inject assetPrefix to env var and template correctly', async ({ }, }); - await expect(page.locator('#prefix1')).toHaveText('http://example.com'); - await expect(page.locator('#prefix2')).toHaveText('http://example.com'); + await expect(page.locator('#prefix')).toHaveText('http://example.com'); }); test('should use output.assetPrefix in none mode', async ({ build }) => { diff --git a/e2e/cases/assets/asset-prefix/src/template.html b/e2e/cases/assets/asset-prefix/src/template.html index 306c210c8b..66d047142a 100644 --- a/e2e/cases/assets/asset-prefix/src/template.html +++ b/e2e/cases/assets/asset-prefix/src/template.html @@ -2,8 +2,7 @@ -
<%= assetPrefix %>
-
<%= process.env.ASSET_PREFIX %>
+
<%= assetPrefix %>