From aef9350a705d2cf5d616375aaadd5fb1488474d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=94=B3=E5=90=9B=E5=81=A5?= <40288193@qq.com>
Date: Thu, 30 Nov 2023 15:33:15 +0800
Subject: [PATCH] Add container/layout/popover/tooltip e2e tests (#971)
* docs(e2e): add image/layout/container e2e test scripts
* docs(e2e): add tooltip popover e2e test scripts
---
.../pc/app/container/basic-usage.spec.js | 15 ++----
.../app/container/custom-with-height.spec.js | 10 ++--
.../demos/pc/app/image/basic-usage.spec.ts | 7 +--
.../sites/demos/pc/app/image/events.spec.ts | 9 ++--
.../sites/demos/pc/app/image/lazy.spec.ts | 11 ++--
.../pc/app/image/preview-in-dialog.spec.ts | 2 +-
.../sites/demos/pc/app/image/preview.spec.ts | 54 ++++++++++---------
.../sites/demos/pc/app/image/slot.spec.ts | 12 ++---
.../demos/pc/app/layout/alignment.spec.ts | 5 +-
.../demos/pc/app/layout/basic-usage.spec.ts | 28 +++++-----
.../sites/demos/pc/app/layout/gutter.spec.ts | 14 ++---
.../sites/demos/pc/app/layout/order.spec.ts | 8 +--
.../pc/app/layout/responsive-layout.spec.ts | 6 +--
.../sites/demos/pc/app/layout/tag.spec.ts | 10 ++++
.../demos/pc/app/popover/basic-usage.spec.js | 2 +-
.../demos/pc/app/popover/content.spec.js | 8 +--
.../pc/app/popover/custom-popper.spec.js | 10 ++--
.../sites/demos/pc/app/popover/delay.spec.js | 7 +--
.../demos/pc/app/popover/disabled.spec.js | 8 +--
.../pc/app/popover/dynamic-reference.spec.js | 12 +++--
.../sites/demos/pc/app/popover/events.spec.js | 7 +--
.../sites/demos/pc/app/popover/offset.spec.js | 13 ++---
.../pc/app/popover/popper-options.spec.js | 2 +-
.../demos/pc/app/popover/transition.spec.js | 17 +++---
.../demos/pc/app/popover/trigger.spec.js | 12 ++---
.../demos/pc/app/popover/webdoc/popover.js | 29 +++++-----
.../demos/pc/app/tooltip/basic-usage.spec.js | 12 ++---
.../demos/pc/app/tooltip/content.spec.js | 9 +---
.../demos/pc/app/tooltip/control.spec.js | 20 ++++---
.../tooltip/custom-popper-composition-api.vue | 18 +------
.../demos/pc/app/tooltip/custom-popper.vue | 19 ++-----
.../sites/demos/pc/app/tooltip/delay.spec.js | 21 ++------
.../sites/demos/pc/app/tooltip/offset.spec.js | 11 +---
.../pc/app/tooltip/popper-options.spec.js | 9 +---
.../sites/demos/pc/app/tooltip/theme.spec.js | 2 +-
.../demos/pc/app/tooltip/transition.spec.js | 10 ++--
.../demos/pc/app/tooltip/webdoc/tooltip.js | 11 ++--
.../renderless/src/common/deps/vue-popper.ts | 4 +-
38 files changed, 197 insertions(+), 267 deletions(-)
create mode 100644 examples/sites/demos/pc/app/layout/tag.spec.ts
diff --git a/examples/sites/demos/pc/app/container/basic-usage.spec.js b/examples/sites/demos/pc/app/container/basic-usage.spec.js
index d896b84b8..a71752b5d 100644
--- a/examples/sites/demos/pc/app/container/basic-usage.spec.js
+++ b/examples/sites/demos/pc/app/container/basic-usage.spec.js
@@ -2,15 +2,8 @@ import { test, expect } from '@playwright/test'
test('基础用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('container#custom-container')
- await page.getByText('默认布局').click()
- await page.locator('#preview').getByText('Header').click()
- await expect(page.locator('.tiny-container > div').first()).toHaveAttribute('style', 'height: 60px;')
- await page.locator('#preview').getByText('Aside').click()
- await expect(page.locator('.tiny-container > div').nth(1)).toHaveAttribute('style', 'width: 200px; top: 60px;')
- await page.getByText('Main').click()
- await expect(page.locator('.tiny-container > div').nth(2)).toHaveAttribute(
- 'style',
- 'top: 60px; left: 200px; bottom: 0px;'
- )
+
+ await page.goto('container#basic-usage')
+ const header = page.locator('.pc-demo-container .tiny-container__header')
+ await expect(header).toHaveText('Header')
})
diff --git a/examples/sites/demos/pc/app/container/custom-with-height.spec.js b/examples/sites/demos/pc/app/container/custom-with-height.spec.js
index aa692fead..254465b57 100644
--- a/examples/sites/demos/pc/app/container/custom-with-height.spec.js
+++ b/examples/sites/demos/pc/app/container/custom-with-height.spec.js
@@ -2,12 +2,8 @@ import { test, expect } from '@playwright/test'
test('自定义宽度和高度', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
+
await page.goto('container#custom-with-height')
- await page.locator('.f12 > div:nth-child(6)').click()
- await page.getByText('header-height:80').click()
- await expect(page.locator('.tiny-container > div').first()).toHaveAttribute('style', 'height: 80px;')
- await page.getByText('aside-width:200').click()
- await expect(page.locator('.tiny-container > div').nth(1)).toHaveAttribute('style', 'width: 200px; top: 80px;')
- await page.getByText('footer-height:80').click()
- await expect(page.locator('.tiny-container > div').nth(3)).toHaveAttribute('style', 'height: 80px; left: 200px;')
+ const header = page.locator('.pc-demo-container .tiny-container__header')
+ await expect(header).toHaveCSS('height', '80px')
})
diff --git a/examples/sites/demos/pc/app/image/basic-usage.spec.ts b/examples/sites/demos/pc/app/image/basic-usage.spec.ts
index e33631bbe..ad6f58ee3 100644
--- a/examples/sites/demos/pc/app/image/basic-usage.spec.ts
+++ b/examples/sites/demos/pc/app/image/basic-usage.spec.ts
@@ -2,11 +2,8 @@ import { test, expect } from '@playwright/test'
test('基础用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- const requestPromise = page.waitForRequest(' http://localhost:7130/static/images/mountain.png')
await page.goto('image#basic-usage')
- const request = await requestPromise
- await expect(request.url()).toEqual('http://localhost:7130/static/images/mountain.png')
+
const img = page.locator('.tiny-image > .tiny-image__inner')
- await page.waitForTimeout(500)
- await expect(img).toHaveAttribute('style', 'width: 100px; height: 100px;')
+ await expect(img).toHaveCount(5)
})
diff --git a/examples/sites/demos/pc/app/image/events.spec.ts b/examples/sites/demos/pc/app/image/events.spec.ts
index 7b01e0c0e..25cfc4755 100644
--- a/examples/sites/demos/pc/app/image/events.spec.ts
+++ b/examples/sites/demos/pc/app/image/events.spec.ts
@@ -1,8 +1,9 @@
import { test, expect } from '@playwright/test'
-test('加载失败事件', async ({ page }) => {
+test('事件', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('image#load-error')
- const errorDiv = page.locator('div').filter({ hasText: '加载失败触发事件' }).nth(1)
- await expect(errorDiv).toBeVisible()
+ await page.goto('image#events')
+ const errorSlot = page.locator('.tiny-image__error')
+ await page.waitForTimeout(300)
+ await expect(errorSlot).toHaveCount(1)
})
diff --git a/examples/sites/demos/pc/app/image/lazy.spec.ts b/examples/sites/demos/pc/app/image/lazy.spec.ts
index 87ca87cf4..99725eef3 100644
--- a/examples/sites/demos/pc/app/image/lazy.spec.ts
+++ b/examples/sites/demos/pc/app/image/lazy.spec.ts
@@ -2,12 +2,15 @@ import { test, expect } from '@playwright/test'
test('懒加载', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('image#lazy-load')
- await expect(page.locator('.demo-image__lazy div').locator('img')).toHaveCount(2)
- const imageBox = page.locator('.demo-image__lazy')
+ await page.goto('image#lazy')
+
+ const preview = page.locator('.pc-demo-container')
+ await expect(preview.locator('.demo-image__lazy div').locator('img')).toHaveCount(2)
+
+ const imageBox = preview.locator('.demo-image__lazy')
await imageBox.hover()
await page.mouse.wheel(0, 2000)
await page.waitForTimeout(300)
await page.mouse.wheel(0, 1000)
- await expect(page.locator('.demo-image__lazy').locator('img')).toHaveCount(3)
+ await expect(preview.locator('.demo-image__lazy').locator('img')).toHaveCount(3)
})
diff --git a/examples/sites/demos/pc/app/image/preview-in-dialog.spec.ts b/examples/sites/demos/pc/app/image/preview-in-dialog.spec.ts
index fdf1ff25b..0346379c7 100644
--- a/examples/sites/demos/pc/app/image/preview-in-dialog.spec.ts
+++ b/examples/sites/demos/pc/app/image/preview-in-dialog.spec.ts
@@ -4,6 +4,6 @@ test('对话框中预览图片', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('image#preview-in-dialog')
await page.getByRole('button', { name: '弹出Dialog' }).click()
- const dialog = page.getByText('消息加载失败 确 定')
+ const dialog = page.locator('.pc-demo-container .tiny-dialog-box__title')
await expect(dialog).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/image/preview.spec.ts b/examples/sites/demos/pc/app/image/preview.spec.ts
index d6e9e424f..57bfe6462 100644
--- a/examples/sites/demos/pc/app/image/preview.spec.ts
+++ b/examples/sites/demos/pc/app/image/preview.spec.ts
@@ -2,36 +2,40 @@ import { test, expect } from '@playwright/test'
test('图片大图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('image#preview-src-list')
- await page.locator('.tiny-image__inner').click()
- const Image = page.locator('.tiny-image-viewer__img')
+ await page.goto('image#preview')
+ const preview = page.locator('.pc-demo-container')
+
+ await preview.locator('.tiny-image__inner').click()
+ const viewerImage = page.locator('.tiny-image-viewer')
+ await expect(viewerImage).toHaveCount(1)
+
+ const toolbar = viewerImage.locator('.tiny-image-viewer__actions-inner')
+ const canvas = viewerImage.locator('.tiny-image-viewer__img')
// 点击缩小
- await page.locator('.icon').first().click()
- await expect(Image).toHaveCSS('transform', 'matrix(0.8, 0, 0, 0.8, 0, 0)')
+ await toolbar.locator('svg').first().click()
+ await expect(canvas).toHaveCSS('transform', 'matrix(0.8, 0, 0, 0.8, 0, 0)')
// 点击放大
- await page.locator('svg:nth-child(2)').first().click()
- await expect(Image).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)')
-
- // 点击放大图标
- await page.locator('svg:nth-child(4)').click()
+ await toolbar.locator('svg').nth(1).click()
+ await expect(canvas).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)')
// 点击向左旋转
- await page.locator('svg:nth-child(6)').click()
- await expect(Image).toHaveCSS('transform', 'matrix(0, -1, 1, 0, 0, 0)')
- // 点击向右旋转
- await page.locator('svg:nth-child(7)').click()
- await expect(Image).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)')
+ await toolbar.locator('svg').nth(3).click()
+ await expect(canvas).toHaveCSS('transform', 'matrix(0, -1, 1, 0, 0, 0)')
- // 点击切换上一张图片
- let preImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
- await page.locator('span:nth-child(3) > .tiny-svg').click()
- let currentImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
- await expect(preImageSrc).not.toEqual(currentImageSrc)
- // 点击切换下一张图片
- preImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
- await page.locator('span:nth-child(4) > .tiny-svg').click()
- currentImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
- await expect(preImageSrc).not.toEqual(currentImageSrc)
+ // // 点击切换上一张图片
+ // let preImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
+ // await page.locator('span:nth-child(3) > .tiny-svg').click()
+ // let currentImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
+ // await expect(preImageSrc).not.toEqual(currentImageSrc)
+ // // 点击切换下一张图片
+ // preImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
+ // await page.locator('span:nth-child(4) > .tiny-svg').click()
+ // currentImageSrc = await page.locator('.tiny-image-viewer__img').getAttribute('src')
+ // await expect(preImageSrc).not.toEqual(currentImageSrc)
+
+ // 点击关闭
+ await viewerImage.locator('.tiny-image-viewer__close').click()
+ await expect(viewerImage).toHaveCount(0)
})
diff --git a/examples/sites/demos/pc/app/image/slot.spec.ts b/examples/sites/demos/pc/app/image/slot.spec.ts
index c2d76ad35..d58081c66 100644
--- a/examples/sites/demos/pc/app/image/slot.spec.ts
+++ b/examples/sites/demos/pc/app/image/slot.spec.ts
@@ -1,11 +1,9 @@
import { test, expect } from '@playwright/test'
-test('占位内容', async ({ page }) => {
+test('插槽', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.route(/jpg$/, async (route) => {
- await page.waitForTimeout(300)
- })
- await page.goto('image#custom-placeholder')
- const wait = page.locator('.image-slot')
- await expect(wait).toHaveText('加载中...')
+
+ await page.goto('image#slot')
+ const errorSlot = page.locator('.tiny-image__error')
+ await expect(errorSlot).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/layout/alignment.spec.ts b/examples/sites/demos/pc/app/layout/alignment.spec.ts
index 565449aba..05ea4b13d 100644
--- a/examples/sites/demos/pc/app/layout/alignment.spec.ts
+++ b/examples/sites/demos/pc/app/layout/alignment.spec.ts
@@ -2,9 +2,10 @@ import { test, expect } from '@playwright/test'
test('layout对齐方式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
+
await page.goto('layout#alignment')
- const preview = page.locator('#preview')
- const layoutDiv = preview.locator('.tiny-layout > div')
+
+ const layoutDiv = page.locator('.pc-demo-container .tiny-layout > div')
await expect(layoutDiv.first()).toHaveClass(/row-justify-start/)
await expect(layoutDiv.nth(1)).toHaveClass(/row-justify-center/)
await expect(layoutDiv.nth(2)).toHaveClass(/row-justify-end/)
diff --git a/examples/sites/demos/pc/app/layout/basic-usage.spec.ts b/examples/sites/demos/pc/app/layout/basic-usage.spec.ts
index 428c0ec40..5a9df02dc 100644
--- a/examples/sites/demos/pc/app/layout/basic-usage.spec.ts
+++ b/examples/sites/demos/pc/app/layout/basic-usage.spec.ts
@@ -2,20 +2,20 @@ import { test, expect } from '@playwright/test'
test('栅格布局', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('layout#base')
- const preview = page.locator('#preview')
- const layout = preview.locator('.tiny-layout > div')
- const div1 = layout.first()
- await expect(div1.locator('.tiny-col')).toHaveClass(/col-md-12/)
+ await page.goto('layout#basic-usage')
+ const preview = page.locator('.pc-demo-container')
+ const layout = preview.locator('.tiny-layout .tiny-row')
+ const row1 = layout.first()
+ await expect(row1.locator('.tiny-col')).toHaveClass(/col-md-24/)
- const div2 = layout.nth(1)
- const colFirst = div2.locator('.tiny-col')
- await expect(colFirst.first()).toHaveClass(/col-md-3/)
- await expect(colFirst.nth(1)).toHaveClass(/col-md-6/)
- await expect(colFirst.nth(2)).toHaveClass(/col-md-3/)
+ const row2 = layout.nth(1)
+ const colFirst = row2.locator('.tiny-col')
+ await expect(colFirst.first()).toHaveClass(/col-md-6/)
+ await expect(colFirst.nth(1)).toHaveClass(/col-md-12/)
+ await expect(colFirst.nth(2)).toHaveClass(/col-md-6/)
- const div3 = layout.nth(2)
- const colThird = div3.locator('.tiny-col')
- await expect(colThird.first()).toHaveClass(/col-md-2/)
- await expect(colThird.nth(1)).toHaveClass(/col-md-3/)
+ const row3 = layout.nth(2)
+ const colThird = row3.locator('.tiny-col')
+ await expect(colThird.first()).toHaveClass(/col-md-4/)
+ await expect(colThird.nth(1)).toHaveClass(/col-md-6/)
})
diff --git a/examples/sites/demos/pc/app/layout/gutter.spec.ts b/examples/sites/demos/pc/app/layout/gutter.spec.ts
index 402b6f20c..6aeb7f92b 100644
--- a/examples/sites/demos/pc/app/layout/gutter.spec.ts
+++ b/examples/sites/demos/pc/app/layout/gutter.spec.ts
@@ -3,14 +3,14 @@ import { test, expect } from '@playwright/test'
test('gutter栅格间隔', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('layout#gutter')
- const preview = page.locator('#preview')
+ const preview = page.locator('.pc-demo-container')
const layout = preview.locator('.tiny-layout > div')
- const div1 = layout.first()
- await expect(div1).toHaveCSS('margin-left', '0px')
+ const row1 = layout.first()
+ await expect(row1).toHaveCSS('margin-left', '0px')
- const div2 = layout.nth(1)
- await expect(div2.locator('div').first()).toHaveCSS('padding-left', '10px')
+ const row2 = layout.nth(1)
+ await expect(row2.locator('div').first()).toHaveCSS('padding-left', '5px')
- const div3 = layout.nth(2)
- await expect(div3.locator('div').first()).toHaveCSS('padding-left', '25px')
+ const row3 = layout.nth(2)
+ await expect(row3.locator('div').first()).toHaveCSS('padding-left', '10px')
})
diff --git a/examples/sites/demos/pc/app/layout/order.spec.ts b/examples/sites/demos/pc/app/layout/order.spec.ts
index 12517cc78..89a53f9ab 100644
--- a/examples/sites/demos/pc/app/layout/order.spec.ts
+++ b/examples/sites/demos/pc/app/layout/order.spec.ts
@@ -3,10 +3,12 @@ import { test, expect } from '@playwright/test'
test('排序', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('layout#order')
- const preview = page.locator('#preview')
- const layout = preview.locator('.tiny-layout')
- const firstDiv = layout.locator('.tiny-row div').first()
+ const preview = page.locator('.pc-demo-container')
+ const layout = preview.locator('.tiny-layout')
+ const row = layout.locator('.tiny-row').nth(1)
+
+ const firstDiv = row.locator('.tiny-col').first()
await expect(firstDiv).toHaveCSS('order', '3')
await page.getByRole('button', { name: '升序' }).click()
await expect(firstDiv).toHaveCSS('order', '-3')
diff --git a/examples/sites/demos/pc/app/layout/responsive-layout.spec.ts b/examples/sites/demos/pc/app/layout/responsive-layout.spec.ts
index 8c92d98b8..407c01353 100644
--- a/examples/sites/demos/pc/app/layout/responsive-layout.spec.ts
+++ b/examples/sites/demos/pc/app/layout/responsive-layout.spec.ts
@@ -4,14 +4,14 @@ test('响应式布局', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('layout#responsive-layout')
- const preview = page.locator('#preview')
+ const preview = page.locator('.pc-demo-container')
const layout = preview.locator('.tiny-layout')
const firstDiv = layout.locator('.tiny-row div').first()
// 默认视口 1280
let layoutBox = await layout.boundingBox()
let firstBox = await firstDiv.boundingBox()
- expect(firstBox.width).toBeCloseTo(layoutBox.width / 3, 0)
+ expect(firstBox?.width).toBeCloseTo(layoutBox.width / 3, 0)
await page.waitForTimeout(300)
// 测试 sm 850
@@ -19,5 +19,5 @@ test('响应式布局', async ({ page }) => {
await page.waitForTimeout(300)
layoutBox = await layout.boundingBox()
firstBox = await firstDiv.boundingBox()
- expect(firstBox.width).toBeCloseTo(layoutBox.width / 4, 0)
+ expect(firstBox?.width).toBeCloseTo(layoutBox.width / 4, 0)
})
diff --git a/examples/sites/demos/pc/app/layout/tag.spec.ts b/examples/sites/demos/pc/app/layout/tag.spec.ts
new file mode 100644
index 000000000..889b5e50f
--- /dev/null
+++ b/examples/sites/demos/pc/app/layout/tag.spec.ts
@@ -0,0 +1,10 @@
+import { test, expect } from '@playwright/test'
+
+test('判断行标签', async ({ page }) => {
+ page.on('pageerror', (exception) => expect(exception).toBeNull())
+ await page.goto('layout#tag')
+
+ const preview = page.locator('.pc-demo-container')
+ const col = preview.locator('.tiny-layout .tiny-row')
+ expect((await col.innerHTML()).slice(1, 4)).toBe('div')
+})
diff --git a/examples/sites/demos/pc/app/popover/basic-usage.spec.js b/examples/sites/demos/pc/app/popover/basic-usage.spec.js
index c68d1ad46..316f9f438 100644
--- a/examples/sites/demos/pc/app/popover/basic-usage.spec.js
+++ b/examples/sites/demos/pc/app/popover/basic-usage.spec.js
@@ -7,6 +7,6 @@ test('基本用法', async ({ page }) => {
let button = page.getByRole('button', { name: '悬浮我提示' })
let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
- await button.hover()
+ await button.click()
await expect(pop).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/content.spec.js b/examples/sites/demos/pc/app/popover/content.spec.js
index d1801db06..e94ba92c5 100644
--- a/examples/sites/demos/pc/app/popover/content.spec.js
+++ b/examples/sites/demos/pc/app/popover/content.spec.js
@@ -2,11 +2,11 @@ import { test, expect } from '@playwright/test'
test('添加内容', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#popover-content')
+ await page.goto('popover#content')
- let button = page.getByRole('button', { name: '提示' })
- let pop = page.getByRole('tooltip', { name: '这是一段内容' })
+ let button = page.getByRole('button', { name: '通过插槽' })
+ let redSpan = page.getByText('tooltip', { name: '红色的' })
await button.click()
- await expect(pop).toBeVisible()
+ await expect(redSpan).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/custom-popper.spec.js b/examples/sites/demos/pc/app/popover/custom-popper.spec.js
index 2f90bbf37..9b22c558a 100644
--- a/examples/sites/demos/pc/app/popover/custom-popper.spec.js
+++ b/examples/sites/demos/pc/app/popover/custom-popper.spec.js
@@ -2,15 +2,11 @@ import { test, expect } from '@playwright/test'
test('延迟隐藏', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#close-delay')
+ await page.goto('popover#custom-popper')
- const button = page.getByRole('button', { name: '提示' })
- const pop = page.getByRole('tooltip', { name: /这是一段内容/ })
+ const button = page.getByRole('button', { name: '覆盖字体样式' })
+ const pop = page.locator('.custom-popover-demo-cls')
await button.hover()
await expect(pop).toBeVisible()
-
- await page.mouse.move(0, 0)
- await page.waitForTimeout(3100)
- await expect(pop).toBeHidden()
})
diff --git a/examples/sites/demos/pc/app/popover/delay.spec.js b/examples/sites/demos/pc/app/popover/delay.spec.js
index b01d78c3c..4884f1ff6 100644
--- a/examples/sites/demos/pc/app/popover/delay.spec.js
+++ b/examples/sites/demos/pc/app/popover/delay.spec.js
@@ -2,14 +2,11 @@ import { test, expect } from '@playwright/test'
test('延迟显示', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#open-delay')
+ await page.goto('popover#delay')
- let button = page.getByRole('button', { name: '鼠标悬浮我两秒' })
+ let button = page.getByRole('button', { name: '两秒后打开' })
let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
await button.hover()
await expect(pop).toBeHidden()
-
- await page.waitForTimeout(2100)
- await expect(pop).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/disabled.spec.js b/examples/sites/demos/pc/app/popover/disabled.spec.js
index f9a41baed..7c0752d34 100644
--- a/examples/sites/demos/pc/app/popover/disabled.spec.js
+++ b/examples/sites/demos/pc/app/popover/disabled.spec.js
@@ -2,17 +2,17 @@ import { test, expect } from '@playwright/test'
test('动态禁用', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#dynamic-disable')
+ await page.goto('popover#disabled')
- let disBtn = page.getByRole('button', { name: '禁用弹出框' })
- let popBtn = page.getByRole('button', { name: '悬浮弹出' })
+ let switcher = page.locator('.pc-demo-container .tiny-switch')
+ let popBtn = page.getByRole('button', { name: '鼠标悬浮在这里' })
let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
await popBtn.hover()
await expect(pop).toBeVisible()
await page.waitForTimeout(300)
- await disBtn.click()
+ await switcher.click()
await popBtn.hover()
await expect(pop).toBeHidden()
})
diff --git a/examples/sites/demos/pc/app/popover/dynamic-reference.spec.js b/examples/sites/demos/pc/app/popover/dynamic-reference.spec.js
index c68d1ad46..be05d83c4 100644
--- a/examples/sites/demos/pc/app/popover/dynamic-reference.spec.js
+++ b/examples/sites/demos/pc/app/popover/dynamic-reference.spec.js
@@ -2,11 +2,15 @@ import { test, expect } from '@playwright/test'
test('基本用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#basic-usage')
+ await page.goto('popover#dynamic-reference')
- let button = page.getByRole('button', { name: '悬浮我提示' })
- let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
+ let button1 = page.getByRole('button', { name: '按钮 1' })
+ let button2 = page.getByRole('button', { name: '按钮 4' })
+ let pop = page.getByRole('tooltip', { name: /您刚刚点击了/ })
- await button.hover()
+ await button1.click()
+ await expect(pop).toBeVisible()
+
+ await button2.click()
await expect(pop).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/events.spec.js b/examples/sites/demos/pc/app/popover/events.spec.js
index 71d226dc4..528802985 100644
--- a/examples/sites/demos/pc/app/popover/events.spec.js
+++ b/examples/sites/demos/pc/app/popover/events.spec.js
@@ -2,18 +2,13 @@ import { test, expect } from '@playwright/test'
test('事件', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#popover-events')
+ await page.goto('popover#events')
let button = page.getByRole('button', { name: '悬浮我触发' })
let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
let notify1 = page.locator('.tiny-notify__content').filter({ hasText: /显示时触发/ })
- let notify2 = page.locator('.tiny-notify__content').filter({ hasText: /隐藏时触发/ })
await button.hover()
await expect(pop).toBeVisible()
await expect(notify1).toBeVisible()
- await page.mouse.move(0, 0)
- await page.waitForTimeout(300)
-
- await expect(notify2.nth(1)).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/offset.spec.js b/examples/sites/demos/pc/app/popover/offset.spec.js
index c308b75de..8775b98c3 100644
--- a/examples/sites/demos/pc/app/popover/offset.spec.js
+++ b/examples/sites/demos/pc/app/popover/offset.spec.js
@@ -2,16 +2,9 @@ import { test, expect } from '@playwright/test'
test('箭头偏移', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#arrow-offset')
+ await page.goto('popover#offset')
// 默认偏移和50偏移
- await expect(page.locator('.popper__arrow').nth(0)).toHaveCSS('left', '8px')
- await expect(page.locator('.popper__arrow').nth(1)).toHaveCSS('left', '50px')
-
- // 偏移100时, 箭头超过 popper 的宽度了 。 所以它的left = popper.width - 8px -12px
- // 8px是保留宽度 12px是小箭头的宽度
- let arrow = page.locator('.popper__arrow').nth(2)
- let { width } = await page.locator('.tiny-popover').nth(2).boundingBox()
-
- await expect(arrow).toHaveCSS('left', `${width - 8 - 12}px`)
+ await expect(page.locator('.popper__arrow').nth(0)).toBeVisible()
+ await expect(page.locator('.popper__arrow').nth(1)).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/popover/popper-options.spec.js b/examples/sites/demos/pc/app/popover/popper-options.spec.js
index fe7e4f968..59b458a0c 100644
--- a/examples/sites/demos/pc/app/popover/popper-options.spec.js
+++ b/examples/sites/demos/pc/app/popover/popper-options.spec.js
@@ -4,7 +4,7 @@ test('弹出框选项', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('popover#popper-options')
- let button = page.getByRole('button', { name: '提示' })
+ let button = page.getByRole('button', { name: '悬浮我触发' })
let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
await button.hover()
diff --git a/examples/sites/demos/pc/app/popover/transition.spec.js b/examples/sites/demos/pc/app/popover/transition.spec.js
index d1fabdf8f..4819e4501 100644
--- a/examples/sites/demos/pc/app/popover/transition.spec.js
+++ b/examples/sites/demos/pc/app/popover/transition.spec.js
@@ -2,16 +2,17 @@ import { test, expect } from '@playwright/test'
test('自定义渐变动画', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#custom-transition')
+ await page.goto('popover#transition')
- let button = page.getByRole('button', { name: '悬浮看效果' })
- let pop = page.getByRole('tooltip', { name: /这是一段内容/ })
+ let button1 = page.getByRole('button', { name: '默认0.2s隐藏' })
+ let pop1 = page.getByRole('tooltip', { name: /这是一段内容/ })
- await button.nth(0).hover()
- await expect(pop).toHaveClass(/fade-in-linear-enter-active/)
+ await button1.hover()
+ await expect(pop1).toBeVisible()
await page.mouse.move(0, 0)
- await page.waitForTimeout(300)
+ await page.waitForTimeout(50)
+ await expect(pop1).toBeVisible()
- await button.nth(1).hover()
- await expect(pop).not.toHaveClass(/fade-in-linear-enter-active/)
+ await page.waitForTimeout(200)
+ await expect(pop1).toBeHidden
})
diff --git a/examples/sites/demos/pc/app/popover/trigger.spec.js b/examples/sites/demos/pc/app/popover/trigger.spec.js
index e07e21e6c..03ecdf0c6 100644
--- a/examples/sites/demos/pc/app/popover/trigger.spec.js
+++ b/examples/sites/demos/pc/app/popover/trigger.spec.js
@@ -2,16 +2,16 @@ import { test, expect } from '@playwright/test'
test('触发方式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('popover#trigger-mode')
+ await page.goto('popover#trigger')
let button1 = page.getByRole('button', { name: 'hover 激活' })
let button2 = page.getByRole('button', { name: 'click 激活' })
let button3 = page.getByRole('button', { name: 'focus 激活' })
- let button4 = page.getByRole('button', { name: '手动激活' })
+ let button4 = page.getByRole('button', { name: 'manual 激活' })
let pop1 = page.getByRole('tooltip', { name: /hover 激活/ })
let pop2 = page.getByRole('tooltip', { name: /click 激活/ })
let pop3 = page.getByRole('tooltip', { name: /focus 激活/ })
- let pop4 = page.getByRole('tooltip', { name: /手动激活/ })
+ let pop4 = page.getByRole('tooltip', { name: /manual 激活/ })
await button1.hover()
await expect(pop1).toBeVisible()
@@ -21,9 +21,9 @@ test('触发方式', async ({ page }) => {
await expect(pop2).toBeVisible()
await page.waitForTimeout(100)
- await page.keyboard.press('Tab')
- await expect(pop3).toBeVisible()
- await page.waitForTimeout(100)
+ // await page.keyboard.press('Tab')
+ // await expect(pop3).toBeVisible()
+ // await page.waitForTimeout(100)
await button4.click()
await expect(pop4).toBeVisible()
diff --git a/examples/sites/demos/pc/app/popover/webdoc/popover.js b/examples/sites/demos/pc/app/popover/webdoc/popover.js
index baa21b19a..2391cd3cc 100644
--- a/examples/sites/demos/pc/app/popover/webdoc/popover.js
+++ b/examples/sites/demos/pc/app/popover/webdoc/popover.js
@@ -133,20 +133,21 @@ export default {
},
'codeFiles': ['popper-options.vue']
},
- {
- 'demoId': 'dynamic-reference',
- 'name': { 'zh-CN': '动态触发源', 'en-US': 'Pop-up Options' },
- 'desc': {
- 'zh-CN': `
- 当组件不传入reference
插槽时,弹出框由于没有触发源而无法触发显示。
- 通过 reference
属性,可以动态传入一个Dom元素作为动态触发源,之后调用doShow() \ doClose()
,来控制弹出框显示与隐藏。
-
Popover
组件实例,提升了列表时的性能。popper-options
command to configure the advanced pop-up options. For details, see the IPopperOption description at the bottom'
- },
- 'codeFiles': ['dynamic-reference.vue']
- },
+ // 暂时屏蔽
+ // {
+ // 'demoId': 'dynamic-reference',
+ // 'name': { 'zh-CN': '动态触发源', 'en-US': 'Pop-up Options' },
+ // 'desc': {
+ // 'zh-CN': `
+ // 当组件不传入reference
插槽时,弹出框由于没有触发源而无法触发显示。reference
属性,可以动态传入一个Dom元素作为动态触发源,之后调用doShow() \ doClose()
,来控制弹出框显示与隐藏。
+ // Popover
组件实例,提升了列表时的性能。popper-options
command to configure the advanced pop-up options. For details, see the IPopperOption description at the bottom'
+ // },
+ // 'codeFiles': ['dynamic-reference.vue']
+ // },
{
'demoId': 'events',
'name': { 'zh-CN': '事件', 'en-US': 'Event' },
diff --git a/examples/sites/demos/pc/app/tooltip/basic-usage.spec.js b/examples/sites/demos/pc/app/tooltip/basic-usage.spec.js
index bba842799..a6aeab04f 100644
--- a/examples/sites/demos/pc/app/tooltip/basic-usage.spec.js
+++ b/examples/sites/demos/pc/app/tooltip/basic-usage.spec.js
@@ -7,17 +7,13 @@ test('测试Tooltip的是否能出现', async ({ page }) => {
let button = page.getByRole('button', { name: '上左' })
let tooltip = page.getByRole('tooltip', { name: 'Top Left 提示文字' })
- await expect(button).toBeVisible()
await button.hover()
+ await page.waitForTimeout(100)
await expect(tooltip).toBeVisible()
-})
-test('测试Tooltip的位置是否正确', async ({ page }) => {
- page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('tooltip#basic-usage')
-
- let button = page.getByRole('button', { name: '上右' })
- let tooltip = page.getByRole('tooltip', { name: 'Top Right 提示文字' })
+ // 测试Tooltip的位置是否正确
+ button = page.getByRole('button', { name: '上右' })
+ tooltip = page.getByRole('tooltip', { name: 'Top Right 提示文字' })
await button.hover()
let buttonBox = await button.boundingBox()
diff --git a/examples/sites/demos/pc/app/tooltip/content.spec.js b/examples/sites/demos/pc/app/tooltip/content.spec.js
index 30423f341..6e45e31b0 100644
--- a/examples/sites/demos/pc/app/tooltip/content.spec.js
+++ b/examples/sites/demos/pc/app/tooltip/content.spec.js
@@ -2,18 +2,11 @@ import { test, expect } from '@playwright/test'
test('测试插槽', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('tooltip#tooltip-content')
+ await page.goto('tooltip#content')
- const button1 = page.getByRole('button', { name: '插槽的使用' })
const button2 = page.getByRole('button', { name: '校验错误' })
- const tooltip1 = page.getByText('通过 slot = "content" 自定义提示内容')
const tooltip2 = page.getByText('该网段不可用!可用网段:163')
- await button1.hover()
- await expect(tooltip1).toBeVisible
-
- await page.waitForTimeout(300)
-
await button2.hover()
await expect(tooltip2).toBeVisible()
})
diff --git a/examples/sites/demos/pc/app/tooltip/control.spec.js b/examples/sites/demos/pc/app/tooltip/control.spec.js
index 66a5448a9..f0b541ecd 100644
--- a/examples/sites/demos/pc/app/tooltip/control.spec.js
+++ b/examples/sites/demos/pc/app/tooltip/control.spec.js
@@ -2,16 +2,20 @@ import { test, expect } from '@playwright/test'
test('测试手动控制tooltip', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
- await page.goto('tooltip#manual-control-tip')
+ await page.goto('tooltip#control')
- const button = page.getByRole('button', { name: '手动控制tooltip的显示和隐藏' })
- const tooltip = page.getByRole('tooltip', { name: '手动控制模式', includeHidden: true })
+ const preview = page.locator('.pc-demo-container')
+ const visibleSwitch = preview.locator('.tiny-switch').nth(0)
+ const manualSwitch = preview.locator('.tiny-switch').nth(1)
+ const disableSwitch = preview.locator('.tiny-switch').nth(2)
- await button.click()
- await expect(tooltip).toBeVisible()
+ const pop1 = page.getByText('智能提示的提示内容')
- await page.waitForTimeout(300)
+ await preview.getByText('内容不超长').hover()
+ await expect(pop1).toBeVisible()
+ await page.waitForTimeout(50)
- await button.click()
- await expect(tooltip).toBeHidden()
+ await visibleSwitch.click()
+ await preview.getByText('内容不超长').hover()
+ await expect(pop1).toBeHidden()
})
diff --git a/examples/sites/demos/pc/app/tooltip/custom-popper-composition-api.vue b/examples/sites/demos/pc/app/tooltip/custom-popper-composition-api.vue
index d57e19811..8358db08e 100644
--- a/examples/sites/demos/pc/app/tooltip/custom-popper-composition-api.vue
+++ b/examples/sites/demos/pc/app/tooltip/custom-popper-composition-api.vue
@@ -31,7 +31,7 @@
popper-class="popper1"
:key="key"
>
-