Skip to content

Commit

Permalink
fix: hidden authors fields in metadata schema step (#1217)
Browse files Browse the repository at this point in the history
* fix: hidden authors fields in metadata schema step

Closes: eclipse-pass/main#710

* fix tests
  • Loading branch information
jaredgalanis authored Sep 26, 2023
1 parent c047181 commit 37c41e2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/components/metadata-form/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,6 +40,8 @@ export default Component.extend({
},
};

newForm.options.hideInitValidationError = true;

$('#schemaForm').empty();
$('#schemaForm').alpaca(newForm);
},
Expand Down
1 change: 1 addition & 0 deletions app/services/metadata-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/nih-submission-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
7 changes: 0 additions & 7 deletions tests/integration/components/workflow-metadata-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,21 +268,14 @@ 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
await waitFor('[name="ISSN"]');
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'));

Expand Down

0 comments on commit 37c41e2

Please sign in to comment.