From a819d6353a00df75587ca77bec3fa5baa4d7f594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 17 May 2019 00:09:54 +0200 Subject: [PATCH] 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. --- .../administration/TagsAndCategories.feature | 6 +++--- cypress/integration/common/steps.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cypress/integration/administration/TagsAndCategories.feature b/cypress/integration/administration/TagsAndCategories.feature index 813ff5d80..e55535ea9 100644 --- a/cypress/integration/administration/TagsAndCategories.feature +++ b/cypress/integration/administration/TagsAndCategories.feature @@ -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 | diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 0be3f882f..387f33ac0 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -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 => {