test: don't skip unicode related tests anymore (#16339)

This commit is contained in:
翠 / green 2024-05-07 17:43:33 +09:00 committed by GitHub
parent 671155337a
commit c2a4ce5a77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 45 deletions

View File

@ -1,10 +0,0 @@
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))

View File

@ -253,7 +253,7 @@ describe('hmr works correctly', () => {
})
// TODO
// test.skipIf(hasWindowsUnicodeFsBug)('full-reload encodeURI path', async () => {
// test('full-reload encodeURI path', async () => {
// await page.goto(
// viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
// )

View File

@ -1,6 +1,5 @@
import { beforeAll, describe, expect, it, test } from 'vitest'
import type { Page } from 'playwright-chromium'
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
import {
addFile,
browser,
@ -253,24 +252,21 @@ if (!isBuild) {
await untilUpdated(() => el.textContent(), '3')
})
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('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)

View File

@ -1,5 +1,4 @@
import { beforeAll, describe, expect, test } from 'vitest'
import { hasWindowsUnicodeFsBug } from '../../hasWindowsUnicodeFsBug'
import {
browserLogs,
editFile,
@ -220,7 +219,7 @@ describe('noBody', () => {
})
})
describe.skipIf(hasWindowsUnicodeFsBug)('Unicode path', () => {
describe('Unicode path', () => {
test('direct access', async () => {
await page.goto(
viteTestUrl + '/unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',

View File

@ -1,6 +1,5 @@
import { relative, resolve } from 'node:path'
import { defineConfig } from 'vite'
import { hasWindowsUnicodeFsBug } from '../hasWindowsUnicodeFsBug'
export default defineConfig({
base: './',
@ -21,14 +20,10 @@ export default defineConfig({
inline1: resolve(__dirname, 'inline/shared-1.html'),
inline2: resolve(__dirname, 'inline/shared-2.html'),
inline3: resolve(__dirname, 'inline/unique.html'),
...(hasWindowsUnicodeFsBug
? {}
: {
unicodePath: resolve(
__dirname,
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
),
}),
unicodePath: resolve(
__dirname,
'unicode-path/中文-にほんご-한글-🌕🌖🌗/index.html',
),
linkProps: resolve(__dirname, 'link-props/index.html'),
valid: resolve(__dirname, 'valid.html'),
importmapOrder: resolve(__dirname, 'importmapOrder.html'),

View File

@ -3,7 +3,6 @@ import fs from 'fs-extra'
import type { GlobalSetupContext } from 'vitest/node'
import type { BrowserServer } from 'playwright-chromium'
import { chromium } from 'playwright-chromium'
import { hasWindowsUnicodeFsBug } from './hasWindowsUnicodeFsBug'
let browserServer: BrowserServer | undefined
@ -28,9 +27,6 @@ export async function setup({ provide }: GlobalSetupContext): 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__') && !/dist(?:\/|$)/.test(file)
},