Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function openIfClosedAndGetContentId(trigger) {
let contentId = trigger.attributes['aria-owns'] && `${trigger.attributes['aria-owns'].value}`;
let content = contentId ? document.querySelector(`#${contentId}`) : undefined;
// If the dropdown is closed, open it
if (!content || content.classList.contains('ember-basic-dropdown-content-placeholder')) {
await click(trigger);
await settled();
contentId = `${trigger.attributes['aria-owns'].value}`;
}
return contentId;
}
test('visiting /foo', async function(assert) {
await visit('/foo');
await click('#bar');
await click(findAll('.baz a')[12]);
assert.equal(currentURL(), '/foo');
});
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');
});
test('visiting /twiddles', async function(assert) {
await click('.foo');
await click('.foo');
await click('.foo');
assert.ok(true);
assert.ok(true);
});
export async function fillContentEditable(selector, content) {
click(selector);
$(selector).html(content);
triggerEvent(selector, 'keyup', 13);
triggerEvent(selector, 'blur');
}
export async function removeField(name) {
await click(`[data-test-field="${name}"] [data-test-field-renderer-remove-btn]`);
}
potentialTargets = document.querySelectorAll(`#${contentId} ${valueOrSelector}`);
}
if (potentialTargets.length > 1) {
let filteredTargets = [].slice.apply(potentialTargets).filter((t) => t.textContent.trim() === valueOrSelector);
if (optionIndex === undefined) {
target = filteredTargets[0] || potentialTargets[0];
} else {
target = filteredTargets[optionIndex] || potentialTargets[optionIndex];
}
} else {
target = potentialTargets[0];
}
if (!target) {
throw new Error(`You called "selectChoose('${cssPathOrTrigger}', '${valueOrSelector}')" but "${valueOrSelector}" didn't match any option`);
}
await click(target);
return settled();
}
export async function fillInFieldEditor(name, value) {
let editorSection = getFieldEditorSectionElement(name);
if (!editorSection) {
throw new Error(`Could not find editor section for field "${name}".`);
}
if (editorSection.classList.contains('closed')) {
await click(editorSection.querySelector(`header`));
}
if (typeof value === 'boolean') {
let toggle = editorSection.querySelector(`.cs-field-editor-section .cs-toggle-switch`);
if (!toggle) {
throw new Error(`Could not find toggle element in editor section for field "${name}".`);
}
let slider = toggle.querySelector('.slider');
if (!slider) {
throw new Error(`Could not find slider element in editor section for field "${name}".`);
}
let isEnabled = slider.classList.contains('slider-right');
if ((isEnabled && value === false) || (!isEnabled && value === true)) {
await click(slider);
assert.dialogOpensAndCloses = async function(options) {
const self = this;
await click(options.openSelector, options.context);
await waitUntil(function() {
return findContains(dialogSelector, options.dialogText);
});
if (options.hasOverlay) {
self.isPresentOnce(overlaySelector);
}
if (options.whileOpen) {
await options.whileOpen();
}
await click(options.closeSelector, options.context);
await waitUntil(function() {
return !findContains(dialogSelector, options.dialogText);
});
self.isAbsent(overlaySelector);
};
}
export async function clickTrigger(scope, options = {}) {
let selector = '.ember-power-select-trigger';
if (scope) {
selector = `${scope} ${selector}`;
}
return click(selector, options);
}