Skip to content

Commit 727c224

Browse files
authored
fix(e2e): fix e2e error caused by select refactor (#3905)
1 parent cc859ab commit 727c224

23 files changed

+59
-62
lines changed

examples/sites/demos/pc/app/amount/custom-service.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ test('自定义服务', async ({ page }) => {
88
await page
99
.locator('div')
1010
.filter({ hasText: /^MZNCNY$/ })
11-
.getByRole('textbox')
11+
.locator('input[type="text"]')
1212
.click()
13-
await page.getByRole('listitem').filter({ hasText: /MZN/ }).locator('div').click()
14-
await page.getByRole('tooltip', { name: '币种 MZN 金额 确定 重置' }).getByRole('textbox').nth(1).click()
15-
await page.getByRole('tooltip', { name: '币种 MZN 金额 确定 重置' }).getByRole('textbox').nth(1).fill('100')
13+
await page.getByLabel('MZN').locator('div').click()
14+
await page.getByRole('tooltip', { name: '币种 MZN 金额 确定 重置' }).getByRole('textbox').click()
15+
await page.getByRole('tooltip', { name: '币种 金额 确定 重置' }).getByRole('textbox').fill('100')
1616
await page.getByRole('button', { name: '确定' }).click()
1717
expect(await demo.locator('.reference-wrapper input').inputValue()).toEqual('$100.00')
1818
})

examples/sites/demos/pc/app/base-select/allow-create.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ test('点击选中', async ({ page }) => {
1616
await input.dispatchEvent('keyup', { KeyboardEvent })
1717

1818
await expect(input).toHaveValue('测试 allow-create')
19-
await dropdown.getByRole('listitem').filter({ hasText: '测试 allow-create' }).click()
19+
await dropdown.getByText('测试 allow-create').click()
2020
await expect(input).toHaveValue('测试 allow-create')
2121

2222
await input.click()
2323
await expect(input).toHaveValue('')
24-
await expect(dropdown.getByRole('listitem').filter({ hasText: '测试 allow-create' })).toHaveClass(/selected/)
24+
await expect(dropdown.getByRole('option').filter({ hasText: '测试 allow-create' })).toHaveClass(/selected/)
2525
})
2626

2727
test('enter 选中', async ({ page }) => {
@@ -46,5 +46,5 @@ test('enter 选中', async ({ page }) => {
4646
await input.click()
4747

4848
await expect(input).toHaveValue('')
49-
await expect(dropdown.getByRole('listitem').filter({ hasText: 'ab' })).toHaveClass(/selected/)
49+
await expect(dropdown.getByRole('option').filter({ hasText: 'ab' })).toHaveClass(/selected/)
5050
})

examples/sites/demos/pc/app/base-select/automatic-dropdown.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ test('可搜索时,获取焦点自动下拉', async ({ page }) => {
2323

2424
await wrap.getByRole('button').nth(1).click()
2525
// 聚焦下拉
26-
await dropdown.getByRole('listitem').filter({ hasText: '上海' }).click()
26+
await dropdown.getByRole('option').filter({ hasText: '上海' }).click()
2727
await expect(input).toHaveValue('上海')
2828
// 验证选中
2929
await input.click()
30-
await expect(page.getByRole('listitem').filter({ hasText: '上海' })).toHaveClass(/selected/)
30+
await expect(page.getByRole('option').filter({ hasText: '上海' })).toHaveClass(/selected/)
3131
})

examples/sites/demos/pc/app/base-select/basic-usage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('基础用法标签式', async ({ page }) => {
1313
await option.filter({ hasText: '天津' }).click()
1414
await expect(input).toHaveValue('天津')
1515
await input.click()
16-
await expect(page.getByRole('listitem').filter({ hasText: '天津' })).toHaveClass(/selected/)
16+
await expect(page.getByRole('option').filter({ hasText: '天津' })).toHaveClass(/selected/)
1717
await option.filter({ hasText: '深圳' }).click()
1818
await expect(input).toHaveValue('深圳')
1919
await input.click()
@@ -36,7 +36,7 @@ test('基础用法配置式', async ({ page }) => {
3636
await option.filter({ hasText: '天津' }).click()
3737
await expect(input).toHaveValue('天津')
3838
await input.click()
39-
await expect(page.getByRole('listitem').filter({ hasText: '天津' })).toHaveClass(/selected/)
39+
await expect(page.getByRole('option').filter({ hasText: '天津' })).toHaveClass(/selected/)
4040
await option.filter({ hasText: '深圳' }).click()
4141
await expect(input).toHaveValue('深圳')
4242
await input.click()

examples/sites/demos/pc/app/base-select/binding-obj.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ test('binding-obj', async ({ page }) => {
1010
const valueLocator = wrap.locator('.value')
1111

1212
await input.click()
13-
await dropdown.getByRole('listitem').filter({ hasText: '重庆' }).click()
13+
await dropdown.getByRole('option').filter({ hasText: '重庆' }).click()
1414
await expect(input).toHaveValue('重庆')
1515
await expect(valueLocator).toHaveText('{ "val": "选项 4", "id": 4 }')
1616

1717
await input.click()
18-
await dropdown.getByRole('listitem').filter({ hasText: '天津' }).click()
18+
await dropdown.getByRole('option').filter({ hasText: '天津' }).click()
1919
await expect(input).toHaveValue('天津')
2020
await expect(valueLocator).toHaveText('{ "val": "选项 3", "id": 3 }')
2121
})

examples/sites/demos/pc/app/base-select/cache-usage.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ test('cache-op', async ({ page }) => {
1010
const cacheValue = wrap.locator('.cache-value')
1111

1212
await input.click()
13-
await dropdown.getByRole('listitem').filter({ hasText: '北京' }).click()
13+
await dropdown.getByRole('option').filter({ hasText: '北京' }).click()
1414
await expect(cacheValue).toContainText(['选项 1'])
1515

1616
await input.click()
17-
await dropdown.getByRole('listitem').filter({ hasText: '上海' }).click()
17+
await dropdown.getByRole('option').filter({ hasText: '上海' }).click()
1818
await expect(cacheValue).toContainText(['选项 2'])
1919
})

examples/sites/demos/pc/app/base-select/clearable.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ test('clearable', async ({ page }) => {
1616
await expect(input).toHaveValue('')
1717
// 验证选中
1818
await input.click()
19-
await dropdown.getByRole('listitem').filter({ hasText: '上海' }).click()
19+
await dropdown.getByRole('option').filter({ hasText: '上海' }).click()
2020
await expect(input).toHaveValue('上海')
2121
})

examples/sites/demos/pc/app/base-select/slot-reference.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ test('custom-reference', async ({ page }) => {
1212

1313
await expect(option).toHaveCount(0)
1414
await reference.click()
15-
await page.getByRole('listitem').filter({ hasText: // }).locator('span').click()
15+
await page.getByRole('option').filter({ hasText: // }).locator('span').click()
1616
})

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test('hex', async ({ page }) => {
1010
page.on('pageerror', (exception) => expect(exception).toBeNull())
1111
await page.goto('color-select-panel#format')
1212
await page.getByRole('button', { name: 'Toggle' }).click()
13-
await page.getByRole('textbox', { name: '请选择' }).click()
13+
await page.getByRole('combobox', { name: '请选择' }).click()
1414
await page.getByRole('list').getByText('hex').click()
1515
await page.getByRole('button', { name: '确定' }).click()
1616
await expect(page.locator('#format')).toContainText('颜色值:#66CCFF')
@@ -20,15 +20,15 @@ test('hsl 时应该为 hsl(xxx,xxx,xxx)', async ({ page }) => {
2020
page.on('pageerror', (exception) => expect(exception).toBeNull())
2121
await page.goto('color-select-panel#format')
2222
await page.getByRole('button', { name: 'Toggle' }).click()
23-
await page.getByRole('textbox', { name: '请选择' }).click()
23+
await page.getByRole('combobox', { name: '请选择' }).click()
2424
await page.getByRole('list').getByText('hsl').click()
2525
})
2626

2727
test('hsv 时候应该为 hsv(xx,xx,xx)', async ({ page }) => {
2828
page.on('pageerror', (exception) => expect(exception).toBeNull())
2929
await page.goto('color-select-panel#format')
3030
await page.getByRole('button', { name: 'Toggle' }).click()
31-
await page.getByRole('textbox', { name: '请选择' }).click()
31+
await page.getByRole('combobox', { name: '请选择' }).click()
3232
await page.getByRole('list').getByText('hsv').click()
3333
await page.getByRole('button', { name: '确定' }).click()
3434
await expect(page.locator('#format')).toContainText('颜色值:hsv(199.99999999999997, 60%, 100%)')

examples/sites/demos/pc/app/country/fields.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test('自定义数据字段', async ({ page }) => {
55
await page.goto('country#fields')
66

77
const select = page.locator('.tiny-select')
8-
const item = page.getByRole('listitem').filter({ hasText: '中国' })
8+
const item = page.getByRole('option').filter({ hasText: '中国' })
99

1010
await select.click()
1111
await item.click()

0 commit comments

Comments
 (0)