Skip to content

Commit

Permalink
test(subform): only one child: field Disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Liberty-liu committed Sep 10, 2023
1 parent ba7cd63 commit 5dece8c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/formTypes/subform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ describe('Field: subform', () => {
expect(previewWrapper.find(`[data-field-id="${list.columns[0]}"] .el-form-item`).classes()).not.toContain('is-required')
expect(previewWrapper.find(`[data-field-id="${newField.columns[0]}"] .el-form-item`).classes()).toContain('is-required')
})
test('Only one child: field Disabled', async () => {
const newField = _.cloneDeep(field)
field.columns[0].options.disabled = true
newField.columns[0] = newField.columns[0].id
const subForm = erGeneratorData(_.cloneDeep(erComponentsConfig.fieldsConfig[2].list[5]), true, 'en')
const list = _.cloneDeep(subForm)
list.columns[0] = subForm.columns[0].id
subForm.columns[0].list[0].push(newField)
const data = wrapLayoutDataByLayoutType([list], [subForm.columns[0], field.columns[0]])
await previewWrapper.findComponent({ ref: 'EReditorRef' }).vm.setData(data)
expect(previewWrapper.find(utils.getTestId('SubformLayout:addButton')).exists()).toBe(true)
expect(previewWrapper.findAll(utils.getTestId('SubformLayout:item'))).toHaveLength(0)
await previewWrapper.find(utils.getTestId('SubformLayout:addButton')).find('button').trigger('click')
expect(previewWrapper.findAll(utils.getTestId('SubformLayout:item'))).toHaveLength(1)
previewWrapper.find('[data-test="er-complete-button"] button').trigger('click')
await new Promise(resolve => setTimeout(resolve, 1000))
expect([list.columns[0], newField.columns[0]]).toStrictEqual(previewWrapper.findAll('[data-field-id]').map(element => element.element.dataset.fieldId))
expect(previewWrapper.find(`[data-field-id="${newField.columns[0]}"] .el-input`).classes()).toContain('is-disabled')
})
test('Only one child: has 2 default contents', async () => {
const values = ['1', '2']
const newField = _.cloneDeep(field)
Expand Down

0 comments on commit 5dece8c

Please sign in to comment.