From 915e1143c783baa65c78ed4294c91510c38013d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 16 Sep 2021 10:52:36 +0200 Subject: [PATCH] Implement cypress tests --- .../integration/Admin.DonationInfo.feature | 31 +++++++++++++++++++ ...ox_show_donations_progress_bar_and_save.js | 6 ++++ ...ins_goal_{string}_and_progress_{string}.js | 8 +++++ .../the_donation_info_is_{string}.js | 6 ++++ ..._open_the_content_menu_of_post_{string}.js | 2 +- ..._following_{string}_are_in_the_database.js | 9 ++++-- 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 cypress/integration/Admin.DonationInfo.feature create mode 100644 cypress/integration/Admin.DonationInfo/I_click_the_checkbox_show_donations_progress_bar_and_save.js create mode 100644 cypress/integration/Admin.DonationInfo/the_donation_info_contains_goal_{string}_and_progress_{string}.js create mode 100644 cypress/integration/Admin.DonationInfo/the_donation_info_is_{string}.js diff --git a/cypress/integration/Admin.DonationInfo.feature b/cypress/integration/Admin.DonationInfo.feature new file mode 100644 index 000000000..1f925f9e2 --- /dev/null +++ b/cypress/integration/Admin.DonationInfo.feature @@ -0,0 +1,31 @@ +Feature: Admin sets donations info settings + As an admin + I want to switch the donation info on and off and like I to change to donations goal and progress + In order to manage the foundings + + Background: + Given the following "users" are in the database: + | slug | email | password | id | name | role | termsAndConditionsAgreedVersion | + | user | user@example.org | abcd | user | User-Chad | user | 0.0.4 | + | admin | admin@example.org | 1234 | admin | Admin-Man | admin | 0.0.4 | + Given the following "posts" are in the database: + | id | title | pinned | createdAt | + | p1 | Some other post | | 2020-01-21 | + | p2 | Houston we have a problem | x | 2020-01-20 | + | p3 | Yet another post | | 2020-01-19 | + Given the following "donations" are in the database: + | id | showDonations | goal | progress | + | d1 | x | 15000.0 | 7000.0 | + + Scenario: The donation info is visible on the index page by default + When I am logged in as "user" + And I navigate to page "/" + Then the donation info is "visible" + And the donation info contains goal "15,000" and progress "7,000" + + Scenario: Admin changes the donation info to be invisible + When I am logged in as "admin" + And I navigate to page "/admin/donations" + Then I click the checkbox show donations progress bar and save + And I navigate to page "/" + Then the donation info is "invisible" diff --git a/cypress/integration/Admin.DonationInfo/I_click_the_checkbox_show_donations_progress_bar_and_save.js b/cypress/integration/Admin.DonationInfo/I_click_the_checkbox_show_donations_progress_bar_and_save.js new file mode 100644 index 000000000..b4289dd5e --- /dev/null +++ b/cypress/integration/Admin.DonationInfo/I_click_the_checkbox_show_donations_progress_bar_and_save.js @@ -0,0 +1,6 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("I click the checkbox show donations progress bar and save", () => { + cy.get("#showDonations").click() + cy.get(".donations-info-button").click() +}) \ No newline at end of file diff --git a/cypress/integration/Admin.DonationInfo/the_donation_info_contains_goal_{string}_and_progress_{string}.js b/cypress/integration/Admin.DonationInfo/the_donation_info_contains_goal_{string}_and_progress_{string}.js new file mode 100644 index 000000000..cd2473800 --- /dev/null +++ b/cypress/integration/Admin.DonationInfo/the_donation_info_contains_goal_{string}_and_progress_{string}.js @@ -0,0 +1,8 @@ +import { When } from "cypress-cucumber-preprocessor/steps"; + +When("the donation info contains goal {string} and progress {string}", (goal, progress) => { + cy.get('.top-info-bar') + .should('contain', goal) + cy.get('.top-info-bar') + .should('contain', progress) +}); \ No newline at end of file diff --git a/cypress/integration/Admin.DonationInfo/the_donation_info_is_{string}.js b/cypress/integration/Admin.DonationInfo/the_donation_info_is_{string}.js new file mode 100644 index 000000000..d259e6520 --- /dev/null +++ b/cypress/integration/Admin.DonationInfo/the_donation_info_is_{string}.js @@ -0,0 +1,6 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("the donation info is {string}", (visibility) => { + cy.get('.top-info-bar') + .should(visibility === 'visible' ? 'exist' : 'not.exist') +}) \ No newline at end of file diff --git a/cypress/integration/Admin.PinPost/I_open_the_content_menu_of_post_{string}.js b/cypress/integration/Admin.PinPost/I_open_the_content_menu_of_post_{string}.js index 78e9ab1ea..a7be22495 100644 --- a/cypress/integration/Admin.PinPost/I_open_the_content_menu_of_post_{string}.js +++ b/cypress/integration/Admin.PinPost/I_open_the_content_menu_of_post_{string}.js @@ -1,6 +1,6 @@ import { When } from "cypress-cucumber-preprocessor/steps"; -When("I open the content menu of post {string}", (title)=> { +When("I open the content menu of post {string}", (title) => { cy.contains('.post-teaser', title) .find('.content-menu .base-button') .click() diff --git a/cypress/integration/common/the_following_{string}_are_in_the_database.js b/cypress/integration/common/the_following_{string}_are_in_the_database.js index 1d17ec686..e03a705f4 100644 --- a/cypress/integration/common/the_following_{string}_are_in_the_database.js +++ b/cypress/integration/common/the_following_{string}_are_in_the_database.js @@ -18,12 +18,12 @@ Given("the following {string} are in the database:", (table,data) => { case "comments": data.hashes().forEach( entry => { cy.factory() - .build("comment",entry,entry); + .build("comment", entry, entry); }) break case "users": data.hashes().forEach( entry => { - cy.factory().build("user",entry,entry); + cy.factory().build("user", entry, entry); }); break case "tags": @@ -31,5 +31,10 @@ Given("the following {string} are in the database:", (table,data) => { cy.factory().build("tag", entry, entry) }); break + case "donations": + data.hashes().forEach( entry => { + cy.factory().build("donations", entry, entry) + }); + break } }) \ No newline at end of file