Skip to content

Commit

Permalink
e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Apr 11, 2024
1 parent 326913d commit 59070a8
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 8 deletions.
26 changes: 25 additions & 1 deletion integration-test/src/features/payment_notices.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 53 additions & 1 deletion integration-test/src/step_definitions/payment_notice_step.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 59070a8

Please sign in to comment.