Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions examples/sites/demos/pc/app/date-picker/align.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/date-picker/clear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
})
7 changes: 5 additions & 2 deletions examples/sites/demos/pc/app/hrapprover/custom-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/hrapprover/disabled.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
})
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading