Skip to content

Commit

Permalink
e2e: Wait for "Create" link in beforeEach
Browse files Browse the repository at this point in the history
This should resolve the following failures:

- https://travis-ci.org/mbland/custom-links/jobs/260701744
- https://travis-ci.org/mbland/custom-links/jobs/260701972

This may also finally fix the flakiness observed in earlier builds, as
the problem was likely that the first `activeElement()` call came before
the expected element became active, considering that the view is set
by `loadApp()` some time after the DOMContentLoaded event. The hint was
the common failure message from both of the above builds:

```
 1) End-to-end test shows the no-links message before any links created:

      AssertionError: expected '| My links | New link | Log out\nCustom
Links' to deeply equal 'Create a new custom link'

      + expected - actual

      -| My links | New link | Log out
      -Custom Links
      +Create a new custom link
```
  • Loading branch information
mbland committed Aug 3, 2017
1 parent ff72cb6 commit 8ae29b1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/end-to-end/end-to-end.js
Expand Up @@ -43,7 +43,8 @@ test.describe('End-to-end test', function() {
})

test.beforeEach(function() {
return driver.get(url)
driver.get(url)
return waitForActiveLink('Create a new custom link')
})

test.afterEach(function() {
Expand Down Expand Up @@ -91,7 +92,6 @@ test.describe('End-to-end test', function() {
}

test.it('shows the no-links message before any links created', function() {
activeElement().getText().should.become('Create a new custom link')
activeElement().getAttribute('href').should.become(url + '#create')
activeElement().click()
driver.wait(until.urlIs(url + '#create'))
Expand All @@ -108,11 +108,14 @@ test.describe('End-to-end test', function() {
})

test.it('creates a new short link', function() {
// Rather than click on the active "Create a new custom link" link, let's
// make sure we can navigate to "New link" in the nav bar as expected.
activeElement().sendKeys(Key.chord(Key.SHIFT, Key.TAB))
activeElement().sendKeys(Key.chord(Key.SHIFT, Key.TAB))
activeElement().getText().should.become('New link')
activeElement().click()
driver.wait(until.urlIs(url + '#create'))

activeElement().sendKeys('foo' + Key.TAB)
activeElement().sendKeys(targetLocation + Key.TAB)
activeElement().sendKeys(Key.ENTER)
Expand Down

0 comments on commit 8ae29b1

Please sign in to comment.