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): [tree-menu,ip-address,rate] update e2e test #1467

Merged
merged 3 commits into from
Mar 5, 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
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/ip-address/delimiter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('ipAddress 属性设置分隔符', async ({ page }) => {

const demo = page.locator('#delimiter')
const defaultDelimiter = demo.locator('svg circle')
const customDelimiter = demo.locator('svg > .st0')
const customDelimiter = demo.locator('svg > path')
const slotDelimiter = demo.locator('li > i').getByText('-')

// 设置分隔符取代默认分隔符
Expand Down
10 changes: 5 additions & 5 deletions examples/sites/demos/pc/app/rate/custom-3-threshold-icon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ test.describe('Rate 自定义 3 分段图标样式', () => {
const icon = page.locator('.tiny-rate__star > .tiny-svg')

await icon.nth(0).click()
await expect(page.locator('.tiny-rate > span:nth-child(1) > .tiny-svg > .st0').first()).toHaveAttribute(
await expect(page.locator('.tiny-rate > span:nth-child(1) > .tiny-svg > path').first()).toHaveAttribute(
'd',
'M6.5 11C5.7 11 5 10.3 5 9.5S5.7 8 6.5 8 8 8.7 8 9.5 7.3 11 6.5 11zm11 0c-.8 0-1.5-.7-1.5-1.5S16.7 8 17.5 8s1.5.7 1.5 1.5-.7 1.5-1.5 1.5zm-2.4 8c-.5 0-.9-.4-.9-.9 0-1.3-1-2.3-2.2-2.3s-2.2 1-2.2 2.3c0 .5-.4.9-.9.9s-.9-.4-.9-.9c0-2.3 1.8-4.1 4-4.1s4 1.8 4 4.1c0 .5-.4.9-.9.9z'
)
await icon.nth(1).click()
await expect(page.locator('.tiny-rate > span:nth-child(2) > .tiny-svg > .st0').first()).toHaveAttribute(
await expect(page.locator('.tiny-rate > span:nth-child(2) > .tiny-svg > path').first()).toHaveAttribute(
'd',
'M6.5 11C5.7 11 5 10.3 5 9.5S5.7 8 6.5 8 8 8.7 8 9.5 7.3 11 6.5 11zm11 0c-.8 0-1.5-.7-1.5-1.5S16.7 8 17.5 8s1.5.7 1.5 1.5-.7 1.5-1.5 1.5zm-2.4 8c-.5 0-.9-.4-.9-.9 0-1.3-1-2.3-2.2-2.3s-2.2 1-2.2 2.3c0 .5-.4.9-.9.9s-.9-.4-.9-.9c0-2.3 1.8-4.1 4-4.1s4 1.8 4 4.1c0 .5-.4.9-.9.9z'
)
await icon.nth(2).click()
await expect(page.locator('.tiny-rate > span:nth-child(3) > .tiny-svg > .st0').first()).toHaveAttribute(
await expect(page.locator('.tiny-rate > span:nth-child(3) > .tiny-svg > path').first()).toHaveAttribute(
'd',
'M9 16h6.1c.6 0 1 .4 1 1s-.4 1-1 1H9c-.6 0-1-.4-1-1s.5-1 1-1zm-2.5-5C5.7 11 5 10.3 5 9.5S5.7 8 6.5 8 8 8.7 8 9.5 7.3 11 6.5 11zm11 0c-.8 0-1.5-.7-1.5-1.5S16.7 8 17.5 8s1.5.7 1.5 1.5-.7 1.5-1.5 1.5z'
)
await icon.nth(3).click()
await expect(page.locator('.tiny-rate > span:nth-child(4) > .tiny-svg > .st0').last()).toHaveAttribute(
await expect(page.locator('.tiny-rate > span:nth-child(4) > .tiny-svg > path').last()).toHaveAttribute(
'd',
'M12 24C5.4 24 0 18.6 0 12S5.4 0 12 0s12 5.4 12 12-5.4 12-12 12zm0-2c5.5 0 10-4.5 10-10S17.5 2 12 2 2 6.5 2 12s4.5 10 10 10z'
)
await icon.nth(4).click()
await expect(page.locator('.tiny-rate > span:nth-child(5) > .tiny-svg > .st0').last()).toHaveAttribute(
await expect(page.locator('.tiny-rate > span:nth-child(5) > .tiny-svg > path').last()).toHaveAttribute(
'd',
'M12 24C5.4 24 0 18.6 0 12S5.4 0 12 0s12 5.4 12 12-5.4 12-12 12zm0-2c5.5 0 10-4.5 10-10S17.5 2 12 2 2 6.5 2 12s4.5 10 10 10z'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.describe('Rate 自定义禁用时未选中图标类名', () => {
await expect(icon.nth(4)).toHaveClass(/disabled/)

// 未选中图标
const svg = page.locator('.tiny-rate > span:nth-child(5) > .tiny-svg > .st0')
const svg = page.locator('.tiny-rate > span:nth-child(5) > .tiny-svg > path')
await expect(svg).toHaveAttribute(
'd',
'M12 2.8c.1 0 .3.1.3.2l2.6 5.5c.1.1.2.2.3.2l5.8.9c.3 0 .4.4.2.6L17 14.5c-.1.1-.1.2-.1.3l1 6.1c0 .2-.1.4-.4.4h-.2l-5.1-2.8h-.4l-5.1 2.8h-.2c-.2 0-.4-.2-.4-.4l1-6.1c0-.1 0-.2-.1-.3l-4.2-4.3c-.2-.2-.1-.6.2-.6l5.8-.9c.1 0 .2-.1.3-.2L11.7 3c0-.2.2-.2.3-.2zM12 1c-.4 0-.8.1-1.1.3-.4.2-.6.5-.8.9L7.8 7l-5 .8c-.8.1-1.4.7-1.7 1.4s-.1 1.6.5 2.2l3.7 3.8-.9 5.4c-.1.6.1 1.2.5 1.7s1 .8 1.6.8c.4 0 .7-.1 1-.3l4.4-2.5 4.4 2.5c.3.2.7.3 1 .3.6 0 1.2-.3 1.6-.8.4-.5.6-1.1.5-1.7l-.9-5.4 3.7-3.8c.6-.6.7-1.4.5-2.2-.3-.8-.9-1.3-1.7-1.4L16 7l-2.2-4.8c-.2-.4-.5-.7-.8-.9-.2-.2-.6-.3-1-.3z'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test.describe('Rate 自定义未选中图标类名', () => {
await page.goto('rate#not-selected-class')

const icon = page.locator('.tiny-rate__star > .tiny-svg')
const svg = page.locator('span:nth-child(5) > .tiny-svg > .st0')
const svg = page.locator('span:nth-child(5) > .tiny-svg > path')

await icon.nth(4).hover()
await expect(svg).toHaveAttribute(
Expand Down
1 change: 0 additions & 1 deletion examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ test('基本使用,无数据场景', async ({ page }) => {
const treeMenu = wrap.locator('.tiny-tree-menu')

await expect(treeMenu.locator('.tiny-input__inner')).toBeVisible()
await expect(treeMenu).toContainText('暂无数据')
})
3 changes: 2 additions & 1 deletion examples/sites/demos/pc/app/tree-menu/props.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ test('字段映射', async ({ page }) => {

// 过滤功能
await treeMenu.locator('.tiny-input__inner').fill('添加标签页')
await expect(page.getByTitle('添加标签页')).toBeVisible()
await page.waitForTimeout(500)
await expect(treeNodeContent.filter({ hasText: /^添加标签页$/ })).toBeVisible()
await expect(treeNodeContent.filter({ hasText: /^指南$/ })).toBeHidden()
await treeMenu.locator('.tiny-input__inner').clear()
await expect(treeNodeContent.filter({ hasText: /^指南$/ })).toBeVisible()
Expand Down
5 changes: 3 additions & 2 deletions packages/renderless/src/tree-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ export const setMenuKey =
return newData
}

export const filterNode = () => (value, data) => {
export const filterNode = (props) => (value, data) => {
if (!value) {
return true
}
return data.label.includes(value)
const propsLabel = props.props?.label || 'label'
return data[propsLabel].includes(value)
}

export const watchFilterText =
Expand Down
2 changes: 1 addition & 1 deletion packages/renderless/src/tree-menu/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const renderless = (
t,
state,
check: check(emit),
filterNode: filterNode(),
filterNode: filterNode(props),
nodeDrop: nodeDrop(emit),
nodeClick: nodeClick({ emit, props, state }),
nodeExpand: nodeExpand(emit),
Expand Down
Loading