Skip to content

fix(file-upload): Modify the import method of e2e test case path for file-upload component #3393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

const path = require('node:path')
const path1 = path.resolve(__dirname, '测试.jpg')
const path2 = path.resolve(__dirname, '测试.svg')
const path3 = path.resolve(__dirname, '测试.png')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await expect(drag).toHaveCSS('width', '100px')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

await upload.click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await expect(lists).toHaveCount(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await fileChooser.setFiles(currentPath)
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/file-upload/image-size.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

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

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('手动上传', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -9,8 +10,6 @@ test('手动上传', async ({ page }) => {
const lists = page.locator('.tiny-upload-list__item')
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('最大上传数', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -9,7 +10,6 @@ test('最大上传数', async ({ page }) => {
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
const modal = page.locator('.tiny-modal').getByText(/文件数不能超过/)

const path = require('node:path')
const path1 = path.resolve(__dirname, '测试.jpg')
const path2 = path.resolve(__dirname, '测试.png')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('粘贴上传', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -8,7 +9,6 @@ test('粘贴上传', async ({ page }) => {
await expect(drag).toHaveCSS('width', '100px')
await expect(drag).toHaveCSS('height', '100px')

const path = require('node:path')
const pathJpg = path.resolve(__dirname, '测试.jpg')

await page.goto(pathJpg)
Expand Down
3 changes: 1 addition & 2 deletions examples/sites/demos/pc/app/file-upload/picture-card.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('照片墙', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -16,8 +17,6 @@ test('照片墙', async ({ page }) => {
const dialogClose = page.getByRole('button', { name: 'Close' })
const { width, height } = await first.boundingBox()

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

await expect(width).toEqual(100)
Expand Down
3 changes: 1 addition & 2 deletions examples/sites/demos/pc/app/file-upload/picture-list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('图片列表缩略图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -12,8 +13,6 @@ test('图片列表缩略图', async ({ page }) => {
const { width, height } = await item1.boundingBox()
const images = container.locator('.tiny-upload-list__item-thumbnail')

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

await expect(width).toBeGreaterThanOrEqual(height)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('事件', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -14,7 +15,6 @@ test('事件', async ({ page }) => {
.getByTitle('删除文件')
.locator('svg')

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

await fileChooser.setFiles(currentPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('定义文件列表', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -8,7 +9,6 @@ test('定义文件列表', async ({ page }) => {
const lists = page.locator('.tiny-upload-list__item')
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])

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

await expect(lists).toHaveCount(2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test('文件列表', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
Expand All @@ -10,8 +11,6 @@ test('文件列表', async ({ page }) => {
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), upload.click()])
const { width, height } = await items.nth(0).boundingBox()

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

await expect(width).toBeGreaterThanOrEqual(height)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test'
import path from 'node:path'

test.describe('设置上传请求', () => {
const path = require('node:path')
const path1 = path.resolve(__dirname, '测试.jpg')

test('上传请求', async ({ page }) => {
Expand Down
Loading