38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
|
|
test('分页变更前置处理', async ({ page }) => {
|
|
page.on('pageerror', (exception) => expect(exception).toBeNull())
|
|
await page.goto('pager#before-page-change')
|
|
|
|
const demo = page.locator('#before-page-change')
|
|
const pager = demo.locator('.tiny-pager')
|
|
const prev = pager.locator('.tiny-pager__btn-prev')
|
|
const next = pager.locator('.tiny-pager__btn-next')
|
|
const tipModal = page.locator('.tiny-modal__box').filter({ hasText: '消息提示' })
|
|
const confirmBtn = tipModal.getByRole('button', { name: '确定' })
|
|
|
|
await pager.locator('li').getByText('6').click()
|
|
await expect(tipModal).toBeVisible()
|
|
await confirmBtn.click()
|
|
await expect(tipModal).not.toBeVisible()
|
|
await next.click()
|
|
await expect(tipModal).toBeVisible()
|
|
await confirmBtn.click()
|
|
await expect(tipModal).not.toBeVisible()
|
|
await prev.click()
|
|
await expect(tipModal).toBeVisible()
|
|
await confirmBtn.click()
|
|
await expect(tipModal).not.toBeVisible()
|
|
await pager.locator('.tiny-pager__popover').click()
|
|
await page.locator('.tiny-pager__selector').getByText('50').click()
|
|
await expect(tipModal).toBeVisible()
|
|
await confirmBtn.click()
|
|
await expect(tipModal).not.toBeVisible()
|
|
await pager.locator('.tiny-pager__goto input').fill('100')
|
|
await page.waitForTimeout(200)
|
|
await pager.locator('.tiny-pager__goto input').press('Enter')
|
|
await expect(tipModal).toBeVisible()
|
|
await confirmBtn.click()
|
|
await expect(tipModal).not.toBeVisible()
|
|
})
|