From 59070a8a424e77c22c2f7fbc8e023c75a3717728 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 11 Apr 2024 14:24:40 +0200 Subject: [PATCH] e2e --- .../src/features/payment_notices.feature | 26 +- .../step_definitions/payment_notice_step.js | 54 +++- .../support/client/payment_pull_client.js | 14 +- .../support/utility/request_builder.js | 269 +++++++++++++++++- 4 files changed, 355 insertions(+), 8 deletions(-) diff --git a/integration-test/src/features/payment_notices.feature b/integration-test/src/features/payment_notices.feature index 0c70c8f..8e3cc49 100644 --- a/integration-test/src/features/payment_notices.feature +++ b/integration-test/src/features/payment_notices.feature @@ -24,4 +24,28 @@ Feature: Recover Payment Notices And response contains notice "DEBT3" - + Scenario: Debt Position with one payment option + Given the payment notice "ONE_OPTION" with one option for org "77777777777" and debtor "STCCST83A15L0001" + When an Http GET request is sent to recover notices for taxCode "STCCST83A15L0001" + Then response has a 200 Http status + And response has size 1 + And payments options has size 1 + And payments option n 1 has 1 installments + + + Scenario: Debt Position with one payment option with Installments + Given the payment notice "INSTALLMENT" with one option with installments for org "77777777777" and debtor "STCCST83A15L0002" + When an Http GET request is sent to recover notices for taxCode "STCCST83A15L0002" + Then response has a 200 Http status + And response has size 1 + And payments options has size 1 + And payments option n 1 has 4 installments + + Scenario: Debt Position with two payment options and installments + Given the payment notice "COMPLEX" with complex options and installments for org "77777777777" and debtor "STCCST83A15L0003" + When an Http GET request is sent to recover notices for taxCode "STCCST83A15L0003" + Then response has a 200 Http status + And response has size 1 + And payments options has size 2 + And payments option n 1 has 1 installments + And payments option n 2 has 3 installments diff --git a/integration-test/src/step_definitions/payment_notice_step.js b/integration-test/src/step_definitions/payment_notice_step.js index 3111b4b..05980d3 100644 --- a/integration-test/src/step_definitions/payment_notice_step.js +++ b/integration-test/src/step_definitions/payment_notice_step.js @@ -3,7 +3,13 @@ const {defineParameterType, Given, When, Then, After, AfterAll} = require('@cucu const {executeDebtPositionCreationAndPublication, executeDebtPositionDeletion} = require("./support/logic/gpd_logic"); const {gpdSessionBundle} = require('./support/utility/data'); const {getNotices} = require("./support/client/payment_pull_client"); -const {formatWithValidYear} = require('./support/utility/helpers'); +const {formatWithValidYear, makeIdNumber} = require('./support/utility/helpers'); +const {createAndPublishDebtPosition} = require("./support/client/gpd_client"); +const { + buildUpdateDebtPositionRequest, + buildDebtPositionOneOption, + buildDebtPositionWithInstallments, buildDebtPositionComplex +} = require("./support/utility/request_builder"); const idOrg = process.env.ORGANIZATIONAL_FISCAL_CODE; const positions = []; @@ -42,15 +48,61 @@ Given('the payment notice {string} for the taxCode {string} with due date {strin } }); +Given('the payment notice {string} with one option for org {string} and debtor {string}', + async function (iupd, organizationCode, taxCode) { + await executeDebtPositionDeletion(organizationCode, iupd); + let response = await createAndPublishDebtPosition(organizationCode, buildDebtPositionOneOption(iupd, makeIdNumber(17), organizationCode, taxCode)); + assert.strictEqual(response.status, 201); + if (this.positions === undefined) { + this.positions = []; + } + this.positions.push(response.data); + }); + +Given('the payment notice {string} with one option with installments for org {string} and debtor {string}', + async function (iupd, organizationCode, taxCode) { + await executeDebtPositionDeletion(organizationCode, iupd); + let response = await createAndPublishDebtPosition(organizationCode, buildDebtPositionWithInstallments(iupd, organizationCode, taxCode)); + assert.strictEqual(response.status, 201); + if (this.positions === undefined) { + this.positions = []; + } + this.positions.push(response.data); + }); + +Given('the payment notice {string} with complex options and installments for org {string} and debtor {string}', + async function (iupd, organizationCode, taxCode) { + await executeDebtPositionDeletion(organizationCode, iupd); + let response = await createAndPublishDebtPosition(organizationCode, buildDebtPositionComplex(iupd, organizationCode, taxCode)); + assert.strictEqual(response.status, 201); + if (this.positions === undefined) { + this.positions = []; + } + this.positions.push(response.data); + }); + When('an Http GET request is sent to recover notices for taxCode {string} with dueDate {string}', async function (taxCode, dueDate) { this.response = await getNotices(taxCode, formatWithValidYear(dueDate)); }); +When('an Http GET request is sent to recover notices for taxCode {string}', + async function (taxCode) { + this.response = await getNotices(taxCode, null); + }); + Then('response contains notice {string}', function (expectedCode) { assert.ok(this.response?.data?.some(item => item.iupd === expectedCode)); }); +Then('payments options has size {int}', function (expectedSize) { + assert.strictEqual(this.response?.data[0].paymentOptions.length, expectedSize); +}); + +Then('payments option n {int} has {int} installments', function (i, expectedSize) { + assert.strictEqual(this.response?.data[0].paymentOptions[i - 1].installments.length, expectedSize); +}); + Then('response has size {int}', function (expectedSize) { assert.strictEqual(this.response?.data?.length, expectedSize); }); diff --git a/integration-test/src/step_definitions/support/client/payment_pull_client.js b/integration-test/src/step_definitions/support/client/payment_pull_client.js index 648c408..3c3043a 100644 --- a/integration-test/src/step_definitions/support/client/payment_pull_client.js +++ b/integration-test/src/step_definitions/support/client/payment_pull_client.js @@ -4,13 +4,17 @@ const GPD_PULL_HOST = process.env.GPD_PULL_HOST; const API_TIMEOUT = process.env.API_TIMEOUT; async function getNotices(taxCode, dueDate) { + let params = { + page: 0, + size: 10 + }; + + if (dueDate) { + params.dueDate = dueDate; + } const data = await get(GPD_PULL_HOST + `/payment-notices/v1`, { timeout: API_TIMEOUT, - params: { - dueDate: dueDate, - page: 0, - size: 5 - }, + params, headers: { "x-tax-code": taxCode, "Ocp-Apim-Subscription-Key": process.env.GPD_PULL_API_SUBSCRIPTION_KEY, diff --git a/integration-test/src/step_definitions/support/utility/request_builder.js b/integration-test/src/step_definitions/support/utility/request_builder.js index 023b4ad..bd3b5fc 100644 --- a/integration-test/src/step_definitions/support/utility/request_builder.js +++ b/integration-test/src/step_definitions/support/utility/request_builder.js @@ -1,5 +1,269 @@ const {addDays, buildStringFromDate, makeIdNumber, makeIdMix,} = require("./helpers"); +function buildDebtPositionOneOption(iupd, iuv, organizationCode, taxCode) { + return { + "iupd": iupd, + "organizationFiscalCode": organizationCode, + "type": "F", + "companyName": "EC Demo Pagamenti Pull Test", + "fullName": "EC Demo Pagamenti Pull Test", + "fiscalCode": taxCode, + "officeName": null, + "validityDate": null, + "switchToExpired": false, + "paymentOption": [ + { + "iuv": iuv, + "organizationFiscalCode": organizationCode, + "amount": 120, + "description": "Test Pull - unica opzione", + "isPartialPayment": false, + "dueDate": "2024-10-30T23:59:59", + "retentionDate": "2024-11-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 120, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + } + ] + }; +} + +function buildDebtPositionComplex(iupd, organizationCode, taxCode) { + return { + "iupd": iupd, + "organizationFiscalCode": organizationCode, + "type": "F", + "companyName": "EC Demo Pagamenti Pull Test", + "fullName": "EC Demo Pagamenti Pull Test", + "fiscalCode": taxCode, + "officeName": null, + "validityDate": null, + "switchToExpired": false, + "paymentOption": [ + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 120, + "description": "Test Pull - opzione totale e piano rateale", + "isPartialPayment": false, + "dueDate": "2024-10-30T23:59:59", + "retentionDate": "2024-11-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 120, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 100, + "description": "Test Pull - opzione totale e piano rateale", + "isPartialPayment": true, + "dueDate": "2024-10-30T23:59:59", + "retentionDate": "2024-10-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 100, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 200, + "description": "Test Pull - opzione totale e piano rateale", + "isPartialPayment": true, + "dueDate": "2024-11-30T23:59:59", + "retentionDate": "2024-11-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 200, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 300, + "description": "Test Pull - opzione totale e piano rateale", + "isPartialPayment": true, + "dueDate": "2024-12-30T23:59:59", + "retentionDate": "2024-12-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 300, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + } + ] + }; +} + +function buildDebtPositionWithInstallments(iupd, organizationCode, taxCode) { + return { + "iupd": iupd, + "organizationFiscalCode": organizationCode, + "type": "F", + "companyName": "EC Demo Pagamenti Pull Test", + "fullName": "EC Demo Pagamenti Pull Test", + "fiscalCode": taxCode, + "officeName": null, + "validityDate": null, + "switchToExpired": false, + "paymentOption": [ + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 100, + "description": "Test Pull - piano rateale", + "isPartialPayment": true, + "dueDate": "2024-10-30T23:59:59", + "retentionDate": "2024-10-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 100, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 200, + "description": "Test Pull - piano rateale", + "isPartialPayment": true, + "dueDate": "2024-11-30T23:59:59", + "retentionDate": "2024-11-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 200, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 300, + "description": "Test Pull - piano rateale", + "isPartialPayment": true, + "dueDate": "2024-12-30T23:59:59", + "retentionDate": "2024-12-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 300, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + }, + { + "iuv": makeIdNumber(17), + "organizationFiscalCode": organizationCode, + "amount": 400, + "description": "Test Pull - piano rateale", + "isPartialPayment": true, + "dueDate": "2025-01-30T23:59:59", + "retentionDate": "2025-01-30T23:59:59", + "paymentDate": null, + "reportingDate": null, + "paymentMethod": "CP", + "pspCompany": null, + "transfer": [ + { + "organizationFiscalCode": organizationCode, + "companyName": "test", + "idTransfer": "1", + "amount": 400, + "remittanceInformation": "Test Pull", + "category": "9/0101108TS/", + "iban": "IT60X0542811101000000123456" + } + ] + } + ] + }; +} + function buildDebtPositionDynamicData(gpdSessionBundle, iupdIn) { return { iupd: iupdIn, @@ -78,5 +342,8 @@ function buildUpdateDebtPositionRequest(debtPosition, payer) { module.exports = { buildDebtPositionDynamicData, - buildUpdateDebtPositionRequest + buildUpdateDebtPositionRequest, + buildDebtPositionOneOption, + buildDebtPositionComplex, + buildDebtPositionWithInstallments }