mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import ViewSortContext from '@baserow/modules/database/components/view/ViewSortContext'
|
|
import ViewGroupByContext from '@baserow/modules/database/components/view/ViewGroupByContext'
|
|
|
|
describe('sort and group by menus with an entry on a field not listed', () => {
|
|
let testApp = null
|
|
|
|
const database = { id: 1, workspace: { id: 1 } }
|
|
const fields = [{ id: 1, name: 'Name', type: 'text', primary: true }]
|
|
const entry = {
|
|
id: 10,
|
|
field: 2,
|
|
order: 'ASC',
|
|
type: 'default',
|
|
width: 200,
|
|
_: { loading: false },
|
|
}
|
|
const view = {
|
|
id: 1,
|
|
type: 'grid',
|
|
ownership_type: 'collaborative',
|
|
sortings: [entry],
|
|
group_bys: [entry],
|
|
group_by_layout: 'section',
|
|
}
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await testApp.afterEach()
|
|
})
|
|
|
|
const menus = [
|
|
['sort', ViewSortContext, { disableSort: false }, '.sortings__remove'],
|
|
[
|
|
'group by',
|
|
ViewGroupByContext,
|
|
{ disableGroupBy: false },
|
|
'.group-bys__remove',
|
|
],
|
|
]
|
|
|
|
const showMenu = async (component, disableProp) => {
|
|
const wrapper = await testApp.mount(component, {
|
|
props: { database, view, fields, readOnly: true, ...disableProp },
|
|
})
|
|
await wrapper.vm.show(document.body)
|
|
await wrapper.vm.$nextTick()
|
|
}
|
|
|
|
test.each(menus)(
|
|
'%s menu keeps the entry removable',
|
|
async (_, component, disableProp, removeSelector) => {
|
|
await showMenu(component, disableProp)
|
|
|
|
expect(document.body.querySelectorAll(removeSelector)).toHaveLength(1)
|
|
}
|
|
)
|
|
|
|
test.each(menus)(
|
|
'%s menu still offers the listed field that is free',
|
|
async (_, component, disableProp) => {
|
|
await showMenu(component, disableProp)
|
|
|
|
expect(
|
|
document.body.querySelectorAll('.button-text__icon.iconoir-plus')
|
|
).toHaveLength(1)
|
|
}
|
|
)
|
|
})
|