Skip to content

Commit f7a615d

Browse files
fix(e2e): fix e2e test of qrcode (#3675)
* fix(loading): 修复e2e报错问题 * fix(e2e): fix e2e test --------- Co-authored-by: chenxi <2465950588@qq.com>
1 parent c264e65 commit f7a615d

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

examples/sites/demos/pc/app/locales/custom-service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('locales-custom-service', async ({ page }) => {
88
const reference = demo.locator('.reference-wrapper')
99
const popper = page.locator('.tiny-locales__popper')
1010

11-
await expect(reference).toHaveText('zh_CN')
11+
await expect(reference).toHaveText('中文')
1212
await expect(popper).toBeHidden()
1313
await reference.hover()
1414
await page.waitForTimeout(200)

examples/sites/demos/pc/app/qr-code/style.spec.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ test('自定义样式', async ({ page }) => {
44
page.on('pageerror', (exception) => expect(exception).toBeNull())
55
await page.goto('qr-code#style')
66

7-
const canvas = page.locator('.tiny-qr-code canvas')
7+
const demo = page.locator('#style')
8+
const wrapper = demo.locator('.tiny-qr-code')
9+
const canvas = demo.locator('.tiny-qr-code canvas')
810
await expect(canvas).toBeVisible()
911

1012
const backgroundColor0 = await canvas.evaluate(
@@ -18,23 +20,7 @@ test('自定义样式', async ({ page }) => {
1820
)
1921

2022
expect(backgroundColor0 === '#1677ff').toBeTruthy()
21-
await page.locator('.tiny-color-picker__inner').click()
22-
await page.locator('.black').click()
23-
await page.locator('.tiny-color-select-panel__inner__hue-select').click()
24-
await page.getByRole('button', { name: '选择' }).click()
25-
const backgroundColor1 = await page.locator('.tiny-color-picker__inner').evaluate((el) => {
26-
return window.getComputedStyle(el).backgroundColor
27-
})
2823

29-
const backgroundColor2 = await canvas.evaluate(
30-
(el: any, { x, y }) => {
31-
const ctx = el.getContext('2d')
32-
const pixel = ctx.getImageData(x, y, 1, 1).data
33-
34-
return `rgb(${pixel[0]}, ${pixel[1]}, ${pixel[2]})`
35-
},
36-
{ x: 1, y: 1 }
37-
)
38-
39-
expect(backgroundColor1 === backgroundColor2).toBeTruthy()
24+
const box = await wrapper.boundingBox()
25+
expect(box?.width).toEqual(250)
4026
})

0 commit comments

Comments
 (0)