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(carousel): add ui-test #54

Merged
merged 1 commit into from
Sep 24, 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
72 changes: 72 additions & 0 deletions tests/carousel/xdesign.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { expect, test } from '@playwright/test'

test.describe('carousel组件xdesign规范', () => {
test('基本用法--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#basic-usage')
const demo = page.locator('#basic-usage')
const carousel = demo.locator('.tiny-carousel')
await carousel.getByRole('list').getByRole('button').nth(1).click()
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('basic-usage.png')
})
test('显示左右箭头--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#carousel-arrow-always')
const demo = page.locator('#carousel-arrow-always')
// 按钮常态、悬浮
await demo.locator('.tiny-carousel__arrow').first().click()
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('carousel-arrow-always.png')
})
test('箭头禁用--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#close-loop')
const demo = page.locator('#close-loop')
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('close-loop.png')
})
test('纵向轮播--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#up-down-carousel')
const demo = page.locator('#up-down-carousel')
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('up-down-carousel.png')
})
test('显示标题--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#show-title')
const demo = page.locator('#show-title')
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('show-title.png')
})
test('卡片模式--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#card-mode')
const demo = page.locator('#card-mode')
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('card-mode.png')
})
test('插槽模式--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#card-show')
const demo = page.locator('#card-show')
const carousel = demo.locator('.tiny-carousel')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('card-show.png')
})
test('弹窗模式--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('carousel#dialog-show')
const demo = page.locator('#dialog-show')
await demo.getByRole('button', { name: '弹出轮播' }).click()
const carousel = demo.locator('.tiny-dialog-box')
await expect(carousel).toBeInViewport()
await expect(carousel).toHaveScreenshot('dialog-card.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.