Skip to content

Commit c048fdc

Browse files
authored
fix(file-upload): Modify the import method of e2e test case path for file-upload component (#3393)
* fix: 修改file-upload组件e2e测试用例path导入方式 * fix: 修改file-upload组件e2e测试用例path为es6导入方式
1 parent 0b47009 commit c048fdc

20 files changed

+100
-26
lines changed

examples/sites/demos/pc/app/file-upload/abort-quest.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('手动取消上传请求', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -10,7 +15,6 @@ test('手动取消上传请求', async ({ page }) => {
1015
const button = page.locator('button').filter({ hasText: '取消上传' })
1116
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
1217

13-
const path = require('node:path')
1418
const currentPath = path.resolve(__dirname, '测试.jpg')
1519

1620
await fileChooser.setFiles(currentPath)

examples/sites/demos/pc/app/file-upload/accept-file-image.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('限制文件类型', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -8,7 +13,6 @@ test('限制文件类型', async ({ page }) => {
813
const lists = page.locator('.tiny-upload-list__li')
914
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
1015

11-
const path = require('node:path')
1216
const path1 = path.resolve(__dirname, '测试.jpg')
1317
const path2 = path.resolve(__dirname, '测试.svg')
1418
const path3 = path.resolve(__dirname, '测试.png')

examples/sites/demos/pc/app/file-upload/basic-usage.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('基本用法', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -8,7 +13,6 @@ test('基本用法', async ({ page }) => {
813
const lists = page.locator('.tiny-upload-list__li')
914
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
1015

11-
const path = require('node:path')
1216
const currentPath = path.resolve(__dirname, '测试.jpg')
1317

1418
await fileChooser.setFiles(currentPath)

examples/sites/demos/pc/app/file-upload/before-upload-limit.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('定义上传前限制', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -10,7 +15,6 @@ test('定义上传前限制', async ({ page }) => {
1015
const lists = page.locator('.tiny-upload-list__item')
1116
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
1217

13-
const path = require('node:path')
1418
const currentPath = path.resolve(__dirname, '测试.jpg')
1519
const exceedFilePath = path.resolve(__dirname, 'before-upload-limit.vue')
1620

examples/sites/demos/pc/app/file-upload/custom-prefix.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('文件选择前确认', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -12,8 +17,6 @@ test('文件选择前确认', async ({ page }) => {
1217
const confirmBtn = page.getByRole('button', { name: '确定' })
1318
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), confirmBtn.click()])
1419

15-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
16-
const path = require('node:path')
1720
const currentPath = path.resolve(__dirname, '测试.jpg')
1821

1922
await fileChooser.setFiles(currentPath)

examples/sites/demos/pc/app/file-upload/drag-upload.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('是否可以拖拽上传', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -9,7 +14,6 @@ test('是否可以拖拽上传', async ({ page }) => {
914
const input = page.locator('.tiny-upload__input')
1015
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), drag.click()])
1116

12-
const path = require('node:path')
1317
const currentPath = path.resolve(__dirname, '测试.jpg')
1418

1519
await expect(drag).toHaveCSS('width', '100px')

examples/sites/demos/pc/app/file-upload/encrypt-config.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('水印和加密弹窗', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -9,8 +14,6 @@ test('水印和加密弹窗', async ({ page }) => {
914
const header = page.getByText('水印及加密设置')
1015
const footer = page.getByRole('button', { name: '选择文件' })
1116
const lists = page.locator('.tiny-upload-list__li')
12-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
13-
const path = require('node:path')
1417
const currentPath = path.resolve(__dirname, '测试.jpg')
1518

1619
await upload.click()

examples/sites/demos/pc/app/file-upload/file-picture-card.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('照片墙的预览、下载与删除', async ({ page, context }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -13,7 +18,6 @@ test('照片墙的预览、下载与删除', async ({ page, context }) => {
1318
const dowPic = page.locator('#file-picture-card svg').nth(1)
1419
const delbutton = page.locator('#file-picture-card svg').nth(2)
1520

16-
const path = require('node:path')
1721
const currentPath = path.resolve(__dirname, '测试.jpg')
1822

1923
await expect(lists).toHaveCount(0)

examples/sites/demos/pc/app/file-upload/http-request.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('覆盖默认请求', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -9,7 +14,6 @@ test('覆盖默认请求', async ({ page }) => {
914
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
1015
const modal = page.locator('.tiny-modal')
1116

12-
const path = require('node:path')
1317
const currentPath = path.resolve(__dirname, '测试.jpg')
1418

1519
await fileChooser.setFiles(currentPath)

examples/sites/demos/pc/app/file-upload/image-size.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { test, expect } from '@playwright/test'
2+
import { fileURLToPath } from 'node:url'
3+
import path from 'node:path'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = path.dirname(__filename)
27

38
test('获取图片的原始尺寸', async ({ page }) => {
49
page.on('pageerror', (exception) => expect(exception).toBeNull())
@@ -8,7 +13,6 @@ test('获取图片的原始尺寸', async ({ page }) => {
813
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
914
const modal = page.locator('.tiny-modal')
1015

11-
const path = require('node:path')
1216
const currentPath = path.resolve(__dirname, '测试.jpg')
1317

1418
await fileChooser.setFiles(currentPath)

0 commit comments

Comments
 (0)