From d074f1cc9e4d064a6b1bd030293895cb1fb6f035 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Wed, 7 Feb 2024 14:33:28 -0800 Subject: [PATCH] adds test coverage for save-on-enter. adds test coverage for save-on-enter. --- .../components/school/emails-editor-test.js | 34 +++++++++++++++++++ .../pages/components/school/emails-editor.js | 12 ++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/frontend/tests/integration/components/school/emails-editor-test.js b/packages/frontend/tests/integration/components/school/emails-editor-test.js index 8a43d9296d..760242c999 100644 --- a/packages/frontend/tests/integration/components/school/emails-editor-test.js +++ b/packages/frontend/tests/integration/components/school/emails-editor-test.js @@ -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, 'admin@school.edu'); + assert.strictEqual(changeAlertRecipients, 'email1@school.edu, email2@school.edu'); + }); + await render( + hbs``, + ); + await component.administratorEmail.set('admin@school.edu'); + await component.changeAlertRecipients.set('email1@school.edu, email2@school.edu'); + 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, 'admin@school.edu'); + assert.strictEqual(changeAlertRecipients, 'email1@school.edu, email2@school.edu'); + }); + await render( + hbs``, + ); + await component.administratorEmail.set('admin@school.edu'); + await component.changeAlertRecipients.set('email1@school.edu, email2@school.edu'); + await component.changeAlertRecipients.save(); + }); }); diff --git a/packages/frontend/tests/pages/components/school/emails-editor.js b/packages/frontend/tests/pages/components/school/emails-editor.js index 86c96280a5..c81d2b4fac 100644 --- a/packages/frontend/tests/pages/components/school/emails-editor.js +++ b/packages/frontend/tests/pages/components/school/emails-editor.js @@ -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]', @@ -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]', @@ -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' } }), }, });