fix(test): [date-picker] update e2e test (#1453)

* fix(test): [date-picker] update e2e test

* fix(test): [date-picker] update e2e test

* fix(test): [user-link] update e2e test
This commit is contained in:
李天佑 2024-03-01 16:28:38 +08:00 committed by GitHub
parent 6ae57a3249
commit e4e91c9c9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 19 deletions

View File

@ -6,28 +6,31 @@ test('[DatePicker] 测试对齐方式', async ({ page }) => {
// 左对齐
const leftDateInputDom = page.getByRole('textbox').nth(1)
const leftDatePanelDom = page.locator('body > div:nth-child(8)')
const leftDatePanelDom = page.locator('.tiny-picker-panel').nth(2)
const leftClosePanel = page.getByText('左对齐:')
const { x: leftDateInputX } = await leftDateInputDom.boundingBox()
await leftDateInputDom.click()
const { x: leftDatePanelX } = await leftDatePanelDom.boundingBox()
expect(leftDateInputX - leftDatePanelX).toBeCloseTo(0)
await page.waitForTimeout(200)
await expect(leftDatePanelDom).toHaveAttribute('x-placement', /bottom-start|top-start/)
await leftClosePanel.click()
// 居中对齐
const centerDateInputDom = page.getByRole('textbox').nth(2)
const centerDatePanelDom = page.locator('body > div:nth-child(9)')
const { x: centerDateInputX, width: centerDateInputWidth } = await centerDateInputDom.boundingBox()
const centerDatePanelDom = page.locator('.tiny-picker-panel').nth(2)
const centerClosePanel = page.getByText('居中对齐:')
await centerDateInputDom.click()
const { x: centerDatePanelX, width: centerDatePanelWidth } = await centerDatePanelDom.boundingBox()
expect(
centerDateInputX + Math.round(centerDateInputWidth / 2) - centerDatePanelX - Math.round(centerDatePanelWidth / 2)
).toBeCloseTo(0)
await page.waitForTimeout(200)
await expect(centerDatePanelDom).toHaveAttribute('x-placement', /bottom|top/)
await centerClosePanel.click()
// 右对齐
const rightDateInputDom = page.getByRole('textbox').nth(3)
const rightDatePanelDom = page.locator('body > div:nth-child(10)')
const { x: rightDateInputX, width: rightDateInputWidth } = await rightDateInputDom.boundingBox()
const rightDatePanelDom = page.locator('.tiny-picker-panel').nth(2)
const rightClosePanel = page.getByText('右对齐:')
await rightDateInputDom.click()
const { x: rightDatePanelX, width: rightDatePanelWidth } = await rightDatePanelDom.boundingBox()
expect(rightDateInputX + rightDateInputWidth - rightDatePanelX - rightDatePanelWidth).toBeCloseTo(0)
await page.waitForTimeout(200)
await expect(rightDatePanelDom).toHaveAttribute('x-placement', /bottom-end|top-end/)
await rightClosePanel.click()
})

View File

@ -31,6 +31,6 @@ test('[DatePicker] 测试清除输入', async ({ page }) => {
// 测试清除功能
await expect(datePickerCustomClearIcon).toHaveValue('2023-05-24')
await page.locator('.tiny-input__icon-container > svg > .st0').click()
await page.locator('#clear').getByRole('img').nth(2).click()
await expect(datePickerCustomClearIcon).toHaveValue('')
})

View File

@ -2,6 +2,9 @@ import { test, expect } from '@playwright/test'
test('自定义服务', async ({ page }) => {
await page.goto('hrapprover#custom-service')
await page.locator('#preview').getByRole('img').nth(1).click()
await expect(page.getByText('已选权签人备注 test1 test2权限申请 test3资产申请')).toBeVisible()
await page.locator('#custom-service').getByRole('img').click()
await page.waitForTimeout(200)
await expect(page.getByRole('cell', { name: 'test1' })).toBeVisible()
await expect(page.getByRole('cell', { name: 'test2' })).toBeVisible()
await expect(page.getByRole('cell', { name: 'test3' })).toBeVisible()
})

View File

@ -4,5 +4,5 @@ test('禁用', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('hrapprover#disabled')
await page.getByRole('button', { name: '启用/禁用' }).click()
await expect(page.locator('.tiny-hrapprover > .is-disabled > input')).toHaveAttribute('disabled', '')
await expect(page.locator('#disabled').getByRole('textbox')).toHaveAttribute('disabled', '')
})

View File

@ -3,7 +3,7 @@ import { test, expect } from '@playwright/test'
test('user-link-custom-service', async ({ page }) => {
await page.goto('user-link#custom-service')
const card = page.locator('.tiny-popper.tiny-user-card')
const reference = page.locator('#preview .tiny-userlink .tiny-popover__reference')
const reference = page.locator('.reference-wrapper')
const img = card.locator('.card-top-img img')
await expect(reference).toHaveText('test3')