diff --git a/examples/sites/demos/pc/app/tree-menu/accordion.spec.ts b/examples/sites/demos/pc/app/tree-menu/accordion.spec.ts index 6b79006e8..953962f1f 100644 --- a/examples/sites/demos/pc/app/tree-menu/accordion.spec.ts +++ b/examples/sites/demos/pc/app/tree-menu/accordion.spec.ts @@ -4,7 +4,9 @@ test('手风琴', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('tree-menu#accordion') - const treeMenu = page.locator('#preview .tiny-tree-menu') + const wrap = page.locator('#accordion') + const treeMenu = wrap.locator('.tiny-tree-menu') + await treeMenu.getByTitle('指南').click() await expect(treeMenu.getByTitle('引入组件')).toBeVisible() await expect(treeMenu.getByTitle('构建部署')).toBeVisible() diff --git a/examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts b/examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts index 2f7243245..924f55dab 100644 --- a/examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts +++ b/examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts @@ -4,7 +4,9 @@ test('基本使用,无数据场景', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('tree-menu#basic-usage') - const treeMenu = page.locator('#preview .tiny-tree-menu') - await expect(treeMenu.getByPlaceholder('请输入内容进行筛选').locator('input')).toBeVisible() + const wrap = page.locator('#basic-usage') + const treeMenu = wrap.locator('.tiny-tree-menu') + + await expect(treeMenu.locator('.tiny-input__inner')).toBeVisible() await expect(treeMenu).toContainText('暂无数据') }) diff --git a/examples/sites/demos/pc/app/tree-menu/current-node-composition-api.vue b/examples/sites/demos/pc/app/tree-menu/current-node-composition-api.vue index 7d33c42a8..8927cba72 100644 --- a/examples/sites/demos/pc/app/tree-menu/current-node-composition-api.vue +++ b/examples/sites/demos/pc/app/tree-menu/current-node-composition-api.vue @@ -4,9 +4,13 @@ setCurrentKey

场景2:通过 setCurrentNode(node:ITreeNode) 设置当前节点

setCurrentNode -

场景3:通过 getCurrentKey() 获取当前节点的 key 为:{{ currentKey }}

+

+ 场景3:通过 getCurrentKey() 获取当前节点的 key 为:{{ currentKey }} +

getCurrentKey -

场景4:通过 getCurrentNode() 获取当前节点的数据为:{{ currentNode }}

+

+ 场景4:通过 getCurrentNode() 获取当前节点的数据为:{{ currentNode }} +

getCurrentNode import { ref, reactive } from 'vue' -import { TreeMenu as TinyTreeMenu, Button as TinyButton, Row as TinyRow, Col as TinyCol } from '@opentiny/vue' +import { TreeMenu as TinyTreeMenu, Button as TinyButton } from '@opentiny/vue' const treeMenu = ref(null) const treeData = reactive([ diff --git a/examples/sites/demos/pc/app/tree-menu/current-node.spec.ts b/examples/sites/demos/pc/app/tree-menu/current-node.spec.ts index 38adb3788..2766d0c14 100644 --- a/examples/sites/demos/pc/app/tree-menu/current-node.spec.ts +++ b/examples/sites/demos/pc/app/tree-menu/current-node.spec.ts @@ -4,22 +4,29 @@ test('设置当前节点', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) await page.goto('tree-menu#current-node') - const treeMenu = page.locator('#preview .tiny-tree-menu') + const wrap = page.locator('#current-node') + const treeMenu = wrap.locator('.tiny-tree-menu') + const treeNode = treeMenu.locator('.tiny-tree-node__wrapper > .tiny-tree-node') + const button = wrap.locator('.tiny-button') const currentCls = /is-current/ // 通过key设置当前节点 - await page.getByRole('button', { name: '设置当前选中的节点的 key' }).click() - await expect(treeMenu.locator('.tiny-tree-node').filter({ hasText: '按需引入' }).nth(2)).toHaveClass(currentCls) - await page.getByRole('button', { name: '获取当前被选中节点的 key' }).click() - await expect(page.locator('#current-node-key')).toHaveText('20101') - await page.getByRole('button', { name: '获取当前选中的节点' }).click() - await expect(page.locator('#current-node')).toHaveText('{ "id": 20101, "label": "按需引入" }') + await button.nth(0).click() + await expect(treeNode.filter({ hasText: /^按需引入$/ })).toHaveClass(currentCls) + // 获取当前被选中节点的 key + await button.nth(2).click() + await expect(wrap.locator('.current-node-key')).toHaveText('20101') + // 获取当前节点的数据 + await button.nth(3).click() + await expect(wrap.locator('.current-node')).toHaveText('{ "id": 20101, "label": "按需引入" }') // 通过node设置当前节点 - await page.getByRole('button', { name: '设置当前选中的节点' }).nth(1).click() - await expect(treeMenu.locator('.tiny-tree-node').filter({ hasText: '规范' })).toHaveClass(currentCls) - await page.getByRole('button', { name: '获取当前被选中节点的 key' }).click() - await expect(page.locator('#current-node-key')).toHaveText('500') - await page.getByRole('button', { name: '获取当前选中的节点' }).click() - await expect(page.locator('#current-node')).toHaveText('{ "id": 500, "label": "规范" }') + await button.nth(1).click() + await expect(treeNode.filter({ hasText: /^规范$/ })).toHaveClass(currentCls) + // 获取当前被选中节点的 key + await button.nth(2).click() + await expect(wrap.locator('.current-node-key')).toHaveText('500') + // 获取当前节点的数据 + await button.nth(3).click() + await expect(wrap.locator('.current-node')).toHaveText('{ "id": 500, "label": "规范" }') }) diff --git a/examples/sites/demos/pc/app/tree-menu/current-node.vue b/examples/sites/demos/pc/app/tree-menu/current-node.vue index adf8814de..3c929a1d6 100644 --- a/examples/sites/demos/pc/app/tree-menu/current-node.vue +++ b/examples/sites/demos/pc/app/tree-menu/current-node.vue @@ -4,9 +4,13 @@ setCurrentKey

场景2:通过 setCurrentNode(node:ITreeNode) 设置当前节点

setCurrentNode -

场景3:通过 getCurrentKey() 获取当前节点的 key 为:{{ currentKey }}

+

+ 场景3:通过 getCurrentKey() 获取当前节点的 key 为:{{ currentKey }} +

getCurrentKey -

场景4:通过 getCurrentNode() 获取当前节点的数据为:{{ currentNode }}

+

+ 场景4:通过 getCurrentNode() 获取当前节点的数据为:{{ currentNode }} +

getCurrentNode