diff --git a/cypress/integration/administration/TagsAndCategories.feature b/cypress/integration/administration/TagsAndCategories.feature index f8bce831b..813ff5d80 100644 --- a/cypress/integration/administration/TagsAndCategories.feature +++ b/cypress/integration/administration/TagsAndCategories.feature @@ -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 | - - - diff --git a/cypress/integration/common/admin.js b/cypress/integration/common/admin.js index 059e34b27..346fe64fb 100644 --- a/cypress/integration/common/admin.js +++ b/cypress/integration/common/admin.js @@ -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) }) })