Fix probably randomly failing cypress test

@mattwr18 @ulfgebhardt @tirokk @appinteractive @ogerly

I think I just fixed a randomly failing test (so-called "flaky" test).
After an update of `neo4j-graphql-js` I wondered why the
`TagsAndCategories.feature` test failed consistently. It turns out the
table that you can see in the test is ordered by the "Users" column:

|   | Name      | Users  | Posts    |
| 1 | Democracy | 2      | 3        |
| 2 | Ecology   | 1      | 1        |
| 3 | Nature    | 1      | 2        |

So there is a tie between row 2 and row 3. It seems that on version
2.4.0 the backend would return those rows in arbitrary order and now it
returns them in a deterministic order, thus failing the test every time.

Therefore I changed the test setup and I believe this should also make
the build more robust now.
This commit is contained in:
Robert Schäfer 2019-05-17 00:09:54 +02:00
parent 45c64db90f
commit a819d6353a
2 changed files with 15 additions and 4 deletions

View File

@ -32,6 +32,6 @@ Feature: Tags and Categories
And I click on the menu item "Tags"
Then I can see the following table:
| | Name | Users | Posts |
| 1 | Democracy | 2 | 3 |
| 2 | Ecology | 1 | 1 |
| 3 | Nature | 1 | 2 |
| 1 | Democracy | 3 | 4 |
| 2 | Nature | 2 | 3 |
| 3 | Ecology | 1 | 1 |

View File

@ -49,14 +49,23 @@ Given('we have a selection of tags and categories as well as posts', () => {
email: 'author@example.org',
password: '1234'
}
const yetAnotherAuthor = {
id: 'yetAnotherAuthor',
email: 'yet-another-author@example.org',
password: '1234'
}
cy.factory()
.create('User', someAuthor)
.authenticateAs(someAuthor)
.create('Post', { id: 'p0' })
.create('Post', { id: 'p1' })
cy.factory()
.authenticateAs(loginCredentials)
.create('User', yetAnotherAuthor)
.authenticateAs(yetAnotherAuthor)
.create('Post', { id: 'p2' })
cy.factory()
.authenticateAs(loginCredentials)
.create('Post', { id: 'p3' })
.relate('Post', 'Categories', { from: 'p0', to: 'cat1' })
.relate('Post', 'Categories', { from: 'p1', to: 'cat2' })
.relate('Post', 'Categories', { from: 'p2', to: 'cat1' })
@ -65,7 +74,9 @@ Given('we have a selection of tags and categories as well as posts', () => {
.relate('Post', 'Tags', { from: 'p0', to: 't3' })
.relate('Post', 'Tags', { from: 'p1', to: 't2' })
.relate('Post', 'Tags', { from: 'p1', to: 't3' })
.relate('Post', 'Tags', { from: 'p2', to: 't2' })
.relate('Post', 'Tags', { from: 'p2', to: 't3' })
.relate('Post', 'Tags', { from: 'p3', to: 't3' })
})
Given('we have the following user accounts:', table => {