mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(database): assign and mention identities behind a field option - Collaborator fields get `include_identities` and long text fields `long_text_include_identities`, both off by default. - With the option on, active identities of the workspace can be assigned or suggested as mentions; they are shown with their icon and renamed in realtime, and they never receive notifications. - Turning the collaborator option off backs up the column, deletes the identity assignments and strips identities from the view defaults, so the update can be undone. - Identities can author row comments and be mentioned in them. - Exports write an identity as `Name <identity>`. * refactor: hide internal emails in collaborator exports through one check * fix: import a personal view only for a person, without a query per owner * fix: show collaborator identities with the icon of the user subject type * refactor: drop a redundant local import of the core handler * fix: unify identity icons and space field options * fix: keep identity field menus and saved mentions readable * fix: limit identity mention suggestions to row comments * perf: prefetch available collaborators once per workspace * fix: use workspace members as authors of generated rows * fix: resolve linked collaborator values by member email * fix: use workspace collaborators for field pickers and paste * refactor: move identity avatar styles to the avatar stylesheet * fix: address review feedback on identity collaborators
143 lines
4.0 KiB
JavaScript
143 lines
4.0 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import Context from '@baserow/modules/core/components/Context'
|
|
|
|
describe('Context.vue', () => {
|
|
it('renders the slot content when openedOnce is true', () => {
|
|
const wrapper = mount(Context, {
|
|
data() {
|
|
return {
|
|
openedOnce: true,
|
|
}
|
|
},
|
|
slots: {
|
|
default: 'Test Content',
|
|
},
|
|
})
|
|
|
|
expect(wrapper.text()).toContain('Test Content')
|
|
})
|
|
|
|
it('does not render the slot content when openedOnce is false', () => {
|
|
const wrapper = mount(Context, {
|
|
data() {
|
|
return {
|
|
openedOnce: false,
|
|
}
|
|
},
|
|
slots: {
|
|
default: 'Test Content',
|
|
},
|
|
})
|
|
|
|
expect(wrapper.text()).not.toContain('Test Content')
|
|
})
|
|
|
|
it('adds the visibility-hidden class when open or updatedOnce is false', () => {
|
|
const wrapper = mount(Context, {
|
|
data() {
|
|
return {
|
|
open: false,
|
|
updatedOnce: false,
|
|
}
|
|
},
|
|
})
|
|
|
|
const contextEl = wrapper.find('[ref="contextEl"]').exists()
|
|
? wrapper.find('[ref="contextEl"]')
|
|
: wrapper.find('.context')
|
|
expect(contextEl.classes()).toContain('visibility-hidden')
|
|
})
|
|
|
|
it('does not add the visibility-hidden class when open and updatedOnce are true', () => {
|
|
const wrapper = mount(Context, {
|
|
data() {
|
|
return {
|
|
open: true,
|
|
updatedOnce: true,
|
|
}
|
|
},
|
|
})
|
|
|
|
const contextEl = wrapper.find('.context')
|
|
expect(contextEl.classes()).not.toContain('visibility-hidden')
|
|
})
|
|
|
|
it('adds the context--overflow-scroll class when overflowScroll prop is true', () => {
|
|
const wrapper = mount(Context, {
|
|
propsData: {
|
|
overflowScroll: true,
|
|
},
|
|
})
|
|
|
|
const contextEl = wrapper.find('.context')
|
|
expect(contextEl.classes()).toContain('context--overflow-scroll')
|
|
})
|
|
|
|
it('does not add the context--overflow-scroll class when overflowScroll prop is false', () => {
|
|
const wrapper = mount(Context, {
|
|
propsData: {
|
|
overflowScroll: false,
|
|
},
|
|
})
|
|
|
|
const contextEl = wrapper.find('.context')
|
|
expect(contextEl.classes()).not.toContain('context--overflow-scroll')
|
|
})
|
|
|
|
it('sets the correct default props', () => {
|
|
const wrapper = mount(Context)
|
|
|
|
expect(wrapper.props('hideOnClickOutside')).toBe(true)
|
|
expect(wrapper.props('overflowScroll')).toBe(false)
|
|
expect(typeof wrapper.props('maxHeightIfOutsideViewport')).toBe('boolean')
|
|
expect(wrapper.props('maxHeightIfOutsideViewport')).toBe(false)
|
|
})
|
|
|
|
it('toggles the open state when the toggle method is called', async () => {
|
|
const wrapper = mount(Context)
|
|
const target = document.createElement('div')
|
|
|
|
expect(wrapper.vm.open).toBe(false)
|
|
|
|
wrapper.vm.toggle(target)
|
|
await wrapper.vm.$nextTick()
|
|
|
|
expect(wrapper.vm.open).toBe(true)
|
|
})
|
|
|
|
it('sets the opener when the toggle method is called with a target', async () => {
|
|
const wrapper = mount(Context)
|
|
const target = document.createElement('div')
|
|
|
|
expect(wrapper.vm.opener).toBe(null)
|
|
|
|
wrapper.vm.toggle(target)
|
|
await wrapper.vm.$nextTick()
|
|
|
|
expect(wrapper.vm.opener).toBe(target)
|
|
})
|
|
|
|
it('positions a menu within a scrolled viewport when its anchor is partly outside', () => {
|
|
vi.stubGlobal('innerWidth', 375)
|
|
vi.stubGlobal('scrollX', 156)
|
|
const wrapper = mount(Context, { props: { horizontalViewportMargin: 8 } })
|
|
try {
|
|
const menu = wrapper.vm.getTeleportedElement()
|
|
vi.spyOn(menu, 'offsetWidth', 'get').mockReturnValue(359)
|
|
vi.spyOn(menu, 'getBoundingClientRect').mockReturnValue(
|
|
new DOMRect(0, 0, 359, 287)
|
|
)
|
|
const anchor = document.createElement('button')
|
|
vi.spyOn(anchor, 'getBoundingClientRect').mockReturnValue(
|
|
new DOMRect(294, 51, 99, 32)
|
|
)
|
|
expect(
|
|
wrapper.vm.calculatePositionElement(anchor, 'bottom', 'left', 10, 0)
|
|
).toMatchObject({ left: 164, right: null })
|
|
} finally {
|
|
wrapper.unmount()
|
|
vi.unstubAllGlobals()
|
|
}
|
|
})
|
|
})
|