test(qr-code):[qr-code] update qr-code E2E test (#1143)

This commit is contained in:
wuyiping0628 2023-12-15 10:14:12 +08:00 committed by GitHub
parent 6b8f1ee381
commit c58b4a350d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 10 deletions

View File

@ -0,0 +1,9 @@
import { test, expect } from '@playwright/test'
test('基本用法', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('qr-code#basic-usage')
const canvas = page.locator('.tiny-qr-code-container canvas')
await expect(canvas).toBeVisible()
})

View File

@ -0,0 +1,11 @@
import { test, expect } from '@playwright/test'
test('自定义icon', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('qr-code#icon')
const canvas = page.locator('.tiny-qr-code-container canvas')
const canvasImg = page.locator('.tiny-qr-code-container .mask-icon img')
await expect(canvas).toBeVisible()
await expect(canvasImg).toBeVisible()
})

View File

@ -0,0 +1,15 @@
import { test, expect } from '@playwright/test'
test('二维码纠错等级', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('qr-code#level')
const canvas = page.locator('.tiny-qr-code-container canvas')
await expect(canvas).toBeVisible()
const button = page.locator('.tiny-radio-button--small')
await expect(button.nth(0).locator('.tiny-radio-button__inner')).toHaveText('Low')
await expect(button.nth(1).locator('.tiny-radio-button__inner')).toHaveText('Medium')
await expect(button.nth(2).locator('.tiny-radio-button__inner')).toHaveText('Quality')
await expect(button.nth(3).locator('.tiny-radio-button__inner')).toHaveText('High')
})

View File

@ -0,0 +1,9 @@
import { test, expect } from '@playwright/test'
test('自定义样式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('qr-code#style')
const canvas = page.locator('.tiny-qr-code-container canvas')
await expect(canvas).toBeVisible()
})

View File

@ -40,7 +40,8 @@ export default {
'props': [ 'props': [
{ {
'name': 'value', 'name': 'value',
'type': 'String', 'type': 'string',
'defaultValue': '',
'desc': { 'desc': {
'zh-CN': '扫描后的文本', 'zh-CN': '扫描后的文本',
'en-US': 'scanned text' 'en-US': 'scanned text'
@ -49,7 +50,7 @@ export default {
}, },
{ {
'name': 'size', 'name': 'size',
'type': 'Number', 'type': 'number',
'defaultValue': '200', 'defaultValue': '200',
'desc': { 'desc': {
'zh-CN': '二维码大小', 'zh-CN': '二维码大小',
@ -59,7 +60,7 @@ export default {
}, },
{ {
'name': 'color', 'name': 'color',
'type': 'String', 'type': 'string',
'defaultValue': '#000', 'defaultValue': '#000',
'desc': { 'desc': {
'zh-CN': '二维码颜色, 仅支持十六进制', 'zh-CN': '二维码颜色, 仅支持十六进制',
@ -69,17 +70,18 @@ export default {
}, },
{ {
'name': 'bordered', 'name': 'bordered',
'type': 'Boolean', 'type': 'boolean',
'defaultValue': 'true', 'defaultValue': 'true',
'desc': { 'desc': {
'zh-CN': '是否有边框', 'zh-CN': '是否有边框',
'en-US': 'Whether has border style' 'en-US': 'Whether has border style'
}, },
'demoId': 'basic-usage' 'demoId': ''
}, },
{ {
'name': 'icon', 'name': 'icon',
'type': 'String', 'type': 'string',
'defaultValue': '',
'desc': { 'desc': {
'zh-CN': '二维码中图片的地址(目前只支持图片地址)', 'zh-CN': '二维码中图片的地址(目前只支持图片地址)',
'en-US': 'include image url (only image link are supported)' 'en-US': 'include image url (only image link are supported)'
@ -87,8 +89,8 @@ export default {
'demoId': 'icon' 'demoId': 'icon'
}, },
{ {
'name': 'iconSize', 'name': 'icon-size',
'type': 'Number', 'type': 'number',
'defaultValue': '50', 'defaultValue': '50',
'desc': { 'desc': {
'zh-CN': '二维码中图片的大小icon 覆盖面积不能超过 30% 否则影响扫码', 'zh-CN': '二维码中图片的大小icon 覆盖面积不能超过 30% 否则影响扫码',
@ -98,10 +100,10 @@ export default {
}, },
{ {
'name': 'level', 'name': 'level',
'type': "'Low' | 'Medium' | 'Quality' | 'High'", 'type': 'string',
'defaultValue': 'Medium', 'defaultValue': 'Medium',
'desc': { 'desc': {
'zh-CN': '二维码纠错等级', 'zh-CN': "二维码纠错等级, 可选 'Low' | 'Medium' | 'Quality' | 'High'",
'en-US': 'Error Code Level' 'en-US': 'Error Code Level'
}, },
'demoId': 'level' 'demoId': 'level'