Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function visit(url: string) {
try {
await _visit(url);
} catch (e) {
if (e.message !== 'TransitionAborted') {
throw e;
}
// Set this.element for application tests as the original
// visit's attempt to do so was interupted by an exception
const context: any = getContext();
context.element = document.querySelector('#ember-testing');
}
await settled();
}
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;
}
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();
}
const patchAjax = function patchAjax(url, method, status, response, responseTime) {
run(function() {
unhandled[url] = {response: response, responseTime: responseTime};
});
return settled();
}
export async function serviceWorkerUpdate() {
window.__hasServiceWorkerUpdate__deferred &&
window.__hasServiceWorkerUpdate__deferred.resolve &&
window.__hasServiceWorkerUpdate__deferred.resolve(true)
return await settled();
}
hooks.afterEach(function() {
return settled().then(() => {
if (this.server) {
this.server.shutdown();
delete this.server;
}
});
});
}
}
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 calendarCenter(selector, newCenter) {
assert('`calendarCenter` expect a Date object as second argument', newCenter instanceof Date);
let calendarComponent = findComponentInstance(selector);
let onCenterChange = calendarComponent.get('onCenterChange');
assert('You cannot call `calendarCenter` on a component that doesn\'t has an `@onCenterChange` action', !!onCenterChange);
let publicAPI = calendarComponent.get('publicAPI');
await run(() => publicAPI.actions.changeCenter(newCenter, publicAPI));
return settled();
}
await trigger(sourceItem, 'dragstart')
await trigger(targetList, 'dragenter')
await trigger(targetItem, 'dragover', above)
await trigger(sourceItem, 'dragend')
} else {
assert(
`target list is empty, the only available target index is 0, but target index ${targetIndex} was provided`,
!targetIndex
)
await trigger(sourceItem, 'dragstart')
await trigger(targetList, 'dragenter')
await trigger(sourceItem, 'dragend')
}
return settled()
}