From e37ad121609e44f542b11b543b9c8e9ba9f08952 Mon Sep 17 00:00:00 2001 From: tholulomo Date: Mon, 16 Oct 2023 11:18:36 -0400 Subject: [PATCH] fix(#387): Curation form enhancements and unit tests update --- .../components/explorer/InputComponent.vue | 25 ++++++++++++++----- app/src/components/nanomine/PageHeader.vue | 1 + .../explorer/curate/form/CurationForm.vue | 16 ++++-------- .../explorer/curate/validlist/XlsList.vue | 2 +- .../explorer/InputComponent.spec.js | 1 + .../explorer/MultipleInputComponent.spec.js | 1 + .../unit/pages/explorer/CurationForm.spec.js | 4 +-- app/tests/unit/pages/explorer/XlsList.spec.js | 3 +-- 8 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/src/components/explorer/InputComponent.vue b/app/src/components/explorer/InputComponent.vue index d333ddb0..6b307ca6 100644 --- a/app/src/components/explorer/InputComponent.vue +++ b/app/src/components/explorer/InputComponent.vue @@ -2,9 +2,12 @@
- Input Required - {{ parent }} + {{inputObj.unitofmeasurement}}
- + {{ parent }} Input Required @@ -115,7 +118,8 @@ export default { dialogText: '', dialogAction: '', dialogActive: false, - tempFileContainer: {} + tempFileContainer: {}, + inFocus: false } }, computed: { @@ -125,6 +129,12 @@ export default { ...mapState({ errors: state => state.explorer.curation.curationFormError }), + unitOfMeasureExists () { + return Object.hasOwnProperty.call(this.inputObj, 'unitofmeasurement') + }, + noteExists () { + return Object.hasOwnProperty.call(this.inputObj, 'note') + }, reduceSpacing () { return { alignItems: 'baseline', minHeight: 'auto', paddingTop: 0 } }, @@ -173,6 +183,9 @@ export default { ...mapActions({ fetchXlsList: 'explorer/curation/fetchXlsList' }), + hasProperty (obj, prop) { + return Object.hasOwnProperty.call(obj, prop) + }, async fetchValues () { // set error and loading state this.loading = true diff --git a/app/src/components/nanomine/PageHeader.vue b/app/src/components/nanomine/PageHeader.vue index 8a1d696a..f945a362 100644 --- a/app/src/components/nanomine/PageHeader.vue +++ b/app/src/components/nanomine/PageHeader.vue @@ -75,6 +75,7 @@
diff --git a/app/src/pages/explorer/curate/form/CurationForm.vue b/app/src/pages/explorer/curate/form/CurationForm.vue index 86f33cbc..7bb9ca19 100644 --- a/app/src/pages/explorer/curate/form/CurationForm.vue +++ b/app/src/pages/explorer/curate/form/CurationForm.vue @@ -40,7 +40,7 @@ @@ -291,7 +285,7 @@

FieldName:

- Section::Subsection::Unit + diff --git a/app/tests/unit/components/explorer/InputComponent.spec.js b/app/tests/unit/components/explorer/InputComponent.spec.js index e28a924f..e610ee40 100644 --- a/app/tests/unit/components/explorer/InputComponent.spec.js +++ b/app/tests/unit/components/explorer/InputComponent.spec.js @@ -85,6 +85,7 @@ describe('InputComponent.vue with input type string', async () => { var text = 'sampletext' const input = wrapper.find('input') expect(wrapper.vm.inputObj.cellValue).toBe(inputObj.cellValue) + input.element.value = text await input.setValue(text) expect(wrapper.vm.inputObj.cellValue).toBe(text) }) diff --git a/app/tests/unit/components/explorer/MultipleInputComponent.spec.js b/app/tests/unit/components/explorer/MultipleInputComponent.spec.js index 1bf76d98..419b605b 100644 --- a/app/tests/unit/components/explorer/MultipleInputComponent.spec.js +++ b/app/tests/unit/components/explorer/MultipleInputComponent.spec.js @@ -54,6 +54,7 @@ describe('MultipleInputComponent.vue with input type string', async () => { var text = 'sampletext' const input = wrapper.find('input') expect(wrapper.vm.inputObj.cellValue).toBe(inputObj.cellValue) + input.element.value = text await input.setValue(text) expect(wrapper.vm.inputObj.cellValue).toBe(text) }) diff --git a/app/tests/unit/pages/explorer/CurationForm.spec.js b/app/tests/unit/pages/explorer/CurationForm.spec.js index 0fbfbf71..0a14ab72 100644 --- a/app/tests/unit/pages/explorer/CurationForm.spec.js +++ b/app/tests/unit/pages/explorer/CurationForm.spec.js @@ -102,7 +102,7 @@ describe('CurationForm.vue', () => { expect(stepper.attributes('class')).toBe( 'form__stepper form__stepper-curate' ) - expect(stepper.props().mdActiveStep).toBe('stepper_null') + expect(stepper.props().mdActiveStep).toBe('') expect(stepper.props().mdVertical).toBe(false) }) @@ -122,7 +122,7 @@ describe('CurationForm.vue', () => { const title = Object.keys(data).filter((word) => word !== 'ID') const options = select.findAllComponents('md-option-stub') - expect(select.props().value).toBe('stepper_null') + expect(select.props().value).toBe('') expect(options.length).toBe(title.length) for (let i = 0; i < options.length; i++) { diff --git a/app/tests/unit/pages/explorer/XlsList.spec.js b/app/tests/unit/pages/explorer/XlsList.spec.js index 9d94d653..b2e565c2 100644 --- a/app/tests/unit/pages/explorer/XlsList.spec.js +++ b/app/tests/unit/pages/explorer/XlsList.spec.js @@ -31,12 +31,11 @@ describe('Spreadsheet List Form.vue', () => { }) it('renders page input properly', () => { - expect.assertions(4) + expect.assertions(3) const field = wrapper.findAll('.md-field-stub') expect(field.length).toBe(2) const name = field.at(0) expect(name.find('p').text()).toBe('FieldName:') - expect(name.find('span').text()).toBe('Section::Subsection::Unit') const value = field.at(1) expect(value.find('p').text()).toBe('Value:') })