-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:opentiny/tiny-vue into wyp/guide-old…
…xdesign-1120
- Loading branch information
Showing
25 changed files
with
333 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
examples/sites/demos/pc/app/tree-select/collapse-tags.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('折叠标签 collapse-tags', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#collapse-tags') | ||
const wrap = page.locator('#collapse-tags') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
const tag = select.locator('.tiny-tag') | ||
const treeNode = dropdown.locator('.tiny-tree-node') | ||
const checkedTreeNodes = dropdown.locator('.tiny-tree-node.is-checked') | ||
|
||
// 验证默认值的折叠标签显示 | ||
await expect(tag).toHaveCount(2) | ||
await expect(tag.filter({ hasText: '三级 1-1-1' })).toBeVisible() | ||
await expect(tag.filter({ hasText: '+ 1' })).toBeVisible() | ||
|
||
// 点击下拉后选中效果 | ||
await tag.first().click() | ||
await expect(checkedTreeNodes).toHaveCount(2) | ||
await expect(treeNode.nth(2)).toHaveClass(/is-checked/) | ||
await expect(treeNode.nth(6)).toHaveClass(/is-checked/) | ||
|
||
// 取消选中一个 | ||
await page.getByRole('treeitem', { name: '三级 1-1-1' }).locator('path').nth(1).click() | ||
await expect(tag.filter({ hasText: '+ 1' })).toBeHidden() | ||
await expect(tag).toHaveCount(1) | ||
|
||
// 再选中2个 | ||
await page.getByRole('treeitem', { name: '三级 1-1-1' }).locator('path').nth(1).click() | ||
await page.getByRole('treeitem', { name: '三级 1-1-2' }).locator('path').nth(1).click() | ||
await expect(tag.filter({ hasText: '+ 4' })).toBeVisible() | ||
await expect(tag).toHaveCount(2) | ||
}) |
9 changes: 4 additions & 5 deletions
9
examples/sites/demos/pc/app/tree-select/copy-composition-api.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('多选一键复制所有标签', async ({ page }) => { | ||
await page.goto('tree-select#copy') | ||
|
||
const wrap = page.locator('#copy') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const copyValueInput = wrap.locator('.copy-value .tiny-input__inner') | ||
const copyIcon = select.locator('.tiny-base-select__copy .tiny-svg') | ||
|
||
await select.hover() | ||
await expect(copyIcon).toBeVisible() | ||
await copyIcon.click() | ||
await copyValueInput.press('Control+V') | ||
await expect(copyValueInput).toHaveValue('三级 1-1-1,二级 2-2') | ||
}) | ||
|
||
test('多选设置复制文本分隔符', async ({ page }) => { | ||
await page.goto('tree-select#copy') | ||
|
||
const wrap = page.locator('#copy') | ||
const select = wrap.locator('.tiny-tree-select').nth(1) | ||
const copyValueInput = wrap.locator('.copy-value .tiny-input__inner') | ||
|
||
await page.waitForTimeout(200) | ||
await select.hover() | ||
await select.locator('.tiny-base-select__copy > .tiny-svg').click() | ||
await copyValueInput.press('Control+V') | ||
await expect(copyValueInput).toHaveValue('三级 1-1-1/二级 2-2') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('禁用', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#disabled') | ||
|
||
const wrap = page.locator('#disabled') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const input = select.locator('.tiny-input__inner') | ||
|
||
const hasDisabled = await input.evaluate((input) => input.hasAttribute('disabled')) | ||
await expect(hasDisabled).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('映射字段', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#map-field') | ||
|
||
const wrap = page.locator('#map-field') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const input = select.locator('.tiny-input__inner') | ||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
const treeNode = dropdown.locator('.tiny-tree-node') | ||
|
||
await input.click() | ||
await treeNode.filter({ hasText: /^二级 2-1$/ }).click() | ||
await expect(input).toHaveValue('二级 2-1') | ||
await input.click() | ||
await expect(treeNode.filter({ hasText: /^二级 2-1$/ })).toHaveClass(/is-current/) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('下拉树多选', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#multiple') | ||
|
||
const wrap = page.locator('#multiple') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
|
||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
const suffixSvg = select.locator('.tiny-input__suffix .tiny-base-select__caret') | ||
const treeNode = dropdown.locator('.tiny-tree-node') | ||
const checkedTreeNodes = dropdown.locator('.tiny-tree-node.is-checked') | ||
const tag = select.locator('.tiny-tag') | ||
|
||
await expect(tag).toHaveCount(2) | ||
|
||
await suffixSvg.click() | ||
await expect(checkedTreeNodes).toHaveCount(2) | ||
await expect(treeNode).toHaveCount(7) | ||
await page | ||
.locator('div') | ||
.filter({ hasText: /^一级 2$/ }) | ||
.locator('.tiny-checkbox') | ||
.click() | ||
|
||
await expect(checkedTreeNodes).toHaveCount(4) | ||
await expect(tag).toHaveCount(4) | ||
}) |
16 changes: 16 additions & 0 deletions
16
examples/sites/demos/pc/app/tree-select/native-properties.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('原生属性', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#native-properties') | ||
|
||
const wrap = page.locator('#native-properties') | ||
const select = wrap.locator('.tiny-tree-select') | ||
const input = select.locator('.tiny-input__inner') | ||
|
||
await expect(input).toHaveAttribute('name', 'inputName') | ||
await expect(input).toHaveAttribute('placeholder', '请选择一个选项') | ||
|
||
const isHasAutocomplete = await input.evaluate((input) => input.hasAttribute('autocomplete')) | ||
await expect(isHasAutocomplete).toBe(true) | ||
}) |
38 changes: 38 additions & 0 deletions
38
examples/sites/demos/pc/app/tree-select/panel-style.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('不挂载在 body 元素上', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#panel-style') | ||
|
||
const wrap = page.locator('#panel-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const dropdown = select.locator('.tiny-base-select__tags-group > .tiny-select-dropdown') | ||
|
||
await select.click() | ||
await expect(dropdown).toHaveCount(1) | ||
}) | ||
|
||
test('自定义类名', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#panel-style') | ||
|
||
const wrap = page.locator('#panel-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(1) | ||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
|
||
await select.click() | ||
await expect(dropdown).toHaveClass(/drop/) | ||
await expect(dropdown).toHaveCSS('box-shadow', 'rgba(0, 0, 0, 0.35) 0px 5px 15px 0px') | ||
}) | ||
|
||
test('从上方弹出面板', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#panel-style') | ||
|
||
const wrap = page.locator('#panel-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(2) | ||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
|
||
await select.click() | ||
await expect(dropdown).toHaveAttribute('x-placement', 'top') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
examples/sites/demos/pc/app/tree-select/reference-style.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('自定义下拉图标', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#reference-style') | ||
|
||
const wrap = page.locator('#reference-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(0) | ||
const suffixIconPath = select.locator('.tiny-input__suffix .tiny-base-select__caret path') | ||
|
||
await expect(suffixIconPath).toHaveAttribute( | ||
'd', | ||
'M2.3 7.78v.08c.02.65.561 1.17 1.221 1.17.68 0 1.229-.54 1.229-1.21 0-.672-.549-1.21-1.229-1.21-.66 0-1.2.519-1.22 1.17Zm4.241.04c0 .67.54 1.21 1.22 1.21.68 0 1.23-.54 1.23-1.21 0-.672-.55-1.21-1.23-1.21-.68 0-1.22.538-1.22 1.21Zm4.24.04v-.08c.02-.651.559-1.17 1.219-1.17.682 0 1.23.538 1.23 1.21 0 .67-.548 1.21-1.23 1.21-.66 0-1.2-.52-1.219-1.17Z' | ||
) | ||
}) | ||
|
||
test('标签类型', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#reference-style') | ||
|
||
const wrap = page.locator('#reference-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(1) | ||
const tag = select.locator('.tiny-tag') | ||
|
||
// 验证是否有对应类型的类名 | ||
await expect(tag.nth(0)).toHaveClass(/tiny-tag--warning/) | ||
}) | ||
|
||
test('下划线类型', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('tree-select#reference-style') | ||
const wrap = page.locator('#reference-style') | ||
const select = wrap.locator('.tiny-tree-select').nth(2) | ||
const input = select.locator('.tiny-input__inner') | ||
const dropdown = page.locator('body > .tiny-select-dropdown') | ||
const treeNode = dropdown.locator('.tiny-tree-node') | ||
|
||
await expect(select.locator('.tiny-input')).toHaveClass(/tiny-input-underline/) | ||
await expect(input).toHaveCSS('border-top-width', '0px') | ||
await expect(input).toHaveCSS('border-left-width', '0px') | ||
await expect(input).toHaveCSS('border-right-width', '0px') | ||
await expect(input).toHaveCSS('border-bottom-color', 'rgb(194, 194, 194)') | ||
|
||
await select.click() | ||
await treeNode.filter({ hasText: /^二级 2-1$/ }).click() | ||
await expect(dropdown).toBeHidden() | ||
await expect(input).toHaveValue('二级 2-1') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.