Implement cypress tests

This commit is contained in:
Wolfgang Huß 2021-09-16 10:52:36 +02:00
parent 1c74234b9a
commit 915e1143c7
6 changed files with 59 additions and 3 deletions

View File

@ -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"

View File

@ -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()
})

View File

@ -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)
});

View File

@ -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')
})

View File

@ -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()

View File

@ -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
}
})