Skip to content

Commit

Permalink
[PAGOPA-959] test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang committed Aug 21, 2023
1 parent 632063b commit 3bded4d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 19 deletions.
6 changes: 3 additions & 3 deletions integration-test/src/config/.env.uat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ nodo_host=https://api.uat.platform.pagopa.it/nodo
creditor_institution_id=77777777777
broker_id=15376371009
station_id=15376371009_01
psp_id=60000000001
channel_id=60000000001_01
psp_id=AGID_01
channel_id=97735020584_03
reporting_batch_wait_execution_sec=120
include_debug_logs=true
include_debug_logs=false
17 changes: 9 additions & 8 deletions integration-test/src/features/01_reporting_batch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ Feature: All about flow report retrieving workflow - Reporting batch component
* a paid debt position

Scenario: Reporting - Reporting batch no computed flow
Given the current flows list size
When the reporting batch analyzes the reporting flows for the organization
And the client waits its execution
Then the client asks the flow list for the organization
* the client receives status code 200
* the client receives an empty list of flows
* the client receives an empty list of new flows

# Scenario: Reporting - Reporting batch Happy path
# Given a report flow sent to Node
# When the reporting batch analyzes the reporting flows for the organization
# And the client waits its execution
# Then the client asks the flow list for the organization
# * the client receives status code 200
# * the client receives a non-empty list of flows
Scenario: Reporting - Reporting batch Happy path
Given a report flow sent to Node
When the reporting batch analyzes the reporting flows for the organization
And the client waits its execution
Then the client asks the flow list for the organization
* the client receives status code 200
* the client receives a non-empty list of flows
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const assert = require("assert");

async function assertEmptyList(response) {
console.log(` - -> the client receives an empty list of flows..`);
assert.ok(response.data.length === 0);
async function assertEmptyList(response, flows) {
console.log(` - -> the client receives an empty list of flows: ${(response.data.length - flows.size)} flows`);
assert.ok((response.data.length - flows.size) === 0);
}

async function assertNonEmptyList(response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ async function generateAndPayDebtPosition(bundle) {

response = await payDebtPosition(bundle.creditorInstitution.id, bundle.debtPosition.paymentOption[0].iuv, buildPayRequest(bundle));
debugLog(`Debt position payment sending API invocation returned HTTP status code: ${response.status} with body: ${JSON. stringify(response.data)}`);
assert.strictEqual(response.status, 200);
assert([200, 409].includes(response.status));
//assert.strictEqual(response.status, 200);

/*
response = await sendRT(buildSendRTRequest(bundle));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ async function sendReportFlowToNode(bundle) {
assert.match(response.data, new RegExp(`<totRestituiti>.+</totRestituiti>`, "g"));
}

async function getCurrentListSize(bundle, flows) {
console.log(` - Then the client asks the flow list for the organization with id [${bundle.creditorInstitution.id}]..`);
bundle.response = await getFlowList(bundle.creditorInstitution.id);
debugLog(`Report flow list retrieving API invocation returned HTTP status code: ${bundle.response.status} with body: ${JSON.stringify(bundle.response.data)}`);
flows.size = bundle.response.data.length;
console.log(` - -> the client receives a list of ${flows.size} flows`);
}

async function waitWholeReportingProcessExecution() {
console.log(` - -> the client waits its execution for [${process.env.reporting_batch_wait_execution_sec}] seconds. Please wait..`);
await new Promise(resolve => setTimeout(resolve, process.env.reporting_batch_wait_execution_sec * 1000));
Expand All @@ -52,5 +60,6 @@ module.exports = {
retrieveReportFlow,
retrieveReportFlowList,
sendReportFlowToNode,
waitWholeReportingProcessExecution
waitWholeReportingProcessExecution,
getCurrentListSize
}
6 changes: 4 additions & 2 deletions integration-test/src/step_definitions/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const {
retrieveReportFlow,
sendReportFlowToNode,
waitWholeReportingProcessExecution,
getCurrentListSize
} = require('./logic/reporting_logic');
const { bundle } = require('./utility/data');
const { bundle, flows } = require('./utility/data');

/* Setting defaul timeout to 10s. */
setDefaultTimeout(120 * 1000);
Expand All @@ -42,6 +43,7 @@ Given('reporting analysis service running', () => executeHealthCheckForReporting
Given('a not paid debt position', () => generateDebtPosition(bundle, true));
Given('a paid debt position', () => generateAndPayDebtPosition(bundle));
Given('a report flow sent to Node', () => sendReportFlowToNode(bundle));
Given('the current flows list size', () => getCurrentListSize(bundle, flows));


/*
Expand All @@ -63,7 +65,7 @@ Then('the client asks the detail for the analyzed debt positions', () => retriev
*/
Then('the client receives status code {int}', (statusCode) => assertStatusCode(bundle.response, statusCode));
Then('the client receives a non-empty list of flows', () => assertNonEmptyList(bundle.response));
Then('the client receives an empty list of flows', () => assertEmptyList(bundle.response));
Then('the client receives an empty list of new flows', () => assertEmptyList(bundle.response, flows));
Then('the client receives the flow XML content', () => assertFlowXMLContent(bundle.response, bundle.flow.id));
Then('the client receives the payment options with status {string}', (status) => assertPaymentOptionStatus(bundle.response, status));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ let bundle = {
response: undefined
};

let flows = {
size: 0
}

module.exports = {
bundle
bundle,
flows
}

0 comments on commit 3bded4d

Please sign in to comment.