Implement first scenario for categories

This commit is contained in:
Robert Schäfer 2018-12-12 18:58:35 +01:00
parent 6fc203003a
commit 96a30ca03e
3 changed files with 72 additions and 9 deletions

View File

@ -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 |

View File

@ -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)
})
})

View File

@ -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
}
})
}