Skip to content

Commit

Permalink
adds test coverage for save-on-enter.
Browse files Browse the repository at this point in the history
adds test coverage for save-on-enter.
  • Loading branch information
stopfstedt committed Feb 7, 2024
1 parent 7024f4c commit d074f1c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,38 @@ module('Integration | Component | school/emails-editor', function (hooks) {
);
await component.cancel();
});

test('save on enter in administrator email input', async function (assert) {
assert.expect(2);
const school = this.server.create('school');
const schoolModel = await this.owner.lookup('service:store').findRecord('school', school.id);
this.set('school', schoolModel);
this.set('save', (administratorEmail, changeAlertRecipients) => {
assert.strictEqual(administratorEmail, '[email protected]');
assert.strictEqual(changeAlertRecipients, '[email protected], [email protected]');
});
await render(
hbs`<School::EmailsEditor @school={{this.school}} @save={{this.save}} @cancel={{(noop)}} />`,
);
await component.administratorEmail.set('[email protected]');
await component.changeAlertRecipients.set('[email protected], [email protected]');
await component.administratorEmail.save();
});

test('save on enter in change-alerts recipients input', async function (assert) {
assert.expect(2);
const school = this.server.create('school');
const schoolModel = await this.owner.lookup('service:store').findRecord('school', school.id);
this.set('school', schoolModel);
this.set('save', (administratorEmail, changeAlertRecipients) => {
assert.strictEqual(administratorEmail, '[email protected]');
assert.strictEqual(changeAlertRecipients, '[email protected], [email protected]');
});
await render(
hbs`<School::EmailsEditor @school={{this.school}} @save={{this.save}} @cancel={{(noop)}} />`,
);
await component.administratorEmail.set('[email protected]');
await component.changeAlertRecipients.set('[email protected], [email protected]');
await component.changeAlertRecipients.save();
});
});
12 changes: 11 additions & 1 deletion packages/frontend/tests/pages/components/school/emails-editor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { clickable, create, fillable, isPresent, text, value } from 'ember-cli-page-object';
import {
clickable,
create,
fillable,
isPresent,
text,
triggerable,
value,
} from 'ember-cli-page-object';

const definition = create({
scope: '[data-test-school-emails-editor]',
Expand All @@ -12,6 +20,7 @@ const definition = create({
value: value('input'),
hasError: isPresent('.validation-error-message'),
errorMessage: text('.validation-error-message'),
save: triggerable('keyup', 'input', { eventProperties: { key: 'Enter' } }),
},
changeAlertRecipients: {
scope: '[data-test-change-alert-recipients]',
Expand All @@ -20,6 +29,7 @@ const definition = create({
value: value('input'),
hasError: isPresent('.validation-error-message'),
errorMessage: text('.validation-error-message'),
save: triggerable('keyup', 'input', { eventProperties: { key: 'Enter' } }),
},
});

Expand Down

0 comments on commit d074f1c

Please sign in to comment.