-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change form validation rules to prevent empty school admin emails fro…
…m being submitted. the corresponding backend model asserts that school admin emails have to be at least one character long. this realigns the frontend form validation rules with the asserts on the backend data model.
- Loading branch information
1 parent
fcec5a7
commit 23b7b83
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ module('Integration | Component | school/emails-editor', function (hooks) { | |
assert.notOk(component.changeAlertRecipients.hasError); | ||
}); | ||
|
||
test('save with empty data', async function (assert) { | ||
test('save with empty change alerts recipients', async function (assert) { | ||
assert.expect(8); | ||
const school = this.server.create('school', { | ||
iliosAdministratorEmail: '[email protected]', | ||
|
@@ -58,7 +58,7 @@ module('Integration | Component | school/emails-editor', function (hooks) { | |
const schoolModel = await this.owner.lookup('service:store').findRecord('school', school.id); | ||
this.set('school', schoolModel); | ||
this.set('save', (administratorEmail, changeAlertRecipients) => { | ||
assert.strictEqual(administratorEmail, ''); | ||
assert.strictEqual(administratorEmail, '[email protected]'); | ||
assert.strictEqual(changeAlertRecipients, ''); | ||
}); | ||
await render( | ||
|
@@ -71,14 +71,37 @@ module('Integration | Component | school/emails-editor', function (hooks) { | |
); | ||
assert.notOk(component.administratorEmail.hasError); | ||
assert.notOk(component.changeAlertRecipients.hasError); | ||
await component.administratorEmail.set(''); | ||
await component.changeAlertRecipients.set(''); | ||
await component.save(); | ||
assert.notOk(component.administratorEmail.hasError); | ||
assert.notOk(component.changeAlertRecipients.hasError); | ||
}); | ||
|
||
test('validation fails', async function (assert) { | ||
test('validation fails if given admin email is empty', async function (assert) { | ||
assert.expect(6); | ||
const school = this.server.create('school', { | ||
iliosAdministratorEmail: '[email protected]', | ||
changeAlertRecipients: '[email protected], [email protected]', | ||
}); | ||
const schoolModel = await this.owner.lookup('service:store').findRecord('school', school.id); | ||
this.set('school', schoolModel); | ||
await render( | ||
hbs`<School::EmailsEditor @school={{this.school}} @save={{(noop)}} @cancel={{(noop)}} />`, | ||
); | ||
assert.strictEqual(component.administratorEmail.value, '[email protected]'); | ||
assert.strictEqual( | ||
component.changeAlertRecipients.value, | ||
'[email protected], [email protected]', | ||
); | ||
assert.notOk(component.administratorEmail.hasError); | ||
assert.notOk(component.changeAlertRecipients.hasError); | ||
await component.administratorEmail.set(''); | ||
await component.save(); | ||
assert.ok(component.administratorEmail.hasError); | ||
assert.notOk(component.changeAlertRecipients.hasError); | ||
}); | ||
|
||
test('validation fails if input contains invalid emails', async function (assert) { | ||
const school = this.server.create('school'); | ||
const schoolModel = await this.owner.lookup('service:store').findRecord('school', school.id); | ||
this.set('school', schoolModel); | ||
|