tiny-vue_version0/examples/sites/demos/pc/app/fullscreen/example-api.spec.ts

38 lines
1.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test'
test('函数式使用', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('fullscreen#example-api')
const fullBtn = page.getByRole('button', { name: 'Request Fullscreen' })
const exitFullBtn = page.getByRole('button', { name: 'Exit Fullscreen' })
const smallImg = page.locator('.tiny-fullscreen-wrapper img').nth(0)
const bigImg = page.locator('.tiny-fullscreen-wrapper img').nth(1)
// 初始化完成,默认非全屏模式
await expect(fullBtn).toBeVisible()
await expect(exitFullBtn).toHaveCount(0)
await expect(smallImg).not.toHaveCSS('display', 'none')
await expect(bigImg).toHaveCSS('display', 'none')
const document1 = await page.evaluate('document.fullscreenElement')
await expect(document1).toBe(null)
// 点击Request Fullscreen按钮图片全屏展示
await fullBtn.click()
await expect(smallImg).not.toHaveCSS('display', 'none')
await expect(bigImg).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区别暂未测试
})