Skip to content

Commit

Permalink
test(site): fix icon not correct test e2e (#2445)
Browse files Browse the repository at this point in the history
  • Loading branch information
gimmyhehe authored Oct 28, 2024
1 parent c5a67e6 commit 3bfafe4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
5 changes: 1 addition & 4 deletions examples/sites/demos/pc/app/action-menu/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ test('基本用法', async ({ page }) => {
// 更多按钮
await expect(moreItem).toHaveText(//)
// 图标显示
await expect(moreItem.locator('svg > path').nth(0)).toHaveAttribute(
'd',
'M8 11.43c-.15 0-.31-.06-.42-.18L1.92 5.6c-.23-.23-.23-.61 0-.85s.61-.23.85 0L8 9.98l5.23-5.23a.61.61 0 0 1 .85 0c.23.23.23.61 0 .85l-5.66 5.66c-.11.11-.27.17-.42.17z'
)
await expect(moreItem.locator('.tiny-dropdown__trigger .tiny-svg')).toBeVisible()
// 分割线
await expect(actionMenu.locator('.tiny-action-menu__item-line')).toHaveCount(2)
// 图标旋转
Expand Down
3 changes: 2 additions & 1 deletion examples/sites/demos/pc/app/action-menu/card-mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ test('基本用法', async ({ page }) => {
await expect(visibleItem).toHaveCount(4)
await expect(moreItem).not.toHaveText(//)
// 三点图标
await expect(moreItem.locator('circle')).toHaveCount(3)
const SvgPathReg = /^M2\.3 7\.78v.+219-1\.17Z$/
await expect(moreItem.locator('.tiny-svg path').first()).toHaveAttribute('d', SvgPathReg)
})
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/action-menu/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('只显示文本', async ({ page }) => {
await page.goto('action-menu#icon')

const wrap = page.locator('#icon')
const actionMenu = wrap.locator('.tiny-action-menu').nth(2)
const actionMenu = wrap.locator('.tiny-action-menu').nth(1)
const actionMenuItem = actionMenu.locator('.tiny-action-menu__item')

await expect(actionMenuItem.nth(0).locator('.tiny-svg')).toBeHidden()
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/button-group/show-more.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ test('测试更多按钮', async ({ page }) => {
// 判断图标是否正确
const moreButton = buttonGroup.getByRole('button').nth(3)
const moreButtonSvg = moreButton.locator('svg path').first()
const moreSvgPathReg = /^M292\.768 449\.694c2\.491\.515.+002-12.555-\.002z$/
const moreSvgPathReg = /^M2\.3 7\.78v.+219-1\.17Z$/
await expect(moreButtonSvg).toHaveAttribute('d', moreSvgPathReg)
})
10 changes: 2 additions & 8 deletions examples/sites/demos/pc/app/date-picker/clear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ test('[DatePicker] 测试清除输入', async ({ page }) => {
// 默认显示清除按钮
await datePickerDefaultClearIcon.hover()
await expect(clearIcon).toBeVisible()
await expect(clearIcon.locator('path').nth(1)).toHaveAttribute(
'd',
'M4.25 3.4 8 7.15l3.75-3.75a.61.61 0 0 1 .85 0c.23.23.23.62 0 .85L8.85 8l3.75 3.75c.23.24.23.62 0 .85a.61.61 0 0 1-.85 0L8 8.85 4.25 12.6a.61.61 0 0 1-.85 0 .592.592 0 0 1 0-.85L7.15 8 3.4 4.25a.61.61 0 0 1 0-.85.61.61 0 0 1 .85 0z'
)
await expect(clearIcon.locator('path').nth(0)).toHaveAttribute('d', /^M12\.49 3\.3a.+22\.71 0Z$/)

// 隐藏清除按钮
await datePickerHideClearIcon.hover()
Expand All @@ -24,10 +21,7 @@ test('[DatePicker] 测试清除输入', async ({ page }) => {
// 自定义清除图标
await datePickerCustomClearIcon.hover()
await expect(clearIcon).toBeVisible()
await expect(clearIcon.locator('path').nth(1)).toHaveAttribute(
'd',
'M4.25 3.4 8 7.15l3.75-3.75a.61.61 0 0 1 .85 0c.23.23.23.62 0 .85L8.85 8l3.75 3.75c.23.24.23.62 0 .85a.61.61 0 0 1-.85 0L8 8.85 4.25 12.6a.61.61 0 0 1-.85 0 .592.592 0 0 1 0-.85L7.15 8 3.4 4.25a.61.61 0 0 1 0-.85.61.61 0 0 1 .85 0z'
)
await expect(clearIcon.locator('path').nth(0)).toHaveAttribute('d', /^M12\.49 3\.3a.+22\.71 0Z$/)

// 测试清除功能
await expect(datePickerCustomClearIcon).toHaveValue('2023-05-24')
Expand Down
4 changes: 0 additions & 4 deletions examples/sites/demos/pc/app/dropdown/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ test('基本用法', async ({ page }) => {

// 箭头是否存在
await expect(dropDownSvg).toBeVisible()
await expect(dropDownSvg.locator('path')).toHaveAttribute(
'd',
'M8 11.43c-.15 0-.31-.06-.42-.18L1.92 5.6c-.23-.23-.23-.61 0-.85s.61-.23.85 0L8 9.98l5.23-5.23a.61.61 0 0 1 .85 0c.23.23.23.61 0 .85l-5.66 5.66c-.11.11-.27.17-.42.17z'
)

await page.waitForTimeout(500)
await dropDown.hover()
Expand Down

0 comments on commit 3bfafe4

Please sign in to comment.