From a02a72de82cdd704e757f8ceec3a6a34c6bee0d0 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 10 Apr 2021 20:06:57 +0200 Subject: [PATCH] unified click events separated post in post.create & post --- cypress/integration/Authentication.feature | 2 +- .../Authentication/I_click_submit.js | 7 ------- cypress/integration/Post.Create.feature | 13 +++---------- .../Post.Create/I_click_on_create_post.js | 5 ----- .../Post.Create/I_click_on_{string}.js | 6 ------ cypress/integration/Post.feature | 18 ++++++++++++++++++ .../I_previously_created_a_post.js | 0 ...up_on_the_landing_page_at_position_{int}.js | 0 .../integration/common/I_click_on_{string}.js | 14 ++++++++++++++ 9 files changed, 36 insertions(+), 29 deletions(-) delete mode 100644 cypress/integration/Authentication/I_click_submit.js delete mode 100644 cypress/integration/Post.Create/I_click_on_create_post.js delete mode 100644 cypress/integration/Post.Create/I_click_on_{string}.js create mode 100644 cypress/integration/Post.feature rename cypress/integration/{Post.Create => Post}/I_previously_created_a_post.js (100%) rename cypress/integration/{Post.Create => Post}/the_post_shows_up_on_the_landing_page_at_position_{int}.js (100%) create mode 100644 cypress/integration/common/I_click_on_{string}.js diff --git a/cypress/integration/Authentication.feature b/cypress/integration/Authentication.feature index ea8807d35..271c85152 100644 --- a/cypress/integration/Authentication.feature +++ b/cypress/integration/Authentication.feature @@ -10,7 +10,7 @@ Feature: Authentication Scenario: Log in When I navigate to page "login" And I fill in my credentials - And I click submit + And I click on "submit button" Then I am logged in as "Peter Pan" Scenario: Refresh and stay logged in diff --git a/cypress/integration/Authentication/I_click_submit.js b/cypress/integration/Authentication/I_click_submit.js deleted file mode 100644 index 679768abd..000000000 --- a/cypress/integration/Authentication/I_click_submit.js +++ /dev/null @@ -1,7 +0,0 @@ -import { When } from "cypress-cucumber-preprocessor/steps"; - -When("I click submit", () => { - cy.get("button[name=submit]") - .click() - .wait(500); // This is to ensure we reach the feed -}); \ No newline at end of file diff --git a/cypress/integration/Post.Create.feature b/cypress/integration/Post.Create.feature index 53835dc74..76742fffb 100644 --- a/cypress/integration/Post.Create.feature +++ b/cypress/integration/Post.Create.feature @@ -9,21 +9,14 @@ Feature: Create a post And I navigate to page "landing" Scenario: Create a post - When I click on create post - And I wait for 500 milliseconds + When I click on "create post button" Then I am on page "post/create" When I choose "My first post" as the title And I choose the following text as content: """ - Human Connection is a free and open-source social network + Ocelot.social is a free and open-source social network for active citizenship. """ - And I click on "Save" - And I wait for 500 milliseconds + And I click on "save button" Then I am on page ".../my-first-post" And the post was saved successfully - - Scenario: See a post on the landing page - When I previously created a post - And I navigate to page "landing" - Then the post shows up on the landing page at position 1 diff --git a/cypress/integration/Post.Create/I_click_on_create_post.js b/cypress/integration/Post.Create/I_click_on_create_post.js deleted file mode 100644 index 7624acf5a..000000000 --- a/cypress/integration/Post.Create/I_click_on_create_post.js +++ /dev/null @@ -1,5 +0,0 @@ -import { When } from "cypress-cucumber-preprocessor/steps"; - -When("I click on create post", () => { - cy.get(".post-add-button").click(); -}); \ No newline at end of file diff --git a/cypress/integration/Post.Create/I_click_on_{string}.js b/cypress/integration/Post.Create/I_click_on_{string}.js deleted file mode 100644 index 1a58cf13f..000000000 --- a/cypress/integration/Post.Create/I_click_on_{string}.js +++ /dev/null @@ -1,6 +0,0 @@ -import { When } from "cypress-cucumber-preprocessor/steps"; - -When(`I click on {string}`, text => { - cy.contains(text) - .click() -}); \ No newline at end of file diff --git a/cypress/integration/Post.feature b/cypress/integration/Post.feature new file mode 100644 index 000000000..3f3879949 --- /dev/null +++ b/cypress/integration/Post.feature @@ -0,0 +1,18 @@ +Feature: Create a post + As an logged in user + I would like to see a post + And to see the whole content of it + + Background: + Given I have an user account + And I am logged in + And I previously created a post + + Scenario: See a post on the landing page + When I navigate to page "landing" + Then the post shows up on the landing page at position 1 + + Scenario: Navigate to the Post Page + When I navigate to page "landing" + And I click on "the first post" + Then I am on page "post/..." diff --git a/cypress/integration/Post.Create/I_previously_created_a_post.js b/cypress/integration/Post/I_previously_created_a_post.js similarity index 100% rename from cypress/integration/Post.Create/I_previously_created_a_post.js rename to cypress/integration/Post/I_previously_created_a_post.js diff --git a/cypress/integration/Post.Create/the_post_shows_up_on_the_landing_page_at_position_{int}.js b/cypress/integration/Post/the_post_shows_up_on_the_landing_page_at_position_{int}.js similarity index 100% rename from cypress/integration/Post.Create/the_post_shows_up_on_the_landing_page_at_position_{int}.js rename to cypress/integration/Post/the_post_shows_up_on_the_landing_page_at_position_{int}.js diff --git a/cypress/integration/common/I_click_on_{string}.js b/cypress/integration/common/I_click_on_{string}.js new file mode 100644 index 000000000..b08399a41 --- /dev/null +++ b/cypress/integration/common/I_click_on_{string}.js @@ -0,0 +1,14 @@ +import { When } from "cypress-cucumber-preprocessor/steps"; + +When("I click on {string}", element => { + const elementSelectors = { + 'submit button': 'button[name=submit]', + 'create post button': '.post-add-button', + 'save button': 'button[type=submit]', + 'the first post': '.post-teaser:nth-child(1)', + } + + cy.get(elementSelectors[element]) + .click() + .wait(750); +}); \ No newline at end of file