Skip to content

Commit

Permalink
PAGOPA-2348 adding scenario and change datatable cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
FedericoRuzzier committed Nov 8, 2024
1 parent 2e6a0f2 commit 50b93d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
35 changes: 35 additions & 0 deletions integration-test/src/features/getFeesMulti.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ Feature: GetFees - Get List of fees by CI, amount, method, touchpoint
| "77777777777" |
| "77777777777" |

Scenario: Commission is higher than the sum of the fees with one psp
Given initial json
"""
{
"bin": "309500",
"paymentMethod": "CP",
"touchpoint": "CHECKOUT",
"idPspList": [{"idPsp":"PPAYITR1XXX"}],
"paymentNotice": [
{
"primaryCreditorInstitution": "77777777777",
"paymentAmount": 899999999999999,
"transferList": [
{
"creditorInstitution": "77777777777",
"transferCategory": "TAX1"
}
]
}
]
}
"""
When the client send a V2 POST to /fees
Then check statusCode is 200
And the body response has one bundle for each psp
And the body response ordering for the bundleOptions.onUs field is:
| onUs |
| true |
And the body response for the bundleOptions.idsCiBundle field is:
| idCiBundle |
| "int-test-cart-1" |
And the sum of the fees is correct and the EC codes are:
| feeCode |
| "77777777777" |

Scenario: Commission is lower than the sum of the fees
Given initial json
"""
Expand Down
11 changes: 5 additions & 6 deletions integration-test/src/step_definitions/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Then('the body response ordering for the bundleOptions.onUs field is:', function
// true values first
return (a.onUs === b.onUs)? 0 : a.onUs? -1 : 1;
});
for (let i=0; i<responseToCheck.data.bundleOptions.length; i++){
for (let i=0; i<dataTable.rows().length; i++){
let bodyOnUs = responseToCheck.data.bundleOptions[i].onUs;
let checkOnUs = JSON.parse(dataTable.rows()[i][0]);
assert.equal(bodyOnUs, checkOnUs)
Expand All @@ -127,7 +127,6 @@ Then('the body response has one bundle for each psp', function () {
assert(!idPsps.includes(responseToCheck.data.bundleOptions[i].idPsp));
idPsps.push(responseToCheck.data.bundleOptions[i].idPsp);
}
console.log(idPsps);
});

Then('the body response does not contain the Poste idPsp', function () {
Expand All @@ -138,8 +137,8 @@ Then('the body response does not contain the Poste idPsp', function () {
});

Then('the body response for the bundleOptions.idsCiBundle field is:', function (dataTable) {
for (let i=0; i<responseToCheck.data.bundleOptions.length; i++){
for(let j=0; j<responseToCheck.data.bundleOptions[i].idsCiBundle.length; j++){
for (let i=0; i<dataTable.rows().length; i++){
for(let j=0; j<dataTable.rows()[i].length; j++){
let bodyIdCiBundle = responseToCheck.data.bundleOptions[i].idsCiBundle[j];
let checkIdCiBundle = JSON.parse(dataTable.rows()[i][j]);
assert.equal(bodyIdCiBundle, checkIdCiBundle)
Expand All @@ -149,12 +148,12 @@ Then('the body response for the bundleOptions.idsCiBundle field is:', function (

Then('the sum of the fees is correct and the EC codes are:', function (dataTable) {
let sumFee = 0;
for (let i=0; i<responseToCheck.data.bundleOptions.length; i++){
for (let i=0; i<dataTable.rows().length; i++){
responseToCheck.data.bundleOptions[i].fees.sort(function (a, b) {
// alphabetical order
return (a.creditorInstitution > b.creditorInstitution) ? 1 : ((b.creditorInstitution > a.creditorInstitution) ? -1 : 0);
});
for(let j=0; j<responseToCheck.data.bundleOptions[i].fees.length; j++){
for(let j=0; j<dataTable.rows()[i].length; j++){
let bodyFeeCode = responseToCheck.data.bundleOptions[i].fees[j].creditorInstitution;
let checkFeeCode = JSON.parse(dataTable.rows()[i][j]);
assert.equal(bodyFeeCode, checkFeeCode);
Expand Down

0 comments on commit 50b93d6

Please sign in to comment.