From e46ff56c1e6ac3ffd7c8efa3cb1eb950ff8f5971 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 16 Jun 2023 16:32:19 +0200 Subject: [PATCH] add send test of e2e feature send coins --- e2e-tests/cypress/e2e/SendCoins.feature | 20 +++++++ .../step_definitions/send_coin_steps.ts | 60 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 e2e-tests/cypress/e2e/SendCoins.feature create mode 100644 e2e-tests/cypress/support/step_definitions/send_coin_steps.ts diff --git a/e2e-tests/cypress/e2e/SendCoins.feature b/e2e-tests/cypress/e2e/SendCoins.feature new file mode 100644 index 000000000..f04684afb --- /dev/null +++ b/e2e-tests/cypress/e2e/SendCoins.feature @@ -0,0 +1,20 @@ +Feature: Send coins + As a user + I want to send and receive GDD + I want to see transaction details on overview and transactions pages + + # Background: + # Given the following "users" are in the database: + # | email | password | name | + # | bob@baumeister.de | Aa12345_ | Bob Baumeister | + # | raeuber@hotzenplotz.de | Aa12345_ | Räuber Hotzenplotz | + + Scenario: Send GDD to other user + Given the user is logged in as "bob@baumeister.de" "Aa12345_" + And the user navigates to page "/send" + When the user fills the send form with "raeuber@hotzenplotz.de" "120,50" "Some memo text" + And the user submits the send form + Then the transaction details are presented for confirmation + When the user submits the transaction by confirming + Then the transaction details are displayed on the transcations page + diff --git a/e2e-tests/cypress/support/step_definitions/send_coin_steps.ts b/e2e-tests/cypress/support/step_definitions/send_coin_steps.ts new file mode 100644 index 000000000..f96da9768 --- /dev/null +++ b/e2e-tests/cypress/support/step_definitions/send_coin_steps.ts @@ -0,0 +1,60 @@ +import { And, Then, When } from '@badeball/cypress-cucumber-preprocessor' +import { SendPage } from '../../e2e/models/SendPage' + +const sendPage = new SendPage() + +When( + 'the user fills the send form with {string} {string} {string}', + (email: string, amount: string, memoText: string) => { + sendPage.enterReceiverEmail(email) + sendPage.enterAmount(amount) + sendPage.enterMemoText(memoText) + } +) + +And('the user submits the send form', () => { + sendPage.submit() + cy.get('.transaction-confirm-send').should('be.visible') +}) + + +Then('the transaction details are presented for confirmation', () => { + cy.get('.transaction-confirm-send').contains('raeuber@hotzenplotz.de') + cy.get('.transaction-confirm-send').contains('+ 120,50 GDD') + cy.get('.transaction-confirm-send').contains('Some memo text') + cy.get('.transaction-confirm-send').contains('+ 515,11 GDD') + cy.get('.transaction-confirm-send').contains('− 120,50 GDD') + cy.get('.transaction-confirm-send').contains('+ 394,61 GDD') +}) + +When('the user submits the transaction by confirming', () => { + cy.intercept({ + method: 'POST', + url: '/graphql', + hostname: 'localhost', + }).as('sendCoins') + + sendPage.submit() + + cy.wait('@sendCoins').then((interception) => { + cy.wrap(interception.response?.statusCode).should('eq', 200) + cy.wrap(interception.request.body) + .should('have.property', 'query', `mutation ($identifier: String!, $amount: Decimal!, $memo: String!) { + sendCoins(identifier: $identifier, amount: $amount, memo: $memo) +} +` ) + cy.wrap(interception.response?.body) + .should('have.nested.property', 'data.sendCoins') + .and('equal', true) + }) + cy.get('[data-test="send-transaction-success-text"]').should('be.visible') + cy.get('.rightside-last-transactions').should('be.visible') + cy.get('.align-items-center').contains('Räuber Hotzenplotz') + cy.get('.align-items-center').contains('− 120,50 GDD') +}) + +Then('the transaction details are displayed on the transcations page', () => { + cy.visit('/transactions') + cy.get('.test-list-group-item').contains('Räuber Hotzenplotz') + cy.get('.test-list-group-item').contains('− 120,50 GDD') +}) \ No newline at end of file