Skip to content

Commit

Permalink
feat(test): [dropdown,select,slider] Modify test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MomoPoppy committed Sep 20, 2024
1 parent e779208 commit e78b274
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 6 additions & 4 deletions examples/sites/demos/pc/app/select/multiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ test('多选时取远端数据与当前已选数据的并集', async ({ page })
await option.filter({ hasText: '全部' }).click()
await expect(tag).toHaveCount(7)
await option.filter({ hasText: '全部' }).click()
await expect(tag).toHaveCount(0)
await expect(tag).toHaveCount(2)
await option.filter({ hasText: '北京' }).click()
await expect(tag).toHaveCount(1)
await expect(tag).toHaveCount(2)
await option.filter({ hasText: '上海' }).click()
await expect(tag).toHaveCount(2)
await tag.filter({ hasText: '上海' }).locator('.tiny-tag__close').click()
await expect(tag).toHaveCount(1)
await option.filter({ hasText: '天津' }).click()
await expect(tag).toHaveCount(3)
await tag.filter({ hasText: '天津' }).locator('.tiny-tag__close').click()
await expect(tag).toHaveCount(2)
})

test('multiple-limit', async ({ page }) => {
Expand Down
5 changes: 3 additions & 2 deletions examples/sites/demos/pc/app/select/size.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('默认尺寸', async ({ page }) => {
const input = select.locator('.tiny-input')
const tag = select.locator('.tiny-tag')

await expect(input.locator('.tiny-input__inner')).toHaveCSS('height', '28px')
await expect(input.locator('.tiny-input__inner')).toHaveCSS('height', '32px')
await expect(tag.nth(0)).toHaveClass(/tiny-tag--light/)
})

Expand All @@ -23,6 +23,7 @@ test('medium 尺寸', async ({ page }) => {
const tag = select.locator('.tiny-tag')

await expect(input).toHaveClass(/tiny-input-medium/)
// TODO: 此处继承input 尺寸的话,应该是32
await expect(input.locator('.tiny-input__inner')).toHaveCSS('height', '40px')
await expect(tag.nth(0)).toHaveClass(/tiny-tag--medium tiny-tag--light/)
})
Expand All @@ -39,7 +40,7 @@ test('small 尺寸', async ({ page }) => {

await expect(input).toHaveClass(/tiny-input-small/)
await expect(tag.nth(0)).toHaveClass(/tiny-tag--small tiny-tag--light/)
expect(height).toBeCloseTo(32, 1)
expect(height).toBeCloseTo(28, 1)
})

test('mini 尺寸', async ({ page }) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/sites/demos/pc/app/slider/show-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test('输入框模式', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('slider#show-input')

const sliderInput = page.locator('.tiny-slider-container .tiny-slider__input input')
const sliderInput = page.locator('.tiny-slider-container .tiny-slider__input .tiny-input__inner')
const sliderBlock = page.locator('.tiny-slider-container .tiny-slider .tiny-slider__handle')
const sliderTip = page.locator('.tiny-slider-container .tiny-slider .tiny-slider__tips')

Expand All @@ -17,6 +17,7 @@ test('输入框模式', async ({ page }) => {
await singleBlock.hover()
await expect(sliderTip.nth(0)).toHaveText('60')

await page.waitForTimeout(200)
// 双输入框
await sliderInput.nth(1).click()
await sliderInput.nth(1).fill('70')
Expand Down
6 changes: 3 additions & 3 deletions packages/renderless/src/slider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ export const updateSlotValue =

export const handleSlotInput =
({ state, api }: Pick<ISliderRenderlessParams, 'api' | 'state'>) =>
(event: Event, isLeftInput: boolean = true): void => {
(event: Event, isLeftInput = true): void => {
const inputValue = (event.target as HTMLInputElement).value

api.changeActiveValue(state.isDouble ? isLeftInput : true)
Expand All @@ -651,9 +651,9 @@ export const handleSlotInput =

export const inputOnChange =
({ api, emit, props, state }: Pick<ISliderRenderlessParams, 'api' | 'state' | 'props' | 'emit'>) =>
(event: Event) => {
(currentValue: string) => {
if (!props.changeCompat) {
if (!/^\d+$/.test(event.target.value)) {
if (!/^\d+$/.test(currentValue)) {
state.activeValue = state.leftBtnValue
return
}
Expand Down

0 comments on commit e78b274

Please sign in to comment.