Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Implement non-promise eval.code #17

Closed
timsuchanek opened this issue Jul 20, 2017 · 0 comments
Closed

Implement non-promise eval.code #17

timsuchanek opened this issue Jul 20, 2017 · 0 comments

Comments

@timsuchanek
Copy link
Contributor

timsuchanek commented Jul 20, 2017

Currently it's not a nice experience when you want to evaluate code, but continue with the method chain. This is an example of tests that I implemented with chromeless. Here it gets pretty clear, that we should have a variant of eval.code that returns the Chromeless instance. One possibility would be to call it directly .code()

export default async (cookies: any[]): Promise<any> => {

  const chromeless = new Chromeless({
    runRemote,
    waitTimeout,
    viewport,
  })

  await chromeless
    .cookies.set(cookies)
    .goto(CONSOLE_URL)
    .wait(3200)
    .wait('a[data-test="sidenav-databrowser"]')
    .click('a[data-test="sidenav-databrowser"]')
    .wait(2200)
    .wait('a[data-test="sidenav-databrowser-model-Post"]')
    .click('a[data-test="sidenav-databrowser-model-Post"]')
    .wait(2200)
    .click('div[class^="NewRowInactive__add"]')
    .type('test url')
    .eval.code(() => document.querySelector('div[data-test="new-row-cell-imageUrl"] input').blur())

  await chromeless
    .click('div[data-test="new-row-cell-description"] > div > div')
    .wait(400)
    .wait('div[data-test="new-row-cell-description"] input')
    .type('some description', 'div[data-test="new-row-cell-description"] input')
    .eval.code(() => document.querySelector('div[data-test="new-row-cell-description"] input').blur())

  await chromeless
    .wait(700)
    .click('button[data-test="add-node"]')
    .wait(300)
    .click('div[data-test="edit-field-imageUrl"]')
    .click('div[data-test="cell-imageUrl"]')
    .type('123')
    .eval.code(() => document.querySelector('input').focus())

  return chromeless
    .press(13)
    .wait(400)
    .click('div[data-test="checkbox-row-0"]')
    .wait(400)
    .click('div[data-test="delete-button"]')
    .wait(400)
    .click('div.button.warning')
    .end()
}

If you're interested in more test examples, here are our console tests: https://github.com/graphcool/console/tree/dev/integration-tests/src/tests

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants