Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): [dialog-box,bulletin-board,cascader-panel,company,config-provider,country,fullscreen] update e2e test #2329

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions examples/sites/demos/pc/app/bulletin-board/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
})
4 changes: 0 additions & 4 deletions examples/sites/demos/pc/app/company/custom-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
})
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/config-provider/tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
6 changes: 0 additions & 6 deletions examples/sites/demos/pc/app/country/custom-service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
})
18 changes: 10 additions & 8 deletions examples/sites/demos/pc/app/dialog-box/destroy-on-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ 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.locator('label').filter({ hasText: '关闭时不销毁' }).click()
await demo.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 demo.locator('.tiny-dialog-box__footer').getByRole('button', { name: '确定' }).click()
await expect(dialogBox).toHaveCount(0)
})
9 changes: 2 additions & 7 deletions examples/sites/demos/pc/app/fullscreen/example-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;')
})

Comment on lines 28 to 29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address TODO comments regarding fullscreen issues.

There are two TODO comments at the end of the file indicating known issues with exiting fullscreen mode and element retrieval in fullscreen. These comments suggest that there are unresolved problems with the fullscreen functionality.

Please consider addressing these TODO items:

  1. Investigate and fix the issue with exiting fullscreen mode using the Esc key.
  2. Resolve the problem of not being able to retrieve elements in fullscreen mode.

Would you like assistance in creating GitHub issues to track these problems?

// // 点击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区别暂未测试
})
1 change: 0 additions & 1 deletion examples/sites/demos/pc/app/locales/custom-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Loading