test(tabs): [tabs] update tabs E2E test dragger (#985)

This commit is contained in:
chenxi-20 2023-12-01 14:14:00 +08:00 committed by GitHub
parent 8bc35c5a48
commit 8b5fc559c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -5,25 +5,25 @@ test('可拖拽', async ({ page }) => {
await page.goto('tabs#tabs-draggable')
const items = page.getByRole('tab')
const box1 = await items.nth(0).boundingBox()
const box2 = await items.nth(1).boundingBox()
const box3 = await items.nth(2).boundingBox()
const arr2 = ['1', '3', '2']
const box2 = await page.getByRole('tab', { name: 'Tab 2' }).boundingBox()
const box3 = await page.getByRole('tab', { name: 'Tab 3' }).boundingBox()
const arr2 = ['2', '3', '1']
for (let i = 0; i < 3; ++i) {
await expect(items.nth(i)).toHaveText(`Tab ${i + 1}`)
}
await page.mouse.move(box1.x + box1.width / 2, box1.y + box1.height / 2)
await page.getByRole('tab', { name: 'Tab 1' }).hover()
await page.mouse.down()
await page.mouse.move(box2.x + box2.width / 2, box2.y + box2.height / 2)
await page.mouse.up()
await page.waitForTimeout(200)
await page.getByRole('tab', { name: 'Tab 1' }).hover()
await page.mouse.down()
await page.mouse.move(box3.x + box3.width / 2, box3.y + box3.height / 2)
await page.mouse.up()
for (let i = 0; i < 3; ++i) {
await expect(items.nth(i)).toHaveText(`Tab ${i + 1}`)
// 网页测试拖拽无法改变位置,示例测试时打开以下代码运行
// await expect(items.nth(i)).toHaveText(`Tab ${arr2[i]}`)
await expect(items.nth(i)).toHaveText(`Tab ${arr2[i]}`)
}
})