Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(e2e): [tooltip,select] fix the security that causes e2e test failures. #2743

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ test.describe('下拉表格远程搜索', () => {
await expect(input).toHaveValue('省 6-市 6')
await input.click()
await expect(page.getByRole('row', { name: '省份 6 城市 6 区域 6' })).toHaveClass(/row__current/)
await input.fill(' ')
// 由于修改示例,增加了空格。所以1个空格匹配全部行, 2个空格才空数据
await input.fill(' ' + ' ')
await input.press('Enter')
await expect(dropdown).toBeVisible()
await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty()
Expand All @@ -79,12 +80,12 @@ test.describe('下拉表格远程搜索', () => {
await expect(suffixSvg).toBeHidden()
await expect(dropdown).toBeHidden()

await input.fill(' ')
await input.fill(' ' + ' ')
await input.press('Enter')
await page.waitForTimeout(1000)
await expect(dropdown).toBeVisible()
await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty()
await input.fill('')
await input.fill(' ')
await input.press('Enter')
await page.waitForTimeout(1000)
await expect(dropdown.locator('.tiny-grid__body tbody')).not.toBeEmpty()
Expand Down Expand Up @@ -127,7 +128,7 @@ test.describe('下拉表格远程搜索', () => {
await tag.nth(0).locator('.tiny-svg').click()
await tag.nth(0).locator('.tiny-svg').click()
await expect((await tag.all()).length).toEqual(0)
await input.fill(' ')
await input.fill(' ' + ' ')
await input.press('Enter')
await expect(dropdown).toBeVisible()
await expect(dropdown.locator('.tiny-grid__body tbody')).toBeEmpty()
Expand Down
17 changes: 9 additions & 8 deletions packages/renderless/src/common/deps/popper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,16 @@ const stopFn = (ev: Event) => {
}

/** 全局的resize观察器, 监听popper的大小改变 */
const resizeOb = isBrowser
? new ResizeObserver((entries) => {
entries.forEach((entry) => {
if (entry.target.popperVm && entry.contentRect.height > 50) {
entry.target.popperVm.update()
}
const resizeOb =
isBrowser && typeof ResizeObserver === 'function'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that ResizeObserver is supported in the environment to prevent runtime errors. This change adds a check for the existence of ResizeObserver before instantiation.

? new ResizeObserver((entries) => {
entries.forEach((entry) => {
if (entry.target.popperVm && entry.contentRect.height > 50) {
entry.target.popperVm.update()
}
})
})
})
: null
: null

interface PopperOptions {
arrowOffset: number
Expand Down
6 changes: 6 additions & 0 deletions packages/renderless/src/select/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ export const handleQueryChange =
})
}

// 嵌套树时, filterMehod传递给tree组件,然后在上面: vm.$refs.selectTree.filter(value) 强制让tree去过滤了。
// 如果不return,那么 api.defaultOnQueryChange 内部会再次过滤,而触发错误。
if (props.renderType === constants.TYPE.Tree) {
return
}

state.triggerSearch = true

api.defaultOnQueryChange(value, isInput)
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-common/src/breakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useBreakpoint = () => {
const activeBreakpoint = hooks.ref('')
const prefixes = ['2xl', 'xl', 'lg', 'md', 'sm']
const createMatchMedia = (mediaQueryString) => {
if (isServer) {
if (isServer || typeof matchMedia !== 'function') {
return {
matches: false,
media: mediaQueryString,
Expand Down
Loading