From 4db242933f6aee3aa2457ac8b3a134f33c134dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sat, 16 Mar 2019 19:23:27 +0100 Subject: [PATCH] Fix HidePosts.feature --- cypress/integration/common/steps.js | 28 +++++++++++++------ .../integration/moderation/HidePosts.feature | 8 +++--- .../ReportContent.feature} | 0 cypress/support/factories.js | 8 ++++++ 4 files changed, 31 insertions(+), 13 deletions(-) rename cypress/integration/{05.ReportContent.feature => moderation/ReportContent.feature} (100%) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index a27ee56f5..ec5f15602 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -156,20 +156,30 @@ When('I press {string}', label => { Given('we have the following posts in our database:', table => { table.hashes().forEach(({ Author, ...postAttributes }) => { - postAttributes.deleted = Boolean(postAttributes.deleted) - postAttributes.disabled = Boolean(postAttributes.disabled) - cy.factory() - .create('User', { + const userAttributes = { name: Author, email: `${Author}@example.org`, password: '1234' - }) - .authenticateAs({ - email: `${Author}@example.org`, - password: '1234' - }) + } + postAttributes.deleted = Boolean(postAttributes.deleted) + const disabled = Boolean(postAttributes.disabled) + cy.factory() + .create('User', userAttributes) + .authenticateAs(userAttributes) .create('Post', postAttributes) + if(disabled) { + const moderatorParams = { + email: 'moderator@example.org', + role: 'moderator', + password: '1234' + } + cy.factory() + .create('User', moderatorParams) + .authenticateAs(moderatorParams) + .mutate('mutation($id: ID!) { disable(id: $id) }', postAttributes) + } }) + }) Then('I see a success message:', message => { diff --git a/cypress/integration/moderation/HidePosts.feature b/cypress/integration/moderation/HidePosts.feature index c2cf49912..e886e5f95 100644 --- a/cypress/integration/moderation/HidePosts.feature +++ b/cypress/integration/moderation/HidePosts.feature @@ -5,10 +5,10 @@ Feature: Hide Posts Background: Given we have the following posts in our database: - | title | deleted | disabled | - | This post should be visible | | | - | This post is disabled | | x | - | This post is deleted | x | | + | id | title | deleted | disabled | + | p1 | This post should be visible | | | + | p2 | This post is disabled | | x | + | p3 | This post is deleted | x | | Scenario: Disabled posts don't show up on the landing page Given I am logged in with a "user" role diff --git a/cypress/integration/05.ReportContent.feature b/cypress/integration/moderation/ReportContent.feature similarity index 100% rename from cypress/integration/05.ReportContent.feature rename to cypress/integration/moderation/ReportContent.feature diff --git a/cypress/support/factories.js b/cypress/support/factories.js index 87bcd1853..b9633d434 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -34,6 +34,14 @@ Cypress.Commands.add( } ) +Cypress.Commands.add( + 'mutate', + { prevSubject: true }, + (factory, mutation, variables) => { + return factory.mutate(mutation, variables) + } +) + Cypress.Commands.add( 'authenticateAs', { prevSubject: true },