How to use the @ember/test-helpers.click function in @ember/test-helpers

To help you get started, we’ve selected a few @ember/test-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cibernox / ember-power-select / addon-test-support / index.js View on Github external
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;
}
github ember-codemods / ember-test-helpers-codemod / transforms / acceptance / __testfixtures__ / click.output.js View on Github external
test('visiting /foo', async function(assert) {
  await visit('/foo');

  await click('#bar');
  await click(findAll('.baz a')[12]);
  assert.equal(currentURL(), '/foo');
});
github ember-codemods / ember-test-helpers-codemod / transforms / native-dom / __testfixtures__ / integration.output.js View on Github external
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');
});
github ember-codemods / ember-test-helpers-codemod / transforms / acceptance / __testfixtures__ / nested-in-and-then.output.js View on Github external
test('visiting /twiddles', async function(assert) {
  await click('.foo');

  await click('.foo');

  await click('.foo');

  assert.ok(true);

  assert.ok(true);
});
github st-h / ember-content-editable / tests / helpers / fill-content-editable.js View on Github external
export async function fillContentEditable(selector, content) {
  click(selector);
  $(selector).html(content);
  triggerEvent(selector, 'keyup', 13);
  triggerEvent(selector, 'blur');
}
github cardstack / cardstack / packages / test-support / addon-test-support / card-ui-helpers.js View on Github external
export async function removeField(name) {
  await click(`[data-test-field="${name}"] [data-test-field-renderer-remove-btn]`);
}
github cibernox / ember-power-select / addon-test-support / index.js View on Github external
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();
}
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
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);
github yapplabs / ember-modal-dialog / tests / helpers / modal-asserts.js View on Github external
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);
  };
}
github cibernox / ember-power-select / addon-test-support / helpers.js View on Github external
export async function clickTrigger(scope, options = {}) {
  let selector = '.ember-power-select-trigger';
  if (scope) {
    selector = `${scope} ${selector}`;
  }
  return click(selector, options);
}