diff --git a/wherehows-web/tests/integration/components/dataset-deprecation-test.js b/wherehows-web/tests/integration/components/dataset-deprecation-test.js index 6ac3194dc5..fcb41a6f65 100644 --- a/wherehows-web/tests/integration/components/dataset-deprecation-test.js +++ b/wherehows-web/tests/integration/components/dataset-deprecation-test.js @@ -1,5 +1,5 @@ import { moduleForComponent, test } from 'ember-qunit'; -import { click } from 'ember-native-dom-helpers'; +import { click, fillIn } from 'ember-native-dom-helpers'; import notificationsStub from 'wherehows-web/tests/stubs/services/notifications'; import hbs from 'htmlbars-inline-precompile'; import { run } from '@ember/runloop'; @@ -39,6 +39,25 @@ test('setting the deprecated property should toggle the checkbox', function(asse assert.notOk(this.$('#dataset-is-deprecated').is(':checked'), 'checkbox is unchecked when property is set false'); }); +test('decommissionDate', async function(assert) { + let isDisabled; + assert.expect(2); + + this.set('decommissionDate', void 0); + this.set('deprecated', true); + + this.render(hbs`{{dataset-deprecation deprecated=deprecated decommissionDate=decommissionDate}}`); + isDisabled = this.$('.dataset-deprecation-toggle__actions [type=submit]').is(':disabled'); + assert.ok(isDisabled, 'submit button is disabled'); + + this.setProperties({ decommissionDate: new Date(), isDirty: true }); + this.render(hbs`{{dataset-deprecation deprecated=deprecated decommissionDate=decommissionDate}}`); + await fillIn('.comment-new__content', 'text'); + + isDisabled = this.$('.dataset-deprecation-toggle__actions [type=submit]').is(':disabled'); + assert.notOk(isDisabled, 'submit button is not disabled'); +}); + test('triggers the onUpdateDeprecation action when submitted', async function(assert) { let submitActionCallCount = 0; @@ -47,8 +66,9 @@ test('triggers the onUpdateDeprecation action when submitted', async function(as assert.equal(deprecated, true, 'action is called with deprecation value of true'); assert.equal(note, '', 'action is called with an empty deprecation note'); }); + this.set('decommissionDate', new Date()); - this.render(hbs`{{dataset-deprecation onUpdateDeprecation=(action submit)}}`); + this.render(hbs`{{dataset-deprecation onUpdateDeprecation=(action submit) decommissionDate=decommissionDate}}`); assert.equal(submitActionCallCount, 0, 'action is not called on render'); assert.equal(this.$('#dataset-is-deprecated').is(':checked'), false, 'deprecation checkbox is unchecked');