Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
trigger.scrollIntoView();
}
let isMultipleSelect = !!trigger.querySelector('.ember-power-select-trigger-multiple-input');
let contentId = await openIfClosedAndGetContentId(trigger);
let isDefaultSingleSelect = !!document.querySelector('.ember-power-select-search-input');
if (isMultipleSelect) {
await fillIn(trigger.querySelector('.ember-power-select-trigger-multiple-input'), value);
} else if (isDefaultSingleSelect) {
await fillIn('.ember-power-select-search-input', value);
} else { // It's probably a customized version
let inputIsInTrigger = !!trigger.querySelector('.ember-power-select-trigger input[type=search]');
if (inputIsInTrigger) {
await fillIn(trigger.querySelector('input[type=search]'), value);
} else {
await fillIn(`#${contentId} .ember-power-select-search-input[type=search]`, 'input');
}
}
return settled();
}
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await click('.foo');
assert.equal(this.element.querySelector('.foo').id, 'foo');
await fillIn('.foo input', 'bar');
await blur('.foo input');
assert.equal(this.element.querySelector('.foo').textContent.trim(), 'foo');
});
test('visiting /foo', async function(assert) {
await visit('/foo');
await fillIn('#bar', 'baz');
await fillIn(this.element.querySelectorAll('#qux input')[5], 'qaaz');
assert.equal(currentURL(), '/foo');
});
export async function login(assert, email = null, password = null, gotoLoginPage = true) {
if (gotoLoginPage) {
await visit('/login');
}
assert.equal(currentURL(), '/login');
await fillIn('input[name=email]', email !== null ? email : 'opev-fe@test.com');
await fillIn('input[name=password]', password !== null ? password : 'test-fe-user');
await click('button[type=submit]');
await settled();
}
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await click('.foo', {});
assert.equal(find('.foo').id, 'foo');
await fillIn('.foo input', 'bar');
await blur('.foo input');
assert.equal(find('.foo').textContent.trim(), 'foo');
});
await tap('.message');
await focus('.message');
await blur('.message');
await triggerEvent('.message', 'custom-event');
await triggerKeyEvent('.message', 'keydown', 'Enter', { ctrlKey: true });
await fillIn('.message', 'content');
const messageElement = find('.message')!;
await click(messageElement);
await doubleClick(messageElement);
await tap(messageElement);
await focus(messageElement);
await blur(messageElement);
await triggerEvent(messageElement, 'custom-event');
await triggerKeyEvent(messageElement, 'keydown', 'Enter', { ctrlKey: true });
await fillIn(messageElement, 'content');
await typeIn(messageElement, 'content');
const allMessages = findAll('.message');
for (const element of allMessages) {
await click(element);
}
const root = getRootElement();
await click(root);
});
async function fillInHelper(value) {
await fillIn('.foo input', value);
await triggerEvent('.foo input', 'change');
}
export async function setFieldValue(name, value) {
let type = find(`[data-test-field="${name}"]`).getAttribute('data-test-field-type');
if (type === '@cardstack/core-types::boolean') {
if (value) {
await click(`[data-test-field="${name}"] .cardstack-core-types-field-value-true`);
} else {
await click(`[data-test-field="${name}"] .cardstack-core-types-field-value-false`);
}
} else if (type === '@cardstack/core-types::has-many' && Array.isArray(value)) {
await fillIn(`#edit-${name}-field-value`, value.join(','));
await triggerEvent(`#edit-${name}-field-value`, 'keyup');
} else {
await fillIn(`#edit-${name}-field-value`, value);
await triggerEvent(`#edit-${name}-field-value`, 'keyup');
}
}
async write(input, value) {
await fillIn(input.querySelector('input'), value);
}
};