Ghost/ghost/admin/tests/helpers/forms.js
Kevin Ansfield 524b23c182
Migrated staff user screen to Ember Octane patterns (#15532)
refs https://github.com/TryGhost/Ghost/issues/14101

- migrated staff user controller to native class syntax
- removed use of `{{action}}` helper
- moved from custom components to native `<input>` and `<textarea>` for form fields
  - added `{{select-on-click}}` modifier to cover the `<GhTextingInput @selectOnClick>` option behaviour for any input element
- added `submitForm()` test helper that finds closest `form` element and trigger's a `submit` event on it simulating <kbd>Enter</kbd> being pressed whilst a field has focus
2022-10-05 12:05:31 +01:00

11 lines
314 B
JavaScript

import {find, triggerEvent} from '@ember/test-helpers';
export async function submitForm(elementOrSelector) {
if (typeof elementOrSelector === 'string') {
elementOrSelector = find(elementOrSelector);
}
const form = elementOrSelector.closest('form');
await triggerEvent(form, 'submit');
}