Skip to content

Commit a5c621f

Browse files
committed
test(color-picker, color-select-panel): format e2e test
1 parent 74f655d commit a5c621f

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

examples/sites/demos/pc/app/color-picker/format.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import { test, expect } from '@playwright/test'
22

33
test('rgb时应该为rgb(xx,xx,xx)', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
45
await page.goto('color-picker#format')
56
// 这个示例默认是rgb, 不需要手动修改
67
// FIXME
78
await expect(page.locator('#format')).toContainText('rgb')
89
})
910

1011
test('hex时应该为#xxx', async ({ page }) => {
12+
page.on('pageerror', (exception) => expect(exception).toBeNull())
1113
await page.goto('color-picker#format')
1214
await page.getByRole('textbox', { name: '请选择' }).click()
1315
await page.locator('li').filter({ hasText: 'Hex' }).click()
1416
await expect(page.locator('#format')).toContainText('#66CCFF')
1517
})
1618

1719
test('hsl时应该为hsl(xxx,xxx,xxx)', async ({ page }) => {
20+
page.on('pageerror', (exception) => expect(exception).toBeNull())
1821
await page.goto('color-picker#format')
1922
await page.getByRole('textbox', { name: '请选择' }).click()
2023
await page.locator('li').filter({ hasText: 'hsl' }).click()
2124
await expect(page.locator('#format')).toContainText('颜色值: hsl(199.99999999999997, 100%, 70%)')
2225
})
2326

2427
test('hsv时候应该为hsv(xx,xx,xx)', async ({ page }) => {
28+
page.on('pageerror', (exception) => expect(exception).toBeNull())
2529
await page.goto('color-picker#format')
2630
await page.getByRole('textbox', { name: '请选择' }).click()
2731
await page.getByRole('list').getByText('hsv').click()

examples/sites/demos/pc/app/color-select-panel/format-composition-api.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212
:visible="visible"
1313
@confirm="onConfirm"
1414
@cancel="onCancel"
15-
:predefine="predefine"
1615
:format="value"
1716
/>
1817
</div>
1918
</div>
2019
</template>
2120

2221
<script setup lang="ts">
23-
import { TinySelect, TinyOption } from '@opentiny/vue'
22+
import { TinySelect, TinyOption, TinyColorSelectPanel, TinyButton } from '@opentiny/vue'
2423
import { ref } from 'vue'
2524
26-
const color = ref('#66ccff')
25+
const color = ref('rgb(102,204,255)')
2726
const visible = ref(false)
28-
const predefine = ref(new Array(8).fill(0).map(() => this.randomHex()))
2927
const options = ref([
3028
{ value: 'hex', label: 'Hex' },
3129
{ value: 'rgb', label: 'rgb' },
@@ -44,4 +42,7 @@ const onConfirm = () => {
4442
const onCancel = () => {
4543
hidden()
4644
}
45+
const changeVisible = () => {
46+
visible.value = !visible.value
47+
}
4748
</script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { test, expect } from '@playwright/test'
2+
3+
test('rgb时应该为rgb(xx,xx,xx)', async ({ page }) => {
4+
page.on('pageerror', (exception) => expect(exception).toBeNull())
5+
await page.goto('color-select-panel#format')
6+
// 这个示例默认是rgb, 不需要手动修改
7+
// FIXME
8+
await expect(page.locator('#format')).toContainText('颜色值: rgb(102,204,255)')
9+
})
10+
11+
test('hex时应该为#xxx', async ({ page }) => {
12+
page.on('pageerror', (exception) => expect(exception).toBeNull())
13+
await page.goto('color-select-panel#format')
14+
await page.getByRole('textbox', { name: '请选择' }).click()
15+
await page.getByText('Hex', { exact: true }).click()
16+
await expect(page.locator('#format')).toContainText('颜色值: #66CCFF')
17+
})
18+
19+
test('hsl时应该为hsl(xxx,xxx,xxx)', async ({ page }) => {
20+
page.on('pageerror', (exception) => expect(exception).toBeNull())
21+
await page.goto('color-select-panel#format')
22+
await page.getByRole('textbox', { name: '请选择' }).click()
23+
await page.getByRole('list').getByText('hsl').click()
24+
await expect(page.locator('#format')).toContainText('颜色值: hsl(199.99999999999997, 100%, 70%)')
25+
})
26+
27+
test('hsv时候应该为hsv(xx,xx,xx)', async ({ page }) => {
28+
page.on('pageerror', (exception) => expect(exception).toBeNull())
29+
await page.goto('color-select-panel#format')
30+
await page.getByRole('textbox', { name: '请选择' }).click()
31+
await page.getByRole('list').getByText('hsv').click()
32+
await expect(page.locator('#format')).toContainText('颜色值: hsv(199.99999999999997, 60%, 100%)')
33+
})

examples/sites/demos/pc/app/color-select-panel/format.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
:visible="visible"
1313
@confirm="onConfirm"
1414
@cancel="onCancel"
15-
:predefine="predefine"
1615
:format="value"
1716
/>
1817
</div>
@@ -31,7 +30,7 @@ export default {
3130
},
3231
data() {
3332
return {
34-
color: '#66ccff',
33+
color: 'rgb(102,204,255)',
3534
visible: false,
3635
predefine: new Array(8).fill(0).map(() => this.randomHex()),
3736
options: [
@@ -63,12 +62,6 @@ export default {
6362
.toString(16)
6463
.padEnd(6, '0')
6564
)
66-
},
67-
addPredefineColor() {
68-
this.predefine.push(this.randomHex())
69-
},
70-
popPredefineColor() {
71-
this.predefine.pop()
7265
}
7366
}
7467
}

0 commit comments

Comments
 (0)