Skip to content

Commit

Permalink
test: add pop-upload UI e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxi-20 committed Sep 23, 2024
1 parent ce7ff28 commit d7c0c0f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"devDependencies": {
"@playwright/test": "^1.47.0",
"prettier": "^3.3.3"
"path": "0.12.7",
"prettier": "^3.3.3"
}
}
}
33 changes: 33 additions & 0 deletions tests/pop-upload/xdesign.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, test } from '@playwright/test'
import path from 'path'

test.describe('pop-upload 组件xdesign规范', () => {
test('自定义上传提示 --UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('pop-upload#upload-tip')
const demo = page.locator('#upload-tip .pc-demo')
const modal = page.locator('.tiny-popupload__modal > .tiny-modal__box').locator('visible=true')
await expect(demo).toBeInViewport()
await demo.getByRole('button', { name: '添加文件' }).click()
await expect(modal).toHaveCount(1)
await expect(modal).toHaveScreenshot('upload-tip.png')

// 点击开始上传截图
const lists = modal.locator('.tiny-popupload__dialog-table-item')
const uploadBtn = modal.getByRole('button', { name: '添加文件' })
const currentPath1 = path.resolve('tests/pop-upload/测试.jpg')
const [fileChooser] = await Promise.all([page.waitForEvent('filechooser'), uploadBtn.click()])
await fileChooser.setFiles(currentPath1)
await expect(lists).toHaveCount(1)
await expect(modal).toHaveScreenshot('upload-tip-list.png')

// 点击删除确认截图
await modal.getByText('删除', { exact: true }).first().click()
await expect(modal).toHaveScreenshot('upload-tip-list-popover.png')

// 上传后的截图
await modal.getByRole('button', { name: '开始上传' }).click()
await expect(page.getByText('共1条数据:其中1条出错,请修改后重试')).toHaveCount(1)
await expect(modal).toHaveScreenshot('upload-tip-list-fail.png')
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/pop-upload/测试.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d7c0c0f

Please sign in to comment.