From a024282f757e3bcebf0557bef82df499959ca344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Thu, 21 Feb 2019 22:08:37 +0100 Subject: [PATCH 01/10] Implement first cucumber features with factories --- .gitignore | 1 + cypress.env.template.json | 5 ++++ cypress/integration/06.WritePost.feature | 2 +- cypress/integration/common/steps.js | 23 +++++++++++++----- cypress/support/factories.js | 30 ++++++++++++++++++++++++ cypress/support/index.js | 1 + 6 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 cypress.env.template.json create mode 100644 cypress/support/factories.js diff --git a/.gitignore b/.gitignore index 0de8272fc..52fe4effc 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,4 @@ static/uploads cypress/videos cypress/screenshots/ +cypress.env.json diff --git a/cypress.env.template.json b/cypress.env.template.json new file mode 100644 index 000000000..59cf04ab6 --- /dev/null +++ b/cypress.env.template.json @@ -0,0 +1,5 @@ +{ + "NEO4J_URI": "bolt://localhost:7687", + "NEO4J_USERNAME": "neo4j", + "NEO4J_PASSWORD": "letmein" +} diff --git a/cypress/integration/06.WritePost.feature b/cypress/integration/06.WritePost.feature index e889a4783..a9cb81ff9 100644 --- a/cypress/integration/06.WritePost.feature +++ b/cypress/integration/06.WritePost.feature @@ -5,7 +5,7 @@ Feature: Create a post Background: Given I am logged in - Given I am on the "landing" page + And I am on the "landing" page Scenario: Create a post When I click on the big plus icon in the bottom right corner to create post diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index fadee974b..fcc2c2789 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -6,9 +6,18 @@ import users from '../../fixtures/users.json' let lastPost = { } +let loginCredentials Given('I am logged in', () => { - cy.loginAs('admin') + loginCredentials = { + email: 'admin@example.org', + password: '1234', + } + cy.factory().create('user', { + role: 'admin', + ...loginCredentials + }) + cy.login('admin@example.org', '1234') }) Given('I am logged in as {string}', userType => { cy.loginAs(userType) @@ -112,7 +121,9 @@ When('I click on the big plus icon in the bottom right corner to create post', ( }) Given('I previously created a post', () => { - // TODO: create a post in the database + cy.factory() + .authenticateAs(loginCredentials) + .create('post', lastPost) }) When('I choose {string} as the title of the post', (title) => { @@ -121,15 +132,15 @@ When('I choose {string} as the title of the post', (title) => { }) When('I type in the following text:', (text) => { - lastPost.text = text.replace('\n', ' ') - cy.get('.ProseMirror').type(lastPost.text) + lastPost.content = text.replace('\n', ' ') + cy.get('.ProseMirror').type(lastPost.content) }) Then('the post shows up on the landing page at position {int}', (index) => { cy.openPage('landing') const selector = `:nth-child(${index}) > .ds-card > .ds-card-content` cy.get(selector).should('contain', lastPost.title) - cy.get(selector).should('contain', lastPost.text) + cy.get(selector).should('contain', lastPost.content) }) Then('I get redirected to {string}', (route) => { @@ -138,5 +149,5 @@ Then('I get redirected to {string}', (route) => { Then('the post was saved successfully', () => { cy.get('.ds-card-header > .ds-heading').should('contain', lastPost.title) - cy.get('.content').should('contain', lastPost.text) + cy.get('.content').should('contain', lastPost.content) }) diff --git a/cypress/support/factories.js b/cypress/support/factories.js new file mode 100644 index 000000000..c56f6bf27 --- /dev/null +++ b/cypress/support/factories.js @@ -0,0 +1,30 @@ +// TODO: find a better way how to import the factories +import Factory from '../../../Nitro-Backend/src/seed/factories' +import { getDriver } from '../../../Nitro-Backend/src/bootstrap/neo4j' + +const neo4jDriver = getDriver({ + uri: Cypress.env('NEO4J_URI'), + username: Cypress.env('NEO4J_USERNAME'), + password: Cypress.env('NEO4J_PASSWORD') +}) +const factory = Factory({neo4jDriver}) + +beforeEach(async () => { + await factory.cleanDatabase({ neo4jDriver }) +}) + +Cypress.Commands.add('factory', (node, relationship, properties) => { + return Factory() +}) + +Cypress.Commands.add('create', { prevSubject: true }, (factory, node, properties) => { + return factory.create(node, properties) +}) + +Cypress.Commands.add('relate', { prevSubject: true }, (factory, node, relationship, properties) => { + return factory.relate(node, relationship, properties) +}) + +Cypress.Commands.add('authenticateAs', { prevSubject: true }, (factory, node, relationship, properties) => { + return factory.authenticateAs(node, relationship, properties) +}) diff --git a/cypress/support/index.js b/cypress/support/index.js index d68db96df..3519487bf 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -15,6 +15,7 @@ // Import commands.js using ES2015 syntax: import './commands' +import './factories' // Alternatively you can use CommonJS syntax: // require('./commands') From 5e0d245b40e2f4e98a3cf61ad85d7af82020606d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Thu, 21 Feb 2019 23:37:53 +0100 Subject: [PATCH 02/10] Implemented most cucumber features with factories --- cypress/integration/01.Login.feature | 6 +- .../integration/03.TagsAndCategories.feature | 6 +- .../integration/04.AboutMeAndLocation.feature | 12 ++-- cypress/integration/06.WritePost.feature | 3 +- cypress/integration/common/settings.js | 27 ++------ cypress/integration/common/steps.js | 64 +++++++++++++------ cypress/support/commands.js | 11 +--- cypress/support/factories.js | 6 +- 8 files changed, 65 insertions(+), 70 deletions(-) diff --git a/cypress/integration/01.Login.feature b/cypress/integration/01.Login.feature index 72adc8553..3837f7042 100644 --- a/cypress/integration/01.Login.feature +++ b/cypress/integration/01.Login.feature @@ -4,11 +4,7 @@ Feature: Authentication In order to attribute posts and other contributions to their authors Background: - Given my account has the following details: - | name | email | password | type - | Peter Lustig | admin@example.org | 1234 | Admin - | Bob der Bausmeister | moderator@example.org | 1234 | Moderator - | Jenny Rostock" | user@example.org | 1234 | User + Given I have a user account Scenario: Log in When I visit the "/login" page diff --git a/cypress/integration/03.TagsAndCategories.feature b/cypress/integration/03.TagsAndCategories.feature index f9509e858..050fb3643 100644 --- a/cypress/integration/03.TagsAndCategories.feature +++ b/cypress/integration/03.TagsAndCategories.feature @@ -14,9 +14,9 @@ Feature: Tags and Categories 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" - Given I am logged in + Given my user account has the role "admin" + And we have a selection of tags and categories as well as posts + And I am logged in Scenario: See an overview of categories When I navigate to the administration dashboard diff --git a/cypress/integration/04.AboutMeAndLocation.feature b/cypress/integration/04.AboutMeAndLocation.feature index aedbf62bc..2a512bf3f 100644 --- a/cypress/integration/04.AboutMeAndLocation.feature +++ b/cypress/integration/04.AboutMeAndLocation.feature @@ -7,21 +7,18 @@ Feature: About me and location to search for users by location. Background: - Given I am logged in + Given I have a user account + And I am logged in And I am on the "settings" page Scenario: Change username When I save "Hansi" as my new name Then I can see my new name "Hansi" when I click on my profile picture in the top right - - Scenario: Keep changes after refresh - When I changed my username to "Hansi" previously - And I refresh the page - Then my new username is still there + And when I refresh the page + Then the name "Hansi" is still there Scenario Outline: I set my location to "" When I save "" as my location - And my username is "Peter Lustig" When people visit my profile page Then they can see the location in the info box below my avatar @@ -36,6 +33,5 @@ Feature: About me and location """ Ich lebe fettlos, fleischlos, fischlos dahin, fühle mich aber ganz wohl dabei """ - And my username is "Peter Lustig" When people visit my profile page Then they can see the text in the info box below my avatar diff --git a/cypress/integration/06.WritePost.feature b/cypress/integration/06.WritePost.feature index a9cb81ff9..0193e44bf 100644 --- a/cypress/integration/06.WritePost.feature +++ b/cypress/integration/06.WritePost.feature @@ -4,7 +4,8 @@ Feature: Create a post To say something to everyone in the community Background: - Given I am logged in + Given I have a user account + And I am logged in And I am on the "landing" page Scenario: Create a post diff --git a/cypress/integration/common/settings.js b/cypress/integration/common/settings.js index b7b283e2b..9f74a1200 100644 --- a/cypress/integration/common/settings.js +++ b/cypress/integration/common/settings.js @@ -4,7 +4,6 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps' let aboutMeText let myLocation -let myName const matchNameInUserMenu = name => { cy.get('.avatar-menu').click() // open @@ -12,18 +11,13 @@ const matchNameInUserMenu = name => { cy.get('.avatar-menu').click() // close again } -const setUserName = name => { +When('I save {string} as my new name', name => { cy.get('input[id=name]') .clear() .type(name) cy.get('[type=submit]') .click() .not('[disabled]') - myName = name -} - -When('I save {string} as my new name', name => { - setUserName(name) }) When('I save {string} as my location', location => { @@ -47,31 +41,20 @@ When('I have the following self-description:', text => { aboutMeText = text }) -When('my username is {string}', name => { - if (myName !== name) { - setUserName(name) - } - matchNameInUserMenu(name) -}) - When('people visit my profile page', url => { - cy.visitMyProfile() + cy.openPage('/profile/peter-pan') }) When('they can see the text in the info box below my avatar', () => { cy.contains(aboutMeText) }) -When('I changed my username to {string} previously', name => { - myName = name -}) - Then('they can see the location in the info box below my avatar', () => { - matchNameInUserMenu(myName) + cy.contains(myLocation) }) -Then('my new username is still there', () => { - matchNameInUserMenu(myName) +Then('the name {string} is still there', (name) => { + matchNameInUserMenu(name) }) Then( diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index fcc2c2789..a00dd5d8f 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -1,38 +1,64 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' import { getLangByName } from '../../support/helpers' -import users from '../../fixtures/users.json' /* global cy */ let lastPost = { } -let loginCredentials + +const loginCredentials = { + email: 'peterpan@example.org', + password: '1234', +} +const narratorParams = { + name: "Peter Pan", + ...loginCredentials +} Given('I am logged in', () => { - loginCredentials = { - email: 'admin@example.org', - password: '1234', - } - cy.factory().create('user', { - role: 'admin', - ...loginCredentials - }) - cy.login('admin@example.org', '1234') + cy.login(loginCredentials) }) Given('I am logged in as {string}', userType => { cy.loginAs(userType) }) Given('we have a selection of tags and categories as well as posts', () => { - // TODO: use db factories instead of seed data + cy.factory() + .authenticateAs(loginCredentials) + .create('category', { id: 'cat1', name: 'Just For Fun', slug: 'justforfun', icon: 'smile' }) + .create('category', { id: 'cat2', name: 'Happyness & Values', slug: 'happyness-values', icon: 'heart-o' }) + .create('category', { id: 'cat3', name: 'Health & Wellbeing', slug: 'health-wellbeing', icon: 'medkit' }) + .create('tag', { id: 't1', name: 'Ecology' }) + .create('tag', { id: 't2', name: 'Nature' }) + .create('tag', { id: 't3', name: 'Democracy' }) + .create('post', { id: 'p0' }) + .create('post', { id: 'p1' }) + .create('post', { id: 'p2' }) + .relate('post', 'Categories', { from: 'p0', to: 'cat1' }) + .relate('post', 'Categories', { from: 'p1', to: 'cat2' }) + .relate('post', 'Categories', { from: 'p2', to: 'cat3' }) + .relate('post', 'Tags', { from: 'p0', to: 't1' }) + .relate('post', 'Tags', { from: 'p0', to: 't2' }) + .relate('post', 'Tags', { from: 'p0', to: 't3' }) + .relate('post', 'Tags', { from: 'p1', to: 't1' }) + .relate('post', 'Tags', { from: 'p1', to: 't2' }) }) -Given('my account has the following details:', table => { - // TODO: use db factories instead of seed data +Given('we have the following user accounts:', table => { + table.hashes().forEach((params) => { + cy.factory().create('user', params) + }) +}) + +Given('I have a user account', () => { + cy.factory().create('user', narratorParams) }) Given('my user account has the role {string}', role => { - // TODO: use db factories instead of seed data + cy.factory().create('user', { + role, + ...loginCredentials + }) }) When('I log out', cy.logout) @@ -46,10 +72,10 @@ Given('I am on the {string} page', page => { }) When('I fill in my email and password combination and click submit', () => { - cy.login('admin@example.org', 1234) + cy.login(loginCredentials) }) -When('I refresh the page', () => { +When(/(?:when )?I refresh the page/, () => { cy.reload() }) @@ -61,7 +87,7 @@ When('I log out through the menu in the top right corner', () => { }) Then('I can see my name {string} in the dropdown menu', () => { - cy.get('.avatar-menu-popover').should('contain', users.admin.name) + cy.get('.avatar-menu-popover').should('contain', narratorParams.name) }) Then('I see the login screen again', () => { @@ -75,7 +101,7 @@ Then('I can click on my profile picture in the top right corner', () => { Then('I am still logged in', () => { cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover').contains(users.admin.name) + cy.get('.avatar-menu-popover').contains(narratorParams.name) }) When('I select {string} in the language menu', name => { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index ebbd6acd1..30b7745cd 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -35,14 +35,7 @@ Cypress.Commands.add('switchLanguage', (name, force) => { } }) -Cypress.Commands.add('visitMyProfile', () => { - cy.get('.avatar-menu').click() - cy.get('.avatar-menu-popover') - .find('a[href^="/profile/"]') - .click() -}) - -Cypress.Commands.add('login', (email, password) => { +Cypress.Commands.add('login', ({email, password}) => { cy.visit(`/login`) cy.get('input[name=email]') .trigger('focus') @@ -58,7 +51,7 @@ Cypress.Commands.add('login', (email, password) => { Cypress.Commands.add('loginAs', role => { role = role || 'admin' - cy.login(users[role].email, users[role].password) + cy.login(users[role]) }) Cypress.Commands.add('logout', (email, password) => { diff --git a/cypress/support/factories.js b/cypress/support/factories.js index c56f6bf27..1c4515737 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -13,7 +13,7 @@ beforeEach(async () => { await factory.cleanDatabase({ neo4jDriver }) }) -Cypress.Commands.add('factory', (node, relationship, properties) => { +Cypress.Commands.add('factory', () => { return Factory() }) @@ -25,6 +25,6 @@ Cypress.Commands.add('relate', { prevSubject: true }, (factory, node, relationsh return factory.relate(node, relationship, properties) }) -Cypress.Commands.add('authenticateAs', { prevSubject: true }, (factory, node, relationship, properties) => { - return factory.authenticateAs(node, relationship, properties) +Cypress.Commands.add('authenticateAs', { prevSubject: true }, (factory, loginCredentials) => { + return factory.authenticateAs(loginCredentials) }) From 233c6abbab1662043ab2d75cd800ff89915a7cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 22 Feb 2019 00:08:01 +0100 Subject: [PATCH 03/10] Refactor most of report cucumber feature --- cypress/integration/05.ReportContent.feature | 8 +-- cypress/integration/common/report.js | 56 +++++++++++++------- cypress/integration/common/steps.js | 18 ++++--- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature index fbfdfe8de..25f5aec94 100644 --- a/cypress/integration/05.ReportContent.feature +++ b/cypress/integration/05.ReportContent.feature @@ -9,13 +9,13 @@ Feature: Report and Moderate Background: Given we have the following posts in our database: - | Author | Title | Content | Slug | - | David Irving | The Truth about the Holocaust | It never existed! | the-truth-about-the-holocaust | + | Author | title | content | + | David Irving | The Truth about the Holocaust | It never existed! | Scenario Outline: Report a post from various pages Given I am logged in with a "user" role - And I see David Irving's post on the - When I click on "Report Contribution" from the triple dot menu of the post + When I see David Irving's post on the + And I click on "Report Contribution" from the triple dot menu of the post And I confirm the reporting dialog because it is a criminal act under German law: """ Do you really want to report the contribution "The Truth about the Holocaust"? diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 812b0d751..4131ade78 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -3,9 +3,9 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' /* global cy */ let lastReportTitle -let dummyReportedPostTitle = 'Hacker, Freaks und Funktionäre' -let dummyReportedPostSlug = 'hacker-freaks-und-funktionareder-ccc' -let dummyAuthorName = 'Jenny Rostock' +let davidIrvingPostTitle = 'The Truth about the Holocaust' +let davidIrvingPostSlug = 'the-truth-about-the-holocaust' +let davidIrvingName = 'David Irving' const savePostTitle = $post => { return $post @@ -23,21 +23,27 @@ Given("I see David Irving's post on the landing page", page => { }) Given("I see David Irving's post on the post page", page => { - cy.visit(`/post/${dummyReportedPostSlug}`) - cy.contains(dummyReportedPostTitle) // wait + cy.visit(`/post/${davidIrvingPostSlug}`) + cy.contains(davidIrvingPostTitle) // wait }) Given('I am logged in with a {string} role', role => { - cy.loginAs(role) + cy.factory().create('user', { + email: `${role}@example.org`, + password: '1234', + role + }) + cy.login({ + email: `${role}@example.org`, + password: '1234', + }) }) When( 'I click on "Report Contribution" from the triple dot menu of the post', () => { - //TODO: match the created post title, not a dummy post title - cy.contains('.ds-card', dummyReportedPostTitle) + cy.contains('.ds-card', davidIrvingPostTitle) .find('.content-menu-trigger') - .find(':nth-child(2)') .click() cy.get('.popover .ds-menu-item-link') @@ -49,8 +55,7 @@ When( When( 'I click on "Report User" from the triple dot menu in the user info box', () => { - //TODO: match the created post author, not a dummy author - cy.contains('.ds-card', dummyAuthorName) + cy.contains('.ds-card', davidIrvingName) .find('.content-menu-trigger') .first() .click() @@ -111,7 +116,7 @@ When(/^I confirm the reporting dialog .*:$/, () => { //TODO: match the right post const message = 'Do you really want to report the' cy.contains(message) // wait for element to become visible - //TODO: cy.get('.ds-modal').contains(dummyReportedPostTitle) + //TODO: cy.get('.ds-modal').contains(davidIrvingPostTitle) cy.get('.ds-modal').within(() => { cy.get('button') .contains('Send Report') @@ -120,22 +125,37 @@ When(/^I confirm the reporting dialog .*:$/, () => { }) Given('somebody reported the following posts:', table => { - table.hashes().forEach(row => { - //TODO: calll factory here - // const options = Object.assign({}, row, { reported: true }) - //create('post', options) + table.hashes().forEach(({slug}, index) => { + const author = { + id: `author${index}`, + email: `author${index}@example.org`, + password: '1234' + } + const reporter = { + id: `reporter${index}`, + email: `reporter${index}@example.org`, + password: '1234' + } + cy.factory() + .create('user', author) + .authenticateAs(author) + .create('post', { id: `p${index}` }) + cy.factory() + .create('user', reporter) + .authenticateAs(reporter) + .create('report', { description: 'I don\'t like this post', resource: { id: `p${index}`, type: 'post' } }) }) }) Then('I see all the reported posts including the one from above', () => { //TODO: match the right post cy.get('table tbody').within(() => { - cy.contains('tr', dummyReportedPostTitle) + cy.contains('tr', davidIrvingPostTitle) }) }) Then('each list item links to the post page', () => { //TODO: match the right post - cy.contains(dummyReportedPostTitle).click() + cy.contains(davidIrvingPostTitle).click() cy.location('pathname').should('contain', '/post') }) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index a00dd5d8f..dc183fa87 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -18,9 +18,6 @@ const narratorParams = { Given('I am logged in', () => { cy.login(loginCredentials) }) -Given('I am logged in as {string}', userType => { - cy.loginAs(userType) -}) Given('we have a selection of tags and categories as well as posts', () => { cy.factory() @@ -128,9 +125,18 @@ When('I press {string}', label => { }) Given('we have the following posts in our database:', table => { - table.hashes().forEach(row => { - //TODO: calll factory here - //create('post', row) + table.hashes().forEach(({Author, title, content}) => { + cy.factory() + .create('user', { + name: Author, + email: `${Author}@example.org`, + password: '1234' + }) + .authenticateAs({ + email: `${Author}@example.org`, + password: '1234' + }) + .create('post', { title, content }) }) }) From 1e219934d289c81140ba26e434de1e5579c17e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 22 Feb 2019 00:11:34 +0100 Subject: [PATCH 04/10] Obsolete cypress command --- cypress/support/commands.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 30b7745cd..a2f52fd91 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -49,11 +49,6 @@ Cypress.Commands.add('login', ({email, password}) => { cy.location('pathname').should('eq', '/') // we're in! }) -Cypress.Commands.add('loginAs', role => { - role = role || 'admin' - cy.login(users[role]) -}) - Cypress.Commands.add('logout', (email, password) => { cy.visit(`/logout`) cy.location('pathname').should('contain', '/login') // we're out From 459b582fb4c977a5d7516e8aa193c728fffbbe93 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Sun, 24 Feb 2019 17:14:06 +0100 Subject: [PATCH 05/10] Fixed some linting issues --- components/ContributionForm.vue | 4 +- cypress/integration/common/report.js | 25 +++++----- cypress/integration/common/settings.js | 2 +- cypress/integration/common/steps.js | 67 ++++++++++++++++---------- cypress/support/commands.js | 2 +- cypress/support/factories.js | 32 ++++++++---- 6 files changed, 82 insertions(+), 50 deletions(-) diff --git a/components/ContributionForm.vue b/components/ContributionForm.vue index 8e96c35fe..cf7c28ece 100644 --- a/components/ContributionForm.vue +++ b/components/ContributionForm.vue @@ -29,7 +29,7 @@ ghost @click.prevent="$router.back()" > - {{ $t('actions.cancel') }} + {{ $t('actions.cancel') }} - {{ $t('actions.save') }} + {{ $t('actions.save') }} diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 4131ade78..0b0d3f253 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -35,7 +35,7 @@ Given('I am logged in with a {string} role', role => { }) cy.login({ email: `${role}@example.org`, - password: '1234', + password: '1234' }) }) @@ -125,16 +125,16 @@ When(/^I confirm the reporting dialog .*:$/, () => { }) Given('somebody reported the following posts:', table => { - table.hashes().forEach(({slug}, index) => { - const author = { - id: `author${index}`, - email: `author${index}@example.org`, - password: '1234' + table.hashes().forEach(({ slug }, index) => { + const author = { + id: `author${index}`, + email: `author${index}@example.org`, + password: '1234' } - const reporter = { - id: `reporter${index}`, - email: `reporter${index}@example.org`, - password: '1234' + const reporter = { + id: `reporter${index}`, + email: `reporter${index}@example.org`, + password: '1234' } cy.factory() .create('user', author) @@ -143,7 +143,10 @@ Given('somebody reported the following posts:', table => { cy.factory() .create('user', reporter) .authenticateAs(reporter) - .create('report', { description: 'I don\'t like this post', resource: { id: `p${index}`, type: 'post' } }) + .create('report', { + description: "I don't like this post", + resource: { id: `p${index}`, type: 'post' } + }) }) }) diff --git a/cypress/integration/common/settings.js b/cypress/integration/common/settings.js index 9f74a1200..3aa6022a8 100644 --- a/cypress/integration/common/settings.js +++ b/cypress/integration/common/settings.js @@ -53,7 +53,7 @@ Then('they can see the location in the info box below my avatar', () => { cy.contains(myLocation) }) -Then('the name {string} is still there', (name) => { +Then('the name {string} is still there', name => { matchNameInUserMenu(name) }) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index dc183fa87..a0d348437 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -3,15 +3,14 @@ import { getLangByName } from '../../support/helpers' /* global cy */ -let lastPost = { -} +let lastPost = {} const loginCredentials = { email: 'peterpan@example.org', - password: '1234', + password: '1234' } const narratorParams = { - name: "Peter Pan", + name: 'Peter Pan', ...loginCredentials } @@ -20,29 +19,44 @@ Given('I am logged in', () => { }) Given('we have a selection of tags and categories as well as posts', () => { - cy.factory() + cy.factory() .authenticateAs(loginCredentials) - .create('category', { id: 'cat1', name: 'Just For Fun', slug: 'justforfun', icon: 'smile' }) - .create('category', { id: 'cat2', name: 'Happyness & Values', slug: 'happyness-values', icon: 'heart-o' }) - .create('category', { id: 'cat3', name: 'Health & Wellbeing', slug: 'health-wellbeing', icon: 'medkit' }) + .create('category', { + id: 'cat1', + name: 'Just For Fun', + slug: 'justforfun', + icon: 'smile' + }) + .create('category', { + id: 'cat2', + name: 'Happyness & Values', + slug: 'happyness-values', + icon: 'heart-o' + }) + .create('category', { + id: 'cat3', + name: 'Health & Wellbeing', + slug: 'health-wellbeing', + icon: 'medkit' + }) .create('tag', { id: 't1', name: 'Ecology' }) .create('tag', { id: 't2', name: 'Nature' }) .create('tag', { id: 't3', name: 'Democracy' }) .create('post', { id: 'p0' }) .create('post', { id: 'p1' }) .create('post', { id: 'p2' }) - .relate('post', 'Categories', { from: 'p0', to: 'cat1' }) - .relate('post', 'Categories', { from: 'p1', to: 'cat2' }) - .relate('post', 'Categories', { from: 'p2', to: 'cat3' }) - .relate('post', 'Tags', { from: 'p0', to: 't1' }) - .relate('post', 'Tags', { from: 'p0', to: 't2' }) - .relate('post', 'Tags', { from: 'p0', to: 't3' }) - .relate('post', 'Tags', { from: 'p1', to: 't1' }) - .relate('post', 'Tags', { from: 'p1', to: 't2' }) + .relate('post', 'Categories', { from: 'p0', to: 'cat1' }) + .relate('post', 'Categories', { from: 'p1', to: 'cat2' }) + .relate('post', 'Categories', { from: 'p2', to: 'cat3' }) + .relate('post', 'Tags', { from: 'p0', to: 't1' }) + .relate('post', 'Tags', { from: 'p0', to: 't2' }) + .relate('post', 'Tags', { from: 'p0', to: 't3' }) + .relate('post', 'Tags', { from: 'p1', to: 't1' }) + .relate('post', 'Tags', { from: 'p1', to: 't2' }) }) Given('we have the following user accounts:', table => { - table.hashes().forEach((params) => { + table.hashes().forEach(params => { cy.factory().create('user', params) }) }) @@ -125,7 +139,7 @@ When('I press {string}', label => { }) Given('we have the following posts in our database:', table => { - table.hashes().forEach(({Author, title, content}) => { + table.hashes().forEach(({ Author, title, content }) => { cy.factory() .create('user', { name: Author, @@ -148,9 +162,12 @@ When('I click on the avatar menu in the top right corner', () => { cy.get('.avatar-menu').click() }) -When('I click on the big plus icon in the bottom right corner to create post', () => { - cy.get('.post-add-button').click() -}) +When( + 'I click on the big plus icon in the bottom right corner to create post', + () => { + cy.get('.post-add-button').click() + } +) Given('I previously created a post', () => { cy.factory() @@ -158,24 +175,24 @@ Given('I previously created a post', () => { .create('post', lastPost) }) -When('I choose {string} as the title of the post', (title) => { +When('I choose {string} as the title of the post', title => { lastPost.title = title.replace('\n', ' ') cy.get('input[name="title"]').type(lastPost.title) }) -When('I type in the following text:', (text) => { +When('I type in the following text:', text => { lastPost.content = text.replace('\n', ' ') cy.get('.ProseMirror').type(lastPost.content) }) -Then('the post shows up on the landing page at position {int}', (index) => { +Then('the post shows up on the landing page at position {int}', index => { cy.openPage('landing') const selector = `:nth-child(${index}) > .ds-card > .ds-card-content` cy.get(selector).should('contain', lastPost.title) cy.get(selector).should('contain', lastPost.content) }) -Then('I get redirected to {string}', (route) => { +Then('I get redirected to {string}', route => { cy.location('pathname').should('contain', route) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index a2f52fd91..5b4c2055b 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -35,7 +35,7 @@ Cypress.Commands.add('switchLanguage', (name, force) => { } }) -Cypress.Commands.add('login', ({email, password}) => { +Cypress.Commands.add('login', ({ email, password }) => { cy.visit(`/login`) cy.get('input[name=email]') .trigger('focus') diff --git a/cypress/support/factories.js b/cypress/support/factories.js index 1c4515737..db31d5866 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -7,7 +7,7 @@ const neo4jDriver = getDriver({ username: Cypress.env('NEO4J_USERNAME'), password: Cypress.env('NEO4J_PASSWORD') }) -const factory = Factory({neo4jDriver}) +const factory = Factory({ neo4jDriver }) beforeEach(async () => { await factory.cleanDatabase({ neo4jDriver }) @@ -17,14 +17,26 @@ Cypress.Commands.add('factory', () => { return Factory() }) -Cypress.Commands.add('create', { prevSubject: true }, (factory, node, properties) => { - return factory.create(node, properties) -}) +Cypress.Commands.add( + 'create', + { prevSubject: true }, + (factory, node, properties) => { + return factory.create(node, properties) + } +) -Cypress.Commands.add('relate', { prevSubject: true }, (factory, node, relationship, properties) => { - return factory.relate(node, relationship, properties) -}) +Cypress.Commands.add( + 'relate', + { prevSubject: true }, + (factory, node, relationship, properties) => { + return factory.relate(node, relationship, properties) + } +) -Cypress.Commands.add('authenticateAs', { prevSubject: true }, (factory, loginCredentials) => { - return factory.authenticateAs(loginCredentials) -}) +Cypress.Commands.add( + 'authenticateAs', + { prevSubject: true }, + (factory, loginCredentials) => { + return factory.authenticateAs(loginCredentials) + } +) From cec78c1954b8ff201ecb05905c2319bd4f311911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 25 Feb 2019 19:00:39 +0100 Subject: [PATCH 06/10] Add instructions to configure cypress for neo4j @appinteractive probably you missed these changes --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c6c87c6a3..6e3debd69 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ $ yarn install Copy: ``` cp .env.template .env +cp cypress.env.template.json cypress.env.json ``` -Configure the file `.env` according to your needs and your local setup. +Configure the files according to your needs and your local setup. ### Development ``` bash From cf898d5417d297ab08e693c46440931286790c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 25 Feb 2019 19:59:16 +0100 Subject: [PATCH 07/10] Report feature uses factories --- cypress/integration/05.ReportContent.feature | 8 ++++---- cypress/integration/common/report.js | 16 +++------------- cypress/integration/common/steps.js | 4 ++-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/05.ReportContent.feature index 25f5aec94..76ebb4fcd 100644 --- a/cypress/integration/05.ReportContent.feature +++ b/cypress/integration/05.ReportContent.feature @@ -9,8 +9,8 @@ Feature: Report and Moderate Background: Given we have the following posts in our database: - | Author | title | content | - | David Irving | The Truth about the Holocaust | It never existed! | + | Author | id | title | content | + | David Irving | p1 | The Truth about the Holocaust | It never existed! | Scenario Outline: Report a post from various pages Given I am logged in with a "user" role @@ -45,8 +45,8 @@ Feature: Report and Moderate Scenario: Review reported content Given somebody reported the following posts: - | Slug | - | the-truth-about-the-holocaust | + | id | + | p1 | And I am logged in with a "moderator" role When I click on the avatar menu in the top right corner And I click on "Moderation" diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 0b0d3f253..f9b232d29 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -125,27 +125,17 @@ When(/^I confirm the reporting dialog .*:$/, () => { }) Given('somebody reported the following posts:', table => { - table.hashes().forEach(({ slug }, index) => { - const author = { - id: `author${index}`, - email: `author${index}@example.org`, - password: '1234' - } + table.hashes().forEach(({ id }) => { const reporter = { - id: `reporter${index}`, - email: `reporter${index}@example.org`, + email: `reporter${id}@example.org`, password: '1234' } - cy.factory() - .create('user', author) - .authenticateAs(author) - .create('post', { id: `p${index}` }) cy.factory() .create('user', reporter) .authenticateAs(reporter) .create('report', { description: "I don't like this post", - resource: { id: `p${index}`, type: 'post' } + resource: { id, type: 'contribution' } }) }) }) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index a0d348437..5e816c5ce 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -139,7 +139,7 @@ When('I press {string}', label => { }) Given('we have the following posts in our database:', table => { - table.hashes().forEach(({ Author, title, content }) => { + table.hashes().forEach(({ Author, id, title, content }) => { cy.factory() .create('user', { name: Author, @@ -150,7 +150,7 @@ Given('we have the following posts in our database:', table => { email: `${Author}@example.org`, password: '1234' }) - .create('post', { title, content }) + .create('post', { id, title, content }) }) }) From 250c70991a5ece063924974a314c92ccc25054fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 25 Feb 2019 21:10:45 +0100 Subject: [PATCH 08/10] All cucumber tests pass on my machine --- .../integration/03.TagsAndCategories.feature | 19 +++--- cypress/integration/common/admin.js | 30 +++++----- cypress/integration/common/report.js | 6 +- cypress/integration/common/steps.js | 58 +++++++++++-------- 4 files changed, 62 insertions(+), 51 deletions(-) diff --git a/cypress/integration/03.TagsAndCategories.feature b/cypress/integration/03.TagsAndCategories.feature index 050fb3643..8f27a36cf 100644 --- a/cypress/integration/03.TagsAndCategories.feature +++ b/cypress/integration/03.TagsAndCategories.feature @@ -22,20 +22,19 @@ Feature: Tags and Categories 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 | + | Icon | Name | Posts | + | | Just For Fun | 2 | + | | Happyness & Values | 1 | + | | Health & Wellbeing | 0 | 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 tags ordered by user and post count: - | # | Name | Nutzer | Beiträge | - | 1 | Naturschutz | 2 | 2 | - | 2 | Freiheit | 2 | 2 | - | 3 | Umwelt | 1 | 1 | - | 4 | Demokratie | 1 | 1 | + Then I can see a list of tags ordered by user count: + | # | 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 9162667b4..b0bc60c16 100644 --- a/cypress/integration/common/admin.js +++ b/cypress/integration/common/admin.js @@ -2,18 +2,6 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps' /* global cy */ -const lastColumnIsSortedInDescendingOrder = () => { - cy.get('tbody') - .find('tr td:last-child') - .then(lastColumn => { - cy.wrap(lastColumn) - const values = lastColumn - .map((i, td) => parseInt(td.textContent)) - .toArray() - const orderedDescending = values.slice(0).sort((a, b) => b - a) - return cy.wrap(values).should('deep.eq', orderedDescending) - }) -} When('I navigate to the administration dashboard', () => { cy.get('.avatar-menu').click() @@ -27,13 +15,25 @@ Then('I can see a list of categories ordered by post count:', table => { cy.get('thead') .find('tr th') .should('have.length', 3) - lastColumnIsSortedInDescendingOrder() + table.hashes().forEach(({Name, Posts}, index) => { + cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(2)`) + .should('contain', Name) + cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(3)`) + .should('contain', Posts) + }) }) -Then('I can see a list of tags ordered by user and post count:', table => { +Then('I can see a list of tags ordered by user count:', table => { // TODO: match the table in the feature with the html table cy.get('thead') .find('tr th') .should('have.length', 4) - lastColumnIsSortedInDescendingOrder() + table.hashes().forEach(({Name, Users, Posts}, index) => { + cy.get(`tbody > :nth-child(${index + 1}) > :nth-child(2)`) + .should('contain', Name) + 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) + }) }) diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index f9b232d29..380d51034 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -28,7 +28,7 @@ Given("I see David Irving's post on the post page", page => { }) Given('I am logged in with a {string} role', role => { - cy.factory().create('user', { + cy.factory().create('User', { email: `${role}@example.org`, password: '1234', role @@ -131,9 +131,9 @@ Given('somebody reported the following posts:', table => { password: '1234' } cy.factory() - .create('user', reporter) + .create('User', reporter) .authenticateAs(reporter) - .create('report', { + .create('Report', { description: "I don't like this post", resource: { id, type: 'contribution' } }) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 5e816c5ce..c17c2729b 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -21,52 +21,64 @@ Given('I am logged in', () => { Given('we have a selection of tags and categories as well as posts', () => { cy.factory() .authenticateAs(loginCredentials) - .create('category', { + .create('Category', { id: 'cat1', name: 'Just For Fun', slug: 'justforfun', icon: 'smile' }) - .create('category', { + .create('Category', { id: 'cat2', name: 'Happyness & Values', slug: 'happyness-values', icon: 'heart-o' }) - .create('category', { + .create('Category', { id: 'cat3', name: 'Health & Wellbeing', slug: 'health-wellbeing', icon: 'medkit' }) - .create('tag', { id: 't1', name: 'Ecology' }) - .create('tag', { id: 't2', name: 'Nature' }) - .create('tag', { id: 't3', name: 'Democracy' }) - .create('post', { id: 'p0' }) - .create('post', { id: 'p1' }) - .create('post', { id: 'p2' }) - .relate('post', 'Categories', { from: 'p0', to: 'cat1' }) - .relate('post', 'Categories', { from: 'p1', to: 'cat2' }) - .relate('post', 'Categories', { from: 'p2', to: 'cat3' }) - .relate('post', 'Tags', { from: 'p0', to: 't1' }) - .relate('post', 'Tags', { from: 'p0', to: 't2' }) - .relate('post', 'Tags', { from: 'p0', to: 't3' }) - .relate('post', 'Tags', { from: 'p1', to: 't1' }) - .relate('post', 'Tags', { from: 'p1', to: 't2' }) + .create('Tag', { id: 't1', name: 'Ecology' }) + .create('Tag', { id: 't2', name: 'Nature' }) + .create('Tag', { id: 't3', name: 'Democracy' }) + + const someAuthor = { + id: 'authorId', + email: '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('Post', { id: 'p2' }) + .relate('Post', 'Categories', { from: 'p0', to: 'cat1' }) + .relate('Post', 'Categories', { from: 'p1', to: 'cat2' }) + .relate('Post', 'Categories', { from: 'p2', to: 'cat1' }) + .relate('Post', 'Tags', { from: 'p0', to: 't1' }) + .relate('Post', 'Tags', { from: 'p0', to: 't2' }) + .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: 't3' }) }) Given('we have the following user accounts:', table => { table.hashes().forEach(params => { - cy.factory().create('user', params) + cy.factory().create('User', params) }) }) Given('I have a user account', () => { - cy.factory().create('user', narratorParams) + cy.factory().create('User', narratorParams) }) Given('my user account has the role {string}', role => { - cy.factory().create('user', { + cy.factory().create('User', { role, ...loginCredentials }) @@ -141,7 +153,7 @@ When('I press {string}', label => { Given('we have the following posts in our database:', table => { table.hashes().forEach(({ Author, id, title, content }) => { cy.factory() - .create('user', { + .create('User', { name: Author, email: `${Author}@example.org`, password: '1234' @@ -150,7 +162,7 @@ Given('we have the following posts in our database:', table => { email: `${Author}@example.org`, password: '1234' }) - .create('post', { id, title, content }) + .create('Post', { id, title, content }) }) }) @@ -172,7 +184,7 @@ When( Given('I previously created a post', () => { cy.factory() .authenticateAs(loginCredentials) - .create('post', lastPost) + .create('Post', lastPost) }) When('I choose {string} as the title of the post', title => { From 7c629ed4f0c1b8eb7f3f63c613164f7aad69b083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 25 Feb 2019 21:34:31 +0100 Subject: [PATCH 09/10] Configure Travis to use factories for cypress --- .travis.yml | 6 +++--- cypress.env.template.json | 1 + cypress/support/factories.js | 5 +++-- docker-compose.travis.yml | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f5cb1b4ef..4afa4c742 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ before_install: - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin + - cp cypress.env.template.json cypress.env.json install: - docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-web . @@ -31,9 +32,8 @@ install: script: - docker-compose exec -e NODE_ENV=test webapp yarn run lint - docker-compose exec -e NODE_ENV=test webapp yarn run test - - docker-compose -f ../Nitro-Backend/docker-compose.yml exec backend yarn run db:seed - - wait-on http://localhost:3000 - - cypress run --record --key $CYPRESS_TOKEN + - wait-on http://localhost:7474 && docker-compose -f ../Nitro-Backend/docker-compose.yml exec neo4j migrate + - wait-on http://localhost:3000 && cypress run --record --key $CYPRESS_TOKEN after_success: - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh diff --git a/cypress.env.template.json b/cypress.env.template.json index 59cf04ab6..bd03f6381 100644 --- a/cypress.env.template.json +++ b/cypress.env.template.json @@ -1,4 +1,5 @@ { + "SEED_SERVER_HOST": "http://localhost:4001", "NEO4J_URI": "bolt://localhost:7687", "NEO4J_USERNAME": "neo4j", "NEO4J_PASSWORD": "letmein" diff --git a/cypress/support/factories.js b/cypress/support/factories.js index db31d5866..95355f414 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -8,13 +8,14 @@ const neo4jDriver = getDriver({ password: Cypress.env('NEO4J_PASSWORD') }) const factory = Factory({ neo4jDriver }) +const seedServerHost = Cypress.env('SEED_SERVER_HOST') beforeEach(async () => { - await factory.cleanDatabase({ neo4jDriver }) + await factory.cleanDatabase({ seedServerHost, neo4jDriver }) }) Cypress.Commands.add('factory', () => { - return Factory() + return Factory({seedServerHost}) }) Cypress.Commands.add( diff --git a/docker-compose.travis.yml b/docker-compose.travis.yml index ced9719a2..8bd536a7b 100644 --- a/docker-compose.travis.yml +++ b/docker-compose.travis.yml @@ -5,3 +5,5 @@ services: build: context: . target: build-and-test + environment: + - BACKEND_URL=http://backend:4123 From a14a81942042bffe1363b9b37f4b3b223eddfea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Tue, 26 Feb 2019 00:24:54 +0100 Subject: [PATCH 10/10] Remove TODOs --- cypress/integration/common/admin.js | 2 -- cypress/integration/common/report.js | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cypress/integration/common/admin.js b/cypress/integration/common/admin.js index b0bc60c16..03cbe5fca 100644 --- a/cypress/integration/common/admin.js +++ b/cypress/integration/common/admin.js @@ -11,7 +11,6 @@ When('I navigate to the administration dashboard', () => { }) 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) @@ -24,7 +23,6 @@ Then('I can see a list of categories ordered by post count:', table => { }) Then('I can see a list of tags ordered by user count:', table => { - // TODO: match the table in the feature with the html table cy.get('thead') .find('tr th') .should('have.length', 4) diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index 380d51034..3f2895dd9 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -111,12 +111,8 @@ Then(`I can't see the moderation menu item`, () => { .should('not.exist') }) -When(/^I confirm the reporting dialog .*:$/, () => { - //TODO: take message from method argument - //TODO: match the right post - const message = 'Do you really want to report the' +When(/^I confirm the reporting dialog .*:$/, (message) => { cy.contains(message) // wait for element to become visible - //TODO: cy.get('.ds-modal').contains(davidIrvingPostTitle) cy.get('.ds-modal').within(() => { cy.get('button') .contains('Send Report') @@ -141,14 +137,12 @@ Given('somebody reported the following posts:', table => { }) Then('I see all the reported posts including the one from above', () => { - //TODO: match the right post cy.get('table tbody').within(() => { cy.contains('tr', davidIrvingPostTitle) }) }) Then('each list item links to the post page', () => { - //TODO: match the right post cy.contains(davidIrvingPostTitle).click() cy.location('pathname').should('contain', '/post') })