From cb12b6926e08a2480ce150ce587fb737f9150fbd Mon Sep 17 00:00:00 2001 From: Jared Galanis Date: Tue, 26 Sep 2023 10:50:30 -0400 Subject: [PATCH 1/2] fix: hidden authors fields in metadata schema step Closes: https://github.com/eclipse-pass/main/issues/710 --- app/components/metadata-form/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/components/metadata-form/index.js b/app/components/metadata-form/index.js index 6046c28b..4d12b11e 100644 --- a/app/components/metadata-form/index.js +++ b/app/components/metadata-form/index.js @@ -41,6 +41,11 @@ export default Component.extend({ }, }; + if (!newForm?.data?.authors) { + newForm.data = {}; + newForm.data.authors = [{}]; + } + $('#schemaForm').empty(); $('#schemaForm').alpaca(newForm); }, From a2ce013058421e61906269b526ac813f5f137e14 Mon Sep 17 00:00:00 2001 From: Jared Galanis Date: Tue, 26 Sep 2023 12:44:22 -0400 Subject: [PATCH 2/2] fix tests --- app/components/metadata-form/index.js | 6 +----- app/services/metadata-schema.js | 1 + tests/acceptance/nih-submission-test.js | 4 ++-- tests/integration/components/workflow-metadata-test.js | 7 ------- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/components/metadata-form/index.js b/app/components/metadata-form/index.js index 4d12b11e..a9293602 100644 --- a/app/components/metadata-form/index.js +++ b/app/components/metadata-form/index.js @@ -1,5 +1,4 @@ /* eslint-disable ember/no-classic-components, ember/no-classic-classes, ember/require-tagless-components, ember/no-component-lifecycle-hooks, ember/no-get */ -// import Component from '@ember/component'; import Component from '@ember/component'; import _ from 'lodash'; import { get } from '@ember/object'; @@ -41,10 +40,7 @@ export default Component.extend({ }, }; - if (!newForm?.data?.authors) { - newForm.data = {}; - newForm.data.authors = [{}]; - } + newForm.options.hideInitValidationError = true; $('#schemaForm').empty(); $('#schemaForm').alpaca(newForm); diff --git a/app/services/metadata-schema.js b/app/services/metadata-schema.js index af32efa7..b1e2b244 100644 --- a/app/services/metadata-schema.js +++ b/app/services/metadata-schema.js @@ -103,6 +103,7 @@ export default class MetadataSchemaService extends Service { addDisplayData(schema, data, readonly) { if (!schema.data) { schema.data = {}; + schema.data.authors = [{}]; } // Will merge 'data' onto 'schema.data'. 'schema.data' values may be overwritten by values from 'data' schema.data = Object.assign(schema.data, data); diff --git a/tests/acceptance/nih-submission-test.js b/tests/acceptance/nih-submission-test.js index 29518ae7..87a8fbca 100644 --- a/tests/acceptance/nih-submission-test.js +++ b/tests/acceptance/nih-submission-test.js @@ -467,7 +467,7 @@ module('Acceptance | submission', function (hooks) { await click('.alpaca-form-button-Next'); await waitFor(document.querySelector('#swal2-content')); - assert.dom(document.querySelector('#swal2-content')).includesText("should have required property 'authors'"); + assert.dom(document.querySelector('#swal2-content')).includesText("should have required property 'author'"); // Some reason, setting the document query to a variable before clicking works, // but calling the query selector in the click does not work @@ -612,7 +612,7 @@ module('Acceptance | submission', function (hooks) { await click('.alpaca-form-button-Next'); await waitFor(document.querySelector('#swal2-content')); - assert.dom(document.querySelector('#swal2-content')).includesText("should have required property 'authors'"); + assert.dom(document.querySelector('#swal2-content')).includesText("should have required property 'author'"); const confirmBtn = document.querySelector('.swal2-confirm'); assert.ok(confirmBtn, 'No SweetAlert OK button found'); diff --git a/tests/integration/components/workflow-metadata-test.js b/tests/integration/components/workflow-metadata-test.js index 5f2a65db..eff85a97 100644 --- a/tests/integration/components/workflow-metadata-test.js +++ b/tests/integration/components/workflow-metadata-test.js @@ -268,10 +268,7 @@ module('Integration | Component | workflow-metadata', (hooks) => { @publication={{this.publication}} /> `); - await waitFor('[data-key="Next"]'); - await waitFor('[data-key="Back"]'); - await waitFor('[data-key="Abort"]'); await click('[data-key="Next"]'); // Need to fill out ISSN field @@ -279,10 +276,6 @@ module('Integration | Component | workflow-metadata', (hooks) => { await fillIn('[name="ISSN"]', '1234'); await click('button[data-key="Next"]'); - await waitFor('[data-key="Back"]'); - await waitFor('[data-key="Abort"]'); - await waitFor('input[name="ISSN"]'); - await click('[data-key="Next"]'); await waitFor(document.querySelector('.swal2-confirm'));