Skip to content

Commit

Permalink
test(calendar-view): Add calendar-view e2e UI test (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youyou-smiles authored Sep 26, 2024
1 parent 5033dcb commit 08e60e4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/calendar-view/xdesign.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect, test } from '@playwright/test'

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

// hover时截图
const line = demo.getByText('前端周会2', { exact: true })
await line.hover()
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('line-hover.png')

})

test('设置工作日或节假日--UI截图', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('calendar-view#set-working-day')
const demo = page.locator('#set-working-day .pc-demo')
await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('set-working-day.png')

const btn1 = demo.getByRole('button', { name: '工作日' })
const btn2 = demo.getByRole('button', { name: '休息日' })
const btn3 = demo.getByRole('button', { name: '节假日' })
const date1 = demo.locator('li').filter({ hasText: '8' }).first()
const date2 = demo.locator('li').filter({ hasText: '9' }).first()
const date3 = demo.locator('li').filter({ hasText: '10' }).first()

await date1.click()
await btn1.click()
await date2.click()
await btn2.click()
await date3.click()
await btn3.click()

await expect(demo).toBeInViewport()
await expect(demo).toHaveScreenshot('right-hover.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.

0 comments on commit 08e60e4

Please sign in to comment.