From 96a30ca03e1d0da2116ac2c3bf49b2e37aa22140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 12 Dec 2018 18:58:35 +0100 Subject: [PATCH] Implement first scenario for categories --- cypress/integration/TagsAndCategories.feature | 42 +++++++++++++++++++ cypress/integration/common/steps.js | 32 +++++++++++++- cypress/plugins/index.js | 7 ---- 3 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 cypress/integration/TagsAndCategories.feature diff --git a/cypress/integration/TagsAndCategories.feature b/cypress/integration/TagsAndCategories.feature new file mode 100644 index 000000000..7655893e5 --- /dev/null +++ b/cypress/integration/TagsAndCategories.feature @@ -0,0 +1,42 @@ +Feature: Tags and Categories + As a database administrator + I would like to see a summary of all tags and categories and their usage + In order to be able to decide which tags and categories are popular or not + + The currently deployed application, codename "Alpha", distinguishes between + categories and tags. Each post can have a number of categories and/or tags. + A few categories are required for each post, tags are completely optional. + Both help to find relevant posts in the database, e.g. users can filter for + categories. + + If administrators summary of all tags and categories and how often they are + used, they learn what new category might be convenient for users, e.g. by + looking at the popularity of a tag. + + Background: + Given we have a selection of tags and categories as well as posts + And my user account has the role "administrator" + + @focus + Scenario: See an overview of categories + Given I am logged in + When I navigate to the administration dashboard + And I click on "Categories" + Then I can see a list of categories ordered by post count: + | Icon | Name | Post Count | + | | Just For Fun | 5 | + | | Happyness & Values | 2 | + | | Health & Wellbeing | 1 | + + Scenario: See an overview of tags + When I navigate to the administration dashboard + And I click on "Tags" + Then I can see a list of categories ordered by post count: + | # | Name | Nutzer | Beiträge | + | 1 | Naturschutz | 2 | 2 | + | 2 | Freiheit | 2 | 2 | + | 3 | Umwelt | 1 | 1 | + | 4 | Demokratie | 1 | 1 | + + + diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 611636040..5474475ab 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -26,8 +26,16 @@ Given('I am logged in', () => { login('admin@example.org', 1234) }) -Given('my account has the following details:', table => { - // as long as we rely on seed data, this is only documentation +Given('we have a selection of tags and categories as well as posts', () => { + // TODO: use db factories instead of seed data +}) + +Given('my account has the following details:', (table) => { + // TODO: use db factories instead of seed data +}) + +Given('my user account has the role {string}', (role) => { + // TODO: use db factories instead of seed data }) When('I log out', logout) @@ -71,3 +79,23 @@ Then('I am still logged in', () => { cy.get('.avatar-menu').click() cy.get('.avatar-menu-popover').contains(username) }) + +When('I navigate to the administration dashboard', () => { + cy.get('.avatar-menu').click() + cy.get('a').contains('Systemverwaltung').click() +}) + +When(`I click on {string}`, (link) => { + cy.contains(link).click() +}) + +Then('I can see a list of categories ordered by post count:', (table) => { + // TODO: match the table in the feature with the html table + cy.get('thead').find('tr th').should('have.length', 3) + const last_column = cy.get('tbody').find('tr td:last-child').then((last_column) => { + cy.wrap(last_column) + const values = last_column.map((i, td) => parseInt(td.textContent)).toArray() + const ordered_descending = values.slice(0).sort((a,b) => b - a) + return cy.wrap(values).should('deep.eq', ordered_descending) + }) +}) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 788e74365..4ec4addb3 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -17,11 +17,4 @@ module.exports = on => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config on('file:preprocessor', cucumber()) - - on('task', { - log() { - console.log(arguments) - return null - } - }) }