Skip to content

Commit

Permalink
test(e2e): add radio UI e2e test (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcr authored Sep 20, 2024
1 parent f825160 commit a426d65
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/radio/xdesign.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect, test } from '@playwright/test'

test.describe('radio组件xdesign规范', () => {
test('默认--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('radio#basic-usage')
const demo = page.locator('#basic-usage .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('basic-usage.png')

// hover时截图
await page.getByRole('radio', { name: '选项二' }).hover()
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('hover.png')
})

test('单选框组--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('radio#group-options')
const demo = page.locator('#group-options .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('radio-group.png')

// 清除图标hover截图
await page.locator('label').filter({ hasText: '公交' }).hover()
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('group-hover.png')

await page.locator('label').filter({ hasText: '地铁' }).hover()
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('checked-hover.png')
})

test('禁用--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('radio#dynamic-disable')
const demo = page.locator('#dynamic-disable .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('disabled.png')
})

test('垂直布局--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('radio#vertical')
const demo = page.locator('#vertical .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('vertical.png')
})

test('尺寸--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('radio#radio-size')
const demo = page.locator('#radio-size .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('size.png')
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a426d65

Please sign in to comment.