From a58861427b9382f0d52aaf477e2f1e4d5983a172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Fri, 15 Feb 2019 16:03:21 +0100 Subject: [PATCH] Expose a bug: wrong redirect on Post#create 1/2 cucumber tests are green. The reason why the first test does not succeed reliably is that the frontend redirects to a wrong URL after you create the post. It's the slug of the first created post. I want to be redirected to the slug of the created post. CC @appinteractive please fix --- cypress/integration/06.WritePost.feature | 2 +- cypress/integration/common/steps.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cypress/integration/06.WritePost.feature b/cypress/integration/06.WritePost.feature index 98f49fb62..e889a4783 100644 --- a/cypress/integration/06.WritePost.feature +++ b/cypress/integration/06.WritePost.feature @@ -21,4 +21,4 @@ Feature: Create a post Scenario: See a post on the landing page Given I previously created a post - Then the post shows up on the landing page + Then the post shows up on the landing page at position 1 diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 5cb83f98f..fadee974b 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -116,19 +116,20 @@ Given('I previously created a post', () => { }) When('I choose {string} as the title of the post', (title) => { - lastPost.title = title - cy.get('input[name="title"]').type(title) + lastPost.title = title.replace('\n', ' ') + cy.get('input[name="title"]').type(lastPost.title) }) When('I type in the following text:', (text) => { - lastPost.text = text - cy.get('.ProseMirror').type(text) + lastPost.text = text.replace('\n', ' ') + cy.get('.ProseMirror').type(lastPost.text) }) -Then('the post shows up on the landing page', () => { +Then('the post shows up on the landing page at position {int}', (index) => { cy.openPage('landing') - cy.get('.ds-container').should('contain', lastPost.title) - cy.get('.ds-container').should('contain', lastPost.text) + const selector = `:nth-child(${index}) > .ds-card > .ds-card-content` + cy.get(selector).should('contain', lastPost.title) + cy.get(selector).should('contain', lastPost.text) }) Then('I get redirected to {string}', (route) => { @@ -136,6 +137,6 @@ Then('I get redirected to {string}', (route) => { }) Then('the post was saved successfully', () => { - cy.get('.post-card').should('contain', lastPost.title) - cy.get('.post-card').should('contain', lastPost.text) + cy.get('.ds-card-header > .ds-heading').should('contain', lastPost.title) + cy.get('.content').should('contain', lastPost.text) })