tiny-vue_version0/examples/sites/demos/pc/app/select/optimization.spec.ts

47 lines
2.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test'
test('单选虚拟滚动', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('select#optimization')
const wrap = page.locator('#optimization')
const select = wrap.locator('.tiny-select').nth(0)
const input = select.locator('.tiny-input__inner')
const dropdown = page.locator('body > .tiny-select-dropdown')
const option = dropdown.locator('.tiny-option')
await select.click()
await expect((await option.all()).length).toBeLessThan(20) // 新虚拟滚动,预加载行数不一样了
await expect(option.filter({ hasText: '北京17' })).toBeHidden()
await option.nth(9).scrollIntoViewIfNeeded()
await page.waitForTimeout(1000)
await expect(option.filter({ hasText: '北京17' })).toBeVisible() // 现在预加载的行比较多所以17行已经可以看到了
})
test('多选虚拟滚动', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('select#optimization')
const wrap = page.locator('#optimization')
const select = wrap.locator('.tiny-select').nth(1)
const dropdown = page.locator('body > .tiny-select-dropdown')
const option = dropdown.locator('.tiny-option')
const tag = select.locator('.tiny-tag')
await select.click()
await expect((await option.all()).length).toBeLessThan(20) // 新虚拟滚动,预加载行数不一样了
await expect(option.filter({ hasText: '北京17' })).toBeHidden()
await expect(option.filter({ hasText: '北京16' })).toBeHidden()
await page.waitForTimeout(500)
await option.nth(9).scrollIntoViewIfNeeded()
await page.waitForTimeout(1000)
await option.nth(9).scrollIntoViewIfNeeded()
await expect(option.filter({ hasText: '北京16' })).toBeVisible()
await expect(option.filter({ hasText: '北京17' })).toBeVisible()
await option.filter({ hasText: '北京17' }).click()
await expect(tag.first()).toHaveText('北京17')
await expect((await tag.all()).length).toEqual(1)
await option.filter({ hasText: '北京16' }).click()
await expect((await tag.all()).length).toEqual(2)
await expect(tag.nth(1)).toHaveText('+ 1')
})