Skip to content

Commit fd31412

Browse files
authored
test: skip unicode test on windows instead of lowering the Node version (#15096)
1 parent 5267a43 commit fd31412

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- os: macos-latest
4646
node_version: 20
4747
- os: windows-latest
48-
node_version: 20.3.1 # https://github.com/nodejs/node/issues/48673
48+
node_version: 20
4949
fail-fast: false
5050

5151
name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"

playground/hasWindowsUnicodeFsBug.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os from 'node:os'
2+
3+
const isWindows = os.platform() === 'win32'
4+
const nodeVersionArray = process.versions.node.split('.')
5+
// ignore some files due to https://github.com/nodejs/node/issues/48673
6+
// node <=21.0.0 and ^20.4.0 has the bug
7+
export const hasWindowsUnicodeFsBug =
8+
isWindows &&
9+
(+nodeVersionArray[0] > 20 ||
10+
(+nodeVersionArray[0] === 20 && +nodeVersionArray[1] >= 4))

playground/hmr/__tests__/hmr.spec.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, it, test } from 'vitest'
2+
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
23
import {
34
addFile,
45
browserLogs,
@@ -205,21 +206,24 @@ if (!isBuild) {
205206
await untilUpdated(() => el.textContent(), '3')
206207
})
207208

208-
test('full-reload encodeURI path', async () => {
209-
await page.goto(
210-
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
211-
)
212-
const el = await page.$('#app')
213-
expect(await el.textContent()).toBe('title')
214-
editFile('unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html', (code) =>
215-
code.replace('title', 'title2'),
216-
)
217-
await page.waitForEvent('load')
218-
await untilUpdated(
219-
async () => (await page.$('#app')).textContent(),
220-
'title2',
221-
)
222-
})
209+
test.skipIf(hasWindowsUnicodeFsBug)(
210+
'full-reload encodeURI path',
211+
async () => {
212+
await page.goto(
213+
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
214+
)
215+
const el = await page.$('#app')
216+
expect(await el.textContent()).toBe('title')
217+
editFile('unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html', (code) =>
218+
code.replace('title', 'title2'),
219+
)
220+
await page.waitForEvent('load')
221+
await untilUpdated(
222+
async () => (await page.$('#app')).textContent(),
223+
'title2',
224+
)
225+
},
226+
)
223227

224228
test('CSS update preserves query params', async () => {
225229
await page.goto(viteTestUrl)

playground/html/__tests__/html.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { beforeAll, describe, expect, test } from 'vitest'
2+
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
23
import {
34
browserLogs,
45
editFile,
@@ -218,7 +219,7 @@ describe('noBody', () => {
218219
})
219220
})
220221

221-
describe('Unicode path', () => {
222+
describe.skipIf(hasWindowsUnicodeFsBug)('Unicode path', () => {
222223
test('direct access', async () => {
223224
await page.goto(
224225
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',

playground/html/vite.config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { resolve } from 'node:path'
22
import { defineConfig } from 'vite'
3+
import { hasWindowsUnicodeFsBug } from '../hasWindowsUnicodeFsBug'
34

45
export default defineConfig({
56
base: './',
@@ -20,10 +21,14 @@ export default defineConfig({
2021
inline1: resolve(__dirname, 'inline/shared-1.html'),
2122
inline2: resolve(__dirname, 'inline/shared-2.html'),
2223
inline3: resolve(__dirname, 'inline/unique.html'),
23-
unicodePath: resolve(
24-
__dirname,
25-
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
26-
),
24+
...(hasWindowsUnicodeFsBug
25+
? {}
26+
: {
27+
unicodePath: resolve(
28+
__dirname,
29+
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
30+
),
31+
}),
2732
linkProps: resolve(__dirname, 'link-props/index.html'),
2833
valid: resolve(__dirname, 'valid.html'),
2934
importmapOrder: resolve(__dirname, 'importmapOrder.html'),

playground/vitestGlobalSetup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'node:path'
33
import fs from 'fs-extra'
44
import type { BrowserServer } from 'playwright-chromium'
55
import { chromium } from 'playwright-chromium'
6+
import { hasWindowsUnicodeFsBug } from './hasWindowsUnicodeFsBug'
67

78
const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup')
89

@@ -30,6 +31,9 @@ export async function setup(): Promise<void> {
3031
.copy(path.resolve(__dirname, '../playground'), tempDir, {
3132
dereference: false,
3233
filter(file) {
34+
if (file.includes('中文-にほんご-한글-🌕🌖🌗')) {
35+
return !hasWindowsUnicodeFsBug
36+
}
3337
file = file.replace(/\\/g, '/')
3438
return !file.includes('__tests__') && !file.match(/dist(\/|$)/)
3539
},

0 commit comments

Comments
 (0)