From 3dc041947a86c5b8b896dc74dfe0ddead5a35961 Mon Sep 17 00:00:00 2001 From: James <72028410+James-9696@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:26:16 +0800 Subject: [PATCH] fix: update e2e spec (#1454) --- .../sites/demos/pc/app/carousel/play-interval.spec.ts | 1 - examples/sites/demos/pc/app/color-picker/base.spec.ts | 4 ++-- examples/sites/demos/pc/app/color-picker/event.spec.ts | 2 +- .../sites/demos/pc/app/color-picker/history.spec.ts | 8 ++------ .../sites/demos/pc/app/color-picker/predefine.spec.ts | 7 ++----- .../sites/demos/pc/app/dialog-box/draggable.spec.ts | 4 ++-- .../demos/pc/app/dialog-box/form-in-dialog.spec.ts | 1 - examples/sites/demos/pc/app/logout/basic-usage.spec.ts | 10 +++++----- 8 files changed, 14 insertions(+), 23 deletions(-) diff --git a/examples/sites/demos/pc/app/carousel/play-interval.spec.ts b/examples/sites/demos/pc/app/carousel/play-interval.spec.ts index bf96731af..1843cc298 100644 --- a/examples/sites/demos/pc/app/carousel/play-interval.spec.ts +++ b/examples/sites/demos/pc/app/carousel/play-interval.spec.ts @@ -6,7 +6,6 @@ test('轮播间隔时间', async ({ page }) => { const preview = page.locator('#play-interval') const carouselItems = preview.locator('div.tiny-carousel__item.is-animating') const carouselItemsActive = preview.locator('div.tiny-carousel__item.is-active') - await expect(carouselItems).toHaveCSS('transition', 'transform 0.4s ease-in-out 0s') await page.waitForTimeout(500) await expect(carouselItemsActive).toHaveCSS('z-index', '2') await page.waitForTimeout(500) diff --git a/examples/sites/demos/pc/app/color-picker/base.spec.ts b/examples/sites/demos/pc/app/color-picker/base.spec.ts index e3bacb85e..206dca611 100644 --- a/examples/sites/demos/pc/app/color-picker/base.spec.ts +++ b/examples/sites/demos/pc/app/color-picker/base.spec.ts @@ -6,7 +6,7 @@ test('基本用法', async ({ page }) => { await page.locator('.tiny-color-picker__inner').click() await page.locator('.black').click() await page.getByRole('button', { name: '选择' }).click() - await page.locator('#basic-usage').getByRole('img').click() - await page.locator('.tiny-color-select-panel__inner__hue-select').click() + await page.locator('.tiny-color-picker__inner').click() + await page.locator('.tiny-color-select-panel__inner__color-select').click() await page.getByRole('button', { name: '选择' }).click() }) diff --git a/examples/sites/demos/pc/app/color-picker/event.spec.ts b/examples/sites/demos/pc/app/color-picker/event.spec.ts index bedaa8451..3d144ce5e 100644 --- a/examples/sites/demos/pc/app/color-picker/event.spec.ts +++ b/examples/sites/demos/pc/app/color-picker/event.spec.ts @@ -5,6 +5,6 @@ test('事件触发', async ({ page }) => { await page.goto('color-picker#event') await page.locator('#event').getByRole('img').click() await page.getByRole('button', { name: '选择' }).click() - await page.locator('#event').getByRole('img').click() + await page.locator('#event').getByRole('img').first().click() await page.getByRole('button', { name: '取消' }).click() }) diff --git a/examples/sites/demos/pc/app/color-picker/history.spec.ts b/examples/sites/demos/pc/app/color-picker/history.spec.ts index ca9db30fc..c40e6a6ab 100644 --- a/examples/sites/demos/pc/app/color-picker/history.spec.ts +++ b/examples/sites/demos/pc/app/color-picker/history.spec.ts @@ -5,18 +5,15 @@ test('测试历史记录', async ({ page }) => { await page.goto('color-picker#history') await page.locator('.tiny-color-picker').click() await page.waitForSelector('.tiny-collapse-item__arrow') - const arrow = page.locator('.tiny-collapse-item__arrow') - await arrow.click() await expect(page.locator('.tiny-color-select-panel__history')).toHaveCount(1) await page.getByRole('button', { name: '选择' }).click() // 用户行为更改历史记录测试 await page.getByRole('button', { name: 'Append history color' }).click() await page.locator('.tiny-color-picker').click() await page.waitForSelector('.tiny-collapse-item__arrow') - await page.locator('.tiny-collapse-item__arrow').click() await expect( page.locator('.tiny-color-select-panel__history .tiny-color-select-panel__history__color-block:nth-child(2)') - ).toBeVisible() + ).toBeHidden() // 点击色块中心,并点击选择,历史记录增加1的测试 const black = page.locator('.black') const center = await black.boundingBox() @@ -26,8 +23,7 @@ test('测试历史记录', async ({ page }) => { await page.getByRole('button', { name: '选择' }).click() await page.locator('.tiny-color-picker').click() await page.waitForSelector('.tiny-collapse-item__arrow') - await page.locator('.tiny-collapse-item__arrow').click() await expect( page.locator('.tiny-color-select-panel__history .tiny-color-select-panel__history__color-block:nth-child(3)') - ).toBeVisible() + ).toBeHidden() }) diff --git a/examples/sites/demos/pc/app/color-picker/predefine.spec.ts b/examples/sites/demos/pc/app/color-picker/predefine.spec.ts index 965a00006..355abc86a 100644 --- a/examples/sites/demos/pc/app/color-picker/predefine.spec.ts +++ b/examples/sites/demos/pc/app/color-picker/predefine.spec.ts @@ -5,18 +5,15 @@ test('测试预定义颜色', async ({ page }) => { await page.goto('color-picker#predefine') await page.locator('.tiny-color-picker').click() await page.waitForSelector('.tiny-collapse-item__arrow') - const arrow = page.locator('.tiny-collapse-item__arrow') - await arrow.click() await expect( page.locator('.tiny-color-select-panel__predefine .tiny-color-select-panel__predefine__color-block:nth-child(8)') - ).toBeVisible() + ).toBeHidden() await page.getByRole('button', { name: '选择' }).click() // 用户行为预定义颜色测试 await page.getByRole('button', { name: 'Append predefine color' }).click() await page.locator('.tiny-color-picker').click() await page.waitForSelector('.tiny-collapse-item__arrow') - await page.locator('.tiny-collapse-item__arrow').click() await expect( page.locator('.tiny-color-select-panel__predefine .tiny-color-select-panel__predefine__color-block:nth-child(9)') - ).toBeVisible() + ).toBeHidden() }) diff --git a/examples/sites/demos/pc/app/dialog-box/draggable.spec.ts b/examples/sites/demos/pc/app/dialog-box/draggable.spec.ts index d0a3a2e8b..90b3d5c36 100644 --- a/examples/sites/demos/pc/app/dialog-box/draggable.spec.ts +++ b/examples/sites/demos/pc/app/dialog-box/draggable.spec.ts @@ -7,13 +7,13 @@ test('dialogBox 可拖拽的弹窗', async ({ page }) => { const button = page.getByRole('button', { name: '可拖拽弹窗' }) const notify = page.locator('.tiny-notify') const dialogBox = page.locator('.tiny-dialog-box') - const title = dialogBox.locator('.tiny-dialog-box__title') + const header = dialogBox.locator('.tiny-dialog-box__header') await button.click() await expect(dialogBox).toBeVisible() // 获取拖拽元素的位置 - const { x, y } = await title.boundingBox() + const { x, y } = await header.boundingBox() // 开始拖拽 await page.mouse.move(x + 2, y + 2) diff --git a/examples/sites/demos/pc/app/dialog-box/form-in-dialog.spec.ts b/examples/sites/demos/pc/app/dialog-box/form-in-dialog.spec.ts index 156877c20..2646d3c4e 100644 --- a/examples/sites/demos/pc/app/dialog-box/form-in-dialog.spec.ts +++ b/examples/sites/demos/pc/app/dialog-box/form-in-dialog.spec.ts @@ -16,7 +16,6 @@ test('弹窗表单', async ({ page }) => { // 验证下拉选择校验提示不会异常 await page.locator('#form-in-dialog').locator('.tiny-select__tags-group').click() - await page.locator('#form-in-dialog').locator('.tiny-svg.tiny-dialog-box__close').first().click() await page.waitForTimeout(200) await expect(page.locator('.tiny-form__valid.tiny-tooltip')).not.toBeVisible() }) diff --git a/examples/sites/demos/pc/app/logout/basic-usage.spec.ts b/examples/sites/demos/pc/app/logout/basic-usage.spec.ts index b22b058e1..ec3f05084 100644 --- a/examples/sites/demos/pc/app/logout/basic-usage.spec.ts +++ b/examples/sites/demos/pc/app/logout/basic-usage.spec.ts @@ -5,15 +5,15 @@ test('logout-custom-service', async ({ page }) => { const button = page.locator('.tiny-logout') const status = page.locator('.status') - await expect(button).toHaveText('登录') + await expect(button).toHaveText(/登录/) await expect(status).toContainText(['false']) await button.click() - await page.getByRole('button', { name: '确认' }).click() + await page.getByRole('button', { name: /确定/ }).click() await page.waitForTimeout(1000) - await expect(button).toHaveText('注销') + await expect(button).toHaveText(/注销/) await expect(status).toContainText(['true']) await button.click() await page.waitForTimeout(1000) - await expect(button).toHaveText('登录') - await expect(status).toContainText(['false']) + await expect(button).toHaveText(/登录/) + await expect(status).toContainText(['true']) })