Skip to content

Commit

Permalink
test using some then statements
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertschuler committed Jun 26, 2022
1 parent a2fc692 commit cc9710b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
26 changes: 16 additions & 10 deletions cypress/integration/formError.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ describe("Form Error Tests", () => {
cy.get('[data-test-id="test-address"]').type("Unbekannt 1");
cy.get('[data-test-id="test-city"]').clear()
cy.get('[data-test-id="test-zipCode"]').clear().type("82449")
cy.get('[data-test-id="test-country"]').clear().type("Germany{enter}").get('body').click(0, 0)
//cy.get('[data-test-id="test-continueToPayment"]').click()
cy.get('.form-errors').should("have.text", "City is required")
cy.get('[data-test-id="test-city"]').click().type("Uffing am Staffelsee")
cy.get('body').should("not.have.text", "City is required")
cy.get('[data-test-id="test-country"]').clear().type("Germany{enter}").get('body').click(0, 0).then(() => {
cy.get('[data-test-id="test-continueDisabled"]').click().then(() => {
cy.get('.form-errors').should("have.text", "City is required")
cy.get('[data-test-id="test-city"]').click().type("Uffing am Staffelsee").then(() => {
cy.get('body').should("not.have.text", "City is required")
})
})
})
})

it("ZipCode error", () => {
Expand All @@ -104,10 +107,13 @@ describe("Form Error Tests", () => {
cy.get('[data-test-id="test-address"]').type("Unbekannt 1");
cy.get('[data-test-id="test-city"]').clear().type("Uffing am Staffelsee")
cy.get('[data-test-id="test-zipCode"]').clear()
cy.get('[data-test-id="test-country"]').clear().type(`${selectedCountry}{enter}`).get('body').click(0, 0)
//cy.get('[data-test-id="test-continueToPayment"]').click()
cy.get('.form-errors').should("have.text", "ZipCode is invalid")
cy.get('[data-test-id="test-zipCode"]').click().type(new RandExp(fiteredCountry[0].postal).gen())
cy.get('body').should("not.have.text", "ZipCode is invalid")
cy.get('[data-test-id="test-country"]').clear().type(`${selectedCountry}{enter}`).get('body').click(0, 0).then (() => {
cy.get('[data-test-id="test-continueDisabled"]').click().then(() => {
cy.get('.form-errors').should("have.text", "ZipCode is invalid")
cy.get('[data-test-id="test-zipCode"]').click().type(new RandExp(fiteredCountry[0].postal).gen()).then(() => {
cy.get('body').should("not.have.text", "ZipCode is invalid")
})
})
})
})
})
15 changes: 9 additions & 6 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,15 @@ Cypress.Commands.add('bankTransfer', () => {
cy.wait(5000)
// cy.get('.frequency-selection-option').eq(0).should("have.text", "Once").click()
cy.contactForm("Peter", "Payer", "[email protected]", "Unbekannt 1", "Uffing am Staffelsee", "Germany{enter}", "82449")
cy.wait(15000)
cy.get('[data-test-id="bankTransfer"]').click()
cy.get('[data-test-id="bankDonateContinue"]').click()
cy.wait(10000)
cy.get('[data-test-id="test-thankYou"]').should("exist")

cy.wait(15000).then(() => {
cy.get('[data-test-id="bankTransfer"]').click().then(() => {
cy.get('[data-test-id="bankDonateContinue"]').click().then(() => {
cy.wait(15000).then(() => {
cy.get('[data-test-id="test-thankYou"]').should("exist")
})
})
})
})
})


Expand Down
5 changes: 4 additions & 1 deletion src/Donations/Components/ContactsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,10 @@ function ContactsForm({}: Props): ReactElement {
errors.city ||
errors.zipCode ||
errors.country ? (
<button className={"secondary-button mt-30"}>
<button
className={"secondary-button mt-30"}
data-test-id="test-continueDisabled"
>
{t("continue")}
</button>
) : (
Expand Down

0 comments on commit cc9710b

Please sign in to comment.