Skip to content

Commit

Permalink
Merge pull request #11 from nypublicradio/mwalsh/safari-checkbox-erro…
Browse files Browse the repository at this point in the history
…r-message-test-case

GT-1311 safari checkbox error message test case
  • Loading branch information
walsh9 authored Nov 29, 2018
2 parents 462617a + 755141e commit e954035
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
21 changes: 15 additions & 6 deletions app/components/personal-info/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { filter, not, and } from '@ember/object/computed';
import makeSubmissionValidations from '../../validations/submission';
import lookupValidator from 'ember-changeset-validations';
import { get } from '@ember/object';
import { next } from '@ember/runloop';

export default Component.extend({
tagName: 'form',
Expand Down Expand Up @@ -53,12 +54,20 @@ export default Component.extend({
});
},
validateAgreement() {
let hasAgreed = get(this, 'hasAgreed');
if (hasAgreed) {
this.set('agreementError', null);
} else {
this.set('agreementError', {message: 'please accept the Terms of Use'})
}
// delay one tick to ensure click event (update checkbox)
// registers before change event (validate checkbox)
// order of events firing can vary between browsers
next(() => {
if (this.get("isDestroyed")) {
return;
}
let hasAgreed = get(this, 'hasAgreed');
if (hasAgreed) {
this.set('agreementError', null);
} else {
this.set('agreementError', {message: 'please accept the Terms of Use'})
}
});
}
}
});
1 change: 1 addition & 0 deletions tests/acceptance/audio-survey-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ test('taking an audio survey', function(assert) {
});

andThen(function() {
assert.equal(find('.personal-info__errors').length, 0, 'no error messages should be visible after filling form');
assert.equal(find('.personal-info__submit.disabled').length, 0, 'submit button should not have disabled style after filling form');
click('.personal-info__submit');
});
Expand Down

0 comments on commit e954035

Please sign in to comment.