From c1a484705ba8b522f5c7be61728541ef1bd4ee42 Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Mon, 21 Oct 2024 15:49:30 +0800 Subject: [PATCH 1/3] test(e2e): [dialog-box] update dialogbox e2e test --- .../pc/app/dialog-box/destroy-on-close.spec.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts index 6df63efb43..6bf8b5deb7 100644 --- a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts +++ b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts @@ -4,13 +4,14 @@ test('关闭时销毁主体元素', async ({ page }) => { page.on('pageerror', (exception) => expect(exception).toBeNull()) const dialogBox = page.locator('.tiny-dialog-box') await page.goto('dialog-box#destroy-on-close') - await page.getByRole('button', { name: '打开弹框' }).click() - await page.getByLabel('Close').click() - await page.getByRole('radio', { name: '关闭时不销毁' }).click() - await page.getByRole('button', { name: '打开弹框' }).click() - await page.getByRole('button', { name: '确定' }).click() - await page.getByRole('radio', { name: '关闭时销毁' }).click() - await page.getByRole('button', { name: '打开弹框' }).click() - await page.getByRole('button', { name: '确定' }).click() + const demo = page.locator('#destroy-on-close') + await demo.getByRole('button', { name: '打开弹框' }).click() + await demo.getByLabel('Close').click() + await demo.locator('label').filter({ hasText: '关闭时不销毁' }).click() + await demo.getByRole('button', { name: '打开弹框' }).click() + await demo.getByRole('button', { name: '确定' }).click() + await demo.locator('label').filter({ hasText: '关闭时销毁' }).click() + await demo.getByRole('button', { name: '打开弹框' }).click() + await demo.getByRole('button', { name: '确定' }).click() await expect(dialogBox).toBeHidden() }) From 000f2b8b8b3ee3b31fc72f0e03c66dde44791c4a Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Mon, 21 Oct 2024 19:19:31 +0800 Subject: [PATCH 2/3] test(e2e): update some components e2e test --- .../demos/pc/app/base-select/automatic-dropdown.spec.ts | 2 +- .../demos/pc/app/bulletin-board/active-name.spec.ts | 2 +- examples/sites/demos/pc/app/bulletin-board/base.spec.ts | 6 +++--- .../demos/pc/app/cascader-panel/basic-usage.spec.ts | 2 +- .../sites/demos/pc/app/company/custom-service.spec.ts | 4 ---- examples/sites/demos/pc/app/config-provider/tag.spec.ts | 2 +- .../sites/demos/pc/app/country/custom-service.spec.js | 6 ------ .../demos/pc/app/dialog-box/destroy-on-close.spec.ts | 4 ++-- .../sites/demos/pc/app/fullscreen/example-api.spec.ts | 9 ++------- .../sites/demos/pc/app/locales/custom-service.spec.ts | 1 - 10 files changed, 11 insertions(+), 27 deletions(-) diff --git a/examples/sites/demos/pc/app/base-select/automatic-dropdown.spec.ts b/examples/sites/demos/pc/app/base-select/automatic-dropdown.spec.ts index 914f68dc25..3fc02a2378 100644 --- a/examples/sites/demos/pc/app/base-select/automatic-dropdown.spec.ts +++ b/examples/sites/demos/pc/app/base-select/automatic-dropdown.spec.ts @@ -9,7 +9,7 @@ test('不可搜索时,获取焦点不下拉', async ({ page }) => { await wrap.getByRole('button').first().click() // 聚焦高亮 - await expect(input).toHaveCSS('border-color', 'rgb(94, 124, 224)') + await expect(input).toHaveCSS('border-color', 'rgb(25, 25, 25)') // 不下拉 await expect(dropdown).toBeHidden() }) diff --git a/examples/sites/demos/pc/app/bulletin-board/active-name.spec.ts b/examples/sites/demos/pc/app/bulletin-board/active-name.spec.ts index d4f569dc9e..c3ed2ef549 100644 --- a/examples/sites/demos/pc/app/bulletin-board/active-name.spec.ts +++ b/examples/sites/demos/pc/app/bulletin-board/active-name.spec.ts @@ -10,7 +10,7 @@ test('BulletinBoard 默认激活的选项卡', async ({ page }) => { // 激活第二项选项卡 await expect(tabTitle.nth(1)).toHaveClass(/is-active/) - await expect(tabTitle.nth(1)).toHaveCSS('color', 'rgb(94, 124, 224)') + await expect(tabTitle.nth(1)).toHaveCSS('color', 'rgb(25, 25, 25)') await expect(tabContent.nth(1)).toHaveClass(/active-item/) await expect(tabContent.nth(1)).toBeVisible() diff --git a/examples/sites/demos/pc/app/bulletin-board/base.spec.ts b/examples/sites/demos/pc/app/bulletin-board/base.spec.ts index bce14cde1a..51f8e7d86c 100644 --- a/examples/sites/demos/pc/app/bulletin-board/base.spec.ts +++ b/examples/sites/demos/pc/app/bulletin-board/base.spec.ts @@ -11,20 +11,20 @@ test('BulletinBoard 基本用法', async ({ page }) => { // 默认激活第一项选项卡 await expect(tabTitle.first()).toHaveClass(/is-active/) await expect(tabTitle.first()).toContainText('TINY 更新日志') - await expect(tabTitle.first()).toHaveCSS('color', 'rgb(94, 124, 224)') + await expect(tabTitle.first()).toHaveCSS('color', 'rgb(25, 25, 25)') await expect(tabContent.first()).toHaveClass(/active-item/) await expect(tabContent.first()).toBeVisible() // 鼠标上放选项标题时,文字变色 for (let i = 0; i < 3; i++) { await tabTitle.nth(i).hover() - await expect(tabTitle.nth(i)).toHaveCSS('color', 'rgb(94, 124, 224)') + await expect(tabTitle.nth(i)).toHaveCSS('color', 'rgb(25, 25, 25)') } // 点击选项标题后,切换展示相应的选项内容 for (let i = 0; i < 3; i++) { await tabTitle.nth(i).click() await expect(tabTitle.nth(i)).toHaveClass(/is-active/) - await expect(tabTitle.nth(i)).toHaveCSS('color', 'rgb(94, 124, 224)') + await expect(tabTitle.nth(i)).toHaveCSS('color', 'rgb(25, 25, 25)') await expect(tabContent.nth(i)).toHaveClass(/active-item/) await expect(tabContent.nth(i)).toBeVisible() } diff --git a/examples/sites/demos/pc/app/cascader-panel/basic-usage.spec.ts b/examples/sites/demos/pc/app/cascader-panel/basic-usage.spec.ts index b8295b7e92..1f1951d9db 100644 --- a/examples/sites/demos/pc/app/cascader-panel/basic-usage.spec.ts +++ b/examples/sites/demos/pc/app/cascader-panel/basic-usage.spec.ts @@ -8,5 +8,5 @@ test('基本用法', async ({ page }) => { await page.getByRole('menuitem', { name: '项目登记' }).click() await expect(page.getByRole('menuitem', { name: '项目登记' })).toHaveClass('tiny-cascader-node is-active') - await expect(page.getByRole('menuitem', { name: '项目登记' })).toHaveCSS('background-color', 'rgb(94, 124, 224)') + await expect(page.getByRole('menuitem', { name: '项目登记' })).toHaveCSS('background-color', 'rgb(245, 245, 245)') }) diff --git a/examples/sites/demos/pc/app/company/custom-service.spec.ts b/examples/sites/demos/pc/app/company/custom-service.spec.ts index 9f402f4420..60ad65df5a 100644 --- a/examples/sites/demos/pc/app/company/custom-service.spec.ts +++ b/examples/sites/demos/pc/app/company/custom-service.spec.ts @@ -23,8 +23,4 @@ test('自定义服务', async ({ page }) => { await expect(modal.nth(1)).toHaveText('change:0001') await expect(input).toHaveValue('公司一') await input.hover() - - // 清空 - await page.locator('.tiny-select .tiny-input__suffix .tiny-svg.icon-close').click() - await expect(input).toHaveValue('') }) diff --git a/examples/sites/demos/pc/app/config-provider/tag.spec.ts b/examples/sites/demos/pc/app/config-provider/tag.spec.ts index 6f3bf1b74a..7eb91f2fef 100644 --- a/examples/sites/demos/pc/app/config-provider/tag.spec.ts +++ b/examples/sites/demos/pc/app/config-provider/tag.spec.ts @@ -9,5 +9,5 @@ test('测试自定义标签', async ({ page }) => { await demo.nth(2).click() await page.waitForTimeout(300) const elements = await page.locator('.tiny-config-provider') - await expect(elements.nth(1)).toHaveCSS('padding', '16px') + await expect(elements.nth(1)).toHaveCSS('padding', '12px') }) diff --git a/examples/sites/demos/pc/app/country/custom-service.spec.js b/examples/sites/demos/pc/app/country/custom-service.spec.js index 7ec8ba3c22..3ff5417675 100644 --- a/examples/sites/demos/pc/app/country/custom-service.spec.js +++ b/examples/sites/demos/pc/app/country/custom-service.spec.js @@ -6,15 +6,9 @@ test('自定义服务', async ({ page }) => { const select = page.locator('.tiny-select') const item = page.getByText('France') - const clear = page.locator('.tiny-select .tiny-svg.icon-close') // 点击选中 await select.click() await item.click() await expect(select.locator('input')).toHaveValue(/France/) await page.waitForTimeout(100) - - // 清除 - await select.hover() - await clear.click() - await expect(select.locator('input')).toHaveValue('') }) diff --git a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts index 6bf8b5deb7..dae40d2b70 100644 --- a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts +++ b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts @@ -9,9 +9,9 @@ test('关闭时销毁主体元素', async ({ page }) => { await demo.getByLabel('Close').click() await demo.locator('label').filter({ hasText: '关闭时不销毁' }).click() await demo.getByRole('button', { name: '打开弹框' }).click() - await demo.getByRole('button', { name: '确定' }).click() + await page.getByRole('button', { name: '确定' }).click() await demo.locator('label').filter({ hasText: '关闭时销毁' }).click() await demo.getByRole('button', { name: '打开弹框' }).click() - await demo.getByRole('button', { name: '确定' }).click() + await page.getByRole('button', { name: '确定' }).click() await expect(dialogBox).toBeHidden() }) diff --git a/examples/sites/demos/pc/app/fullscreen/example-api.spec.ts b/examples/sites/demos/pc/app/fullscreen/example-api.spec.ts index 49de9f5775..671cd36aa4 100644 --- a/examples/sites/demos/pc/app/fullscreen/example-api.spec.ts +++ b/examples/sites/demos/pc/app/fullscreen/example-api.spec.ts @@ -19,19 +19,14 @@ test('函数式使用', async ({ page }) => { // 点击Request Fullscreen按钮,图片全屏展示 await fullBtn.click() - await expect(smallImg).not.toHaveCSS('display', 'none') - await expect(bigImg).toHaveCSS('display', 'none') + await expect(smallImg).toHaveCSS('display', 'none') + await expect(bigImg).not.toHaveCSS('display', 'none') // 选取需要添加样式的元素并设置新的CSS属性 await page.$eval('.tinyui-design-header', (el) => { el.setAttribute('style', 'display: none;') }) - // // 点击Exit Fullscreen按钮,退出全屏展示 - await fullBtn.click() - await expect(smallImg).not.toHaveCSS('display', 'none') - await expect(bigImg).toHaveCSS('display', 'none') - // TINY-TODO: 全屏时,按Esc键退出全屏图片有问题 // TINY-TODO: 因全屏模式下获取不到元素 pageOnly teleport区别暂未测试 }) diff --git a/examples/sites/demos/pc/app/locales/custom-service.spec.ts b/examples/sites/demos/pc/app/locales/custom-service.spec.ts index 83b5ae7d8e..5385406812 100644 --- a/examples/sites/demos/pc/app/locales/custom-service.spec.ts +++ b/examples/sites/demos/pc/app/locales/custom-service.spec.ts @@ -13,5 +13,4 @@ test('locales-custom-service', async ({ page }) => { await reference.hover() await page.waitForTimeout(200) await expect(popper).toBeVisible() - await popper.getByText('enUS').click() }) From 54afc865ce07bf3c465f6cbe0e7f14698062effd Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Mon, 21 Oct 2024 19:36:12 +0800 Subject: [PATCH 3/3] test(e2e): update some components e2e test --- .../demos/pc/app/dialog-box/destroy-on-close.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts index dae40d2b70..f6947cd398 100644 --- a/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts +++ b/examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts @@ -5,13 +5,14 @@ test('关闭时销毁主体元素', async ({ page }) => { const dialogBox = page.locator('.tiny-dialog-box') await page.goto('dialog-box#destroy-on-close') const demo = page.locator('#destroy-on-close') - await demo.getByRole('button', { name: '打开弹框' }).click() - await demo.getByLabel('Close').click() + await demo.locator('label').filter({ hasText: '关闭时不销毁' }).click() await demo.getByRole('button', { name: '打开弹框' }).click() - await page.getByRole('button', { name: '确定' }).click() + await demo.locator('.tiny-dialog-box__footer').getByRole('button', { name: '确定' }).click() + await expect(dialogBox).toBeHidden() + await demo.locator('label').filter({ hasText: '关闭时销毁' }).click() await demo.getByRole('button', { name: '打开弹框' }).click() - await page.getByRole('button', { name: '确定' }).click() - await expect(dialogBox).toBeHidden() + await demo.locator('.tiny-dialog-box__footer').getByRole('button', { name: '确定' }).click() + await expect(dialogBox).toHaveCount(0) })