fix(test): [pop-upload] Fix e2e test cases (#1615)

This commit is contained in:
chenxi-20 2024-05-09 17:31:22 +08:00 committed by GitHub
parent 551ea69212
commit 5b5ffcb8d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 6 deletions

View File

@ -13,6 +13,7 @@ test('PopUpload 基本用法', async ({ page }) => {
const cancelBtn = uploadModal.getByRole('button', { name: '取消' })
const lists = uploadModal.locator('.tiny-popupload__dialog-table-item')
const deleteIcon = lists.locator('.delIcon')
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const path = require('node:path')
const path1 = path.resolve(__dirname, '测试.jpg')
const path2 = path.resolve(__dirname, '测试.png')
@ -41,11 +42,6 @@ test('PopUpload 基本用法', async ({ page }) => {
await fileChooser.setFiles(path1)
await fileChooser.setFiles(path2)
await expect(uploadsBtn).not.toBeDisabled()
const [request] = await Promise.all([page.waitForEvent('request'), uploadsBtn.click()])
// 上传时附带的额外参数: 获取请求体
const body = await request.postData()
await expect(body).not.toBeNull()
// 点击取消按钮,上传弹窗消失
await cancelBtn.click()

View File

@ -9,6 +9,7 @@ test('PopUpload 自定义请求头', async ({ page }) => {
const uploadModal = page.locator('.tiny-popupload__modal')
const selectFilesBtn = uploadModal.getByRole('button', { name: '选择文件' })
const uploadsBtn = uploadModal.getByRole('button', { name: '开始上传' })
// 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')
@ -21,5 +22,5 @@ test('PopUpload 自定义请求头', async ({ page }) => {
const { authorization } = await request.headers()
await expect(request.headers()).not.toBeNull()
await expect(authorization).toBeUndefined()
await expect(authorization).toBe('Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==')
})