Skip to content

Commit

Permalink
test: skip unicode test on windows instead of lowering the Node versi…
Browse files Browse the repository at this point in the history
…on (#15096)
  • Loading branch information
sapphi-red authored Nov 22, 2023
1 parent 5267a43 commit fd31412
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- os: macos-latest
node_version: 20
- os: windows-latest
node_version: 20.3.1 # https://github.com/nodejs/node/issues/48673
node_version: 20
fail-fast: false

name: "Build&Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
Expand Down
10 changes: 10 additions & 0 deletions playground/hasWindowsUnicodeFsBug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os from 'node:os'

const isWindows = os.platform() === 'win32'
const nodeVersionArray = process.versions.node.split('.')
// ignore some files due to https://github.com/nodejs/node/issues/48673
// node <=21.0.0 and ^20.4.0 has the bug
export const hasWindowsUnicodeFsBug =
isWindows &&
(+nodeVersionArray[0] > 20 ||
(+nodeVersionArray[0] === 20 && +nodeVersionArray[1] >= 4))
34 changes: 19 additions & 15 deletions playground/hmr/__tests__/hmr.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { beforeAll, describe, expect, it, test } from 'vitest'
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
import {
addFile,
browserLogs,
Expand Down Expand Up @@ -205,21 +206,24 @@ if (!isBuild) {
await untilUpdated(() => el.textContent(), '3')
})

test('full-reload encodeURI path', async () => {
await page.goto(
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
)
const el = await page.$('#app')
expect(await el.textContent()).toBe('title')
editFile('unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html', (code) =>
code.replace('title', 'title2'),
)
await page.waitForEvent('load')
await untilUpdated(
async () => (await page.$('#app')).textContent(),
'title2',
)
})
test.skipIf(hasWindowsUnicodeFsBug)(
'full-reload encodeURI path',
async () => {
await page.goto(
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
)
const el = await page.$('#app')
expect(await el.textContent()).toBe('title')
editFile('unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html', (code) =>
code.replace('title', 'title2'),
)
await page.waitForEvent('load')
await untilUpdated(
async () => (await page.$('#app')).textContent(),
'title2',
)
},
)

test('CSS update preserves query params', async () => {
await page.goto(viteTestUrl)
Expand Down
3 changes: 2 additions & 1 deletion playground/html/__tests__/html.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { beforeAll, describe, expect, test } from 'vitest'
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
import {
browserLogs,
editFile,
Expand Down Expand Up @@ -218,7 +219,7 @@ describe('noBody', () => {
})
})

describe('Unicode path', () => {
describe.skipIf(hasWindowsUnicodeFsBug)('Unicode path', () => {
test('direct access', async () => {
await page.goto(
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
Expand Down
13 changes: 9 additions & 4 deletions playground/html/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import { hasWindowsUnicodeFsBug } from '../hasWindowsUnicodeFsBug'

export default defineConfig({
base: './',
Expand All @@ -20,10 +21,14 @@ export default defineConfig({
inline1: resolve(__dirname, 'inline/shared-1.html'),
inline2: resolve(__dirname, 'inline/shared-2.html'),
inline3: resolve(__dirname, 'inline/unique.html'),
unicodePath: resolve(
__dirname,
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
),
...(hasWindowsUnicodeFsBug
? {}
: {
unicodePath: resolve(
__dirname,
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
),
}),
linkProps: resolve(__dirname, 'link-props/index.html'),
valid: resolve(__dirname, 'valid.html'),
importmapOrder: resolve(__dirname, 'importmapOrder.html'),
Expand Down
4 changes: 4 additions & 0 deletions playground/vitestGlobalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path'
import fs from 'fs-extra'
import type { BrowserServer } from 'playwright-chromium'
import { chromium } from 'playwright-chromium'
import { hasWindowsUnicodeFsBug } from './hasWindowsUnicodeFsBug'

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

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

0 comments on commit fd31412

Please sign in to comment.