Hopefully fix flaky tags and categories test

This commit is contained in:
Robert Schäfer 2019-04-03 21:40:24 +02:00
parent 5f684479f0
commit 6a356dd8b1
2 changed files with 12 additions and 40 deletions

View File

@ -21,8 +21,8 @@ Feature: Tags and Categories
Scenario: See an overview of categories
When I navigate to the administration dashboard
And I click on the menu item "Categories"
Then I can see a list of categories ordered by post count:
| Icon | Name | Posts |
Then I can see the following table:
| | Name | Posts |
| | Just For Fun | 2 |
| | Happyness & Values | 1 |
| | Health & Wellbeing | 0 |
@ -30,11 +30,8 @@ Feature: Tags and Categories
Scenario: See an overview of tags
When I navigate to the administration dashboard
And I click on the menu item "Tags"
Then I can see a list of tags ordered by user count:
| # | Name | Users | Posts |
Then I can see the following table:
| | Name | Users | Posts |
| 1 | Democracy | 2 | 3 |
| 2 | Ecology | 1 | 1 |
| 3 | Nature | 1 | 2 |

View File

@ -9,38 +9,13 @@ When('I navigate to the administration dashboard', () => {
.click()
})
Then('I can see a list of categories ordered by post count:', table => {
cy.get('thead')
.find('tr th')
.should('have.length', 3)
table.hashes().forEach(({ Name, Posts }, index) => {
cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(2)`).should(
'contain',
Name.trim()
)
cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(3)`).should(
'contain',
Posts
)
})
})
Then('I can see a list of tags ordered by user count:', table => {
cy.get('thead')
.find('tr th')
.should('have.length', 4)
table.hashes().forEach(({ Name, Users, Posts }, index) => {
cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(2)`).should(
'contain',
Name.trim()
)
cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(3)`).should(
'contain',
Users
)
cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(4)`).should(
'contain',
Posts
)
Then('I can see the following table:', table => {
const headers = table.raw()[0]
headers.forEach((expected, i) => {
cy.get('thead th').eq(i).should('contain', expected)
})
const flattened = [].concat.apply([], table.rows())
flattened.forEach((expected, i) => {
cy.get('tbody td').eq(i).should('contain', expected)
})
})