mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 08:48:35 +00:00
A cell unmounted in the same render it was mounted in has no cell ref yet, and a context can be hidden after an awaited request outlived it (Sentry FE-BX, FP, FN).
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import { describe, expect, test, vi } from 'vitest'
|
|
import { h, nextTick } from 'vue'
|
|
import { mount } from '@vue/test-utils'
|
|
import gridField from '@baserow/modules/database/mixins/gridField'
|
|
import gridFieldInput from '@baserow/modules/database/mixins/gridFieldInput'
|
|
|
|
const Cell = {
|
|
mixins: [gridField, gridFieldInput],
|
|
emits: ['created'],
|
|
created() {
|
|
this.$emit('created')
|
|
},
|
|
render() {
|
|
return h('div', { ref: 'cell' })
|
|
},
|
|
}
|
|
|
|
describe('gridField', () => {
|
|
test('a selected cell unmounted in the render it was mounted in does not throw', async () => {
|
|
// The parent hides the cell again while it is being created, so Vue unmounts
|
|
// it in the same flush, before its `cell` ref is set and `mounted` runs.
|
|
const Parent = {
|
|
data: () => ({ show: false }),
|
|
render() {
|
|
return this.show
|
|
? h(Cell, {
|
|
workspaceId: 1,
|
|
field: { id: 1, type: 'text' },
|
|
value: '',
|
|
selected: true,
|
|
readOnly: false,
|
|
storePrefix: '',
|
|
onCreated: () => (this.show = false),
|
|
})
|
|
: h('div')
|
|
},
|
|
}
|
|
const errorHandler = vi.fn()
|
|
const wrapper = mount(Parent, { global: { config: { errorHandler } } })
|
|
|
|
wrapper.vm.show = true
|
|
await nextTick()
|
|
|
|
expect(wrapper.findComponent(Cell).exists()).toBe(false)
|
|
expect(errorHandler).not.toHaveBeenCalled()
|
|
})
|
|
})
|