mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* fix(database): guard grid against missing and stale cell values Grouped rows now get newly created fields, sorts treat a missing or null cell as empty, and rich text cells tolerate a value of the previous field type. Rows in collapsed groups resolve their group from the section key. * fix(database): address review findings on grid cell guards Key an undefined group value like null so pathFromKey can parse it, remove deleted rows from collapsed groups, and sort present-but-undefined cells and empty multiple select or collaborator formulas as empty. * refactor(database): drop empty value for formula types that cannot be sorted Multiple select and collaborator formulas cannot be sorted or grouped by, so a missing cell never reaches their sort. * fix(database): sort zero in array formulas as a value The element check treated 0 as missing, so [0] tied with [] and with other numbers. * fix(database): keep grouped row caches shared and sort null cells as empty addField now reuses one copy per row, so an edit reaches both sectionRows and absoluteRows. The sort wrapper also replaces null cells.
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
import { TestApp } from '@baserow/test/helpers/testApp'
|
|
import GridViewFieldSingleSelect from '@baserow/modules/database/components/view/grid/fields/GridViewFieldSingleSelect'
|
|
import FieldSelectOptionsDropdown from '@baserow/modules/database/components/field/FieldSelectOptionsDropdown'
|
|
|
|
describe('GridViewFieldSingleSelect component', () => {
|
|
let testApp = null
|
|
|
|
beforeEach(() => {
|
|
testApp = new TestApp()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
await testApp.afterEach()
|
|
})
|
|
|
|
const option = { id: 1, value: 'Done', color: 'green' }
|
|
const field = {
|
|
id: 1,
|
|
name: 'Status',
|
|
order: 0,
|
|
type: 'single_select',
|
|
primary: false,
|
|
select_options: [option],
|
|
_: { loading: false },
|
|
}
|
|
|
|
const mountComponent = (value, readOnly = true) =>
|
|
testApp.mount(GridViewFieldSingleSelect, {
|
|
props: {
|
|
field,
|
|
value,
|
|
readOnly,
|
|
selected: true,
|
|
storePrefix: 'page/',
|
|
workspaceId: 10,
|
|
},
|
|
})
|
|
|
|
test('renders the selected option', async () => {
|
|
const wrapper = await mountComponent(option)
|
|
|
|
const selected = wrapper.find('.grid-field-single-select__option')
|
|
expect(selected.text()).toBe('Done')
|
|
expect(selected.classes()).toContain('background-color--green')
|
|
})
|
|
|
|
// A row missing the field's key, e.g. one added before the field reached
|
|
// the store, passes an undefined value.
|
|
test.each([[null], [undefined]])(
|
|
'renders no option for the value %s',
|
|
async (value) => {
|
|
const wrapper = await mountComponent(value)
|
|
|
|
expect(wrapper.find('.grid-field-single-select__option').exists()).toBe(
|
|
false
|
|
)
|
|
}
|
|
)
|
|
|
|
test('saves an option picked for a cell with an undefined value', async () => {
|
|
const wrapper = await mountComponent(undefined, false)
|
|
|
|
wrapper.findComponent(FieldSelectOptionsDropdown).vm.$emit('input', 1)
|
|
|
|
expect(wrapper.emitted('update')).toEqual([[option, null]])
|
|
})
|
|
})
|