Skip to content

Commit

Permalink
Merge branch 'main' into CHK-3174-enforce-no-cache-index
Browse files Browse the repository at this point in the history
  • Loading branch information
infantesimone authored Sep 25, 2024
2 parents da95bb2 + 00f5fc5 commit f11dcac
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 13 deletions.
16 changes: 15 additions & 1 deletion .devops/pagopa-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ stages:
io_api_path: '/ecommerce/webview/v1'
npg_sdk_url: 'https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js'
gdi_check_timeout: 12000
io_client_redirect_outcome_path: '/pp-restapi/v4'
io_client_redirect_outcome_path: 'https://api.dev.platform.pagopa.it/ecommerce/io-outcomes/v1/transactions'
checkout_client_redirect_outcome_path: 'https://dev.checkout.pagopa.it/v2/esito'

- script: |
Expand Down Expand Up @@ -154,6 +154,11 @@ stages:
displayName: 'export envs from .env.development'
workingDirectory: pagopa-ecommerce-fe
- script: |
yarn start-io-mock &
displayName: 'Start ecommerce fe IO mock'
workingDirectory: pagopa-ecommerce-fe
- script: |
yarn dev &
displayName: 'Start ecommerce fe'
Expand All @@ -166,6 +171,15 @@ stages:
- script: yarn test:integration
displayName: 'Integration tests exec'
workingDirectory: pagopa-ecommerce-fe

- script: |
yarn dev:env:noredirect &
displayName: 'Set ecommerce fe with noredirect env'
workingDirectory: pagopa-ecommerce-fe
- script: yarn test:noredirect
displayName: 'IO noredirect button Integration tests exec'
workingDirectory: pagopa-ecommerce-fe

- task: PublishTestResults@2
displayName: 'Publish integration tests results from Jest tests'
Expand Down
6 changes: 3 additions & 3 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ECOMMERCE_CHECKOUT_API_PATH=/ecommerce/checkout/v1
ECOMMERCE_IO_API_PATH=/ecommerce/webview/v1
ECOMMERCE_GDI_CHECK_TIMEOUT=12000
ECOMMERCE_NPG_SDK_URL=https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js
ECOMMERCE_IO_CLIENT_REDIRECT_OUTCOME_PATH=test
ECOMMERCE_IO_CLIENT_REDIRECT_OUTCOME_PATH=http://localhost:1234/ecommerce/io-outcomes/v1/transactions
ECOMMERCE_CHECKOUT_CLIENT_REDIRECT_OUTCOME_PATH=http://localhost:1234/v2/esito
ECOMMERCE_GET_TRANSACTION_POLLING_DELAY_MILLIS=1000
ECOMMERCE_GET_TRANSACTION_POLLING_RETRIES=4
ECOMMERCE_GET_TRANSACTION_POLLING_DELAY_MILLIS=100
ECOMMERCE_GET_TRANSACTION_POLLING_RETRIES=2
1 change: 1 addition & 0 deletions .env.development.noredirect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ECOMMERCE_IO_CLIENT_REDIRECT_OUTCOME_PATH=iowallet://localhost:1234/ecommerce/io-outcomes/v1/transactions
11 changes: 3 additions & 8 deletions .proxyrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,22 @@
* and the API proxy server (thanks to http-proxy-middleware)
* on localhost:1234 so we don't have to deal with CORS.
*
* Note: to run the development server must be set IO_PAY_PORTAL_API_HOST=http://localhost:1234
* and apiHost with the host api (for example http://localhost:80).
*/

const {createProxyMiddleware} = require("http-proxy-middleware");

const apiHost = "http://127.0.0.1:8080";
const apiHostIO = "http://127.0.0.1:8082";
const ecommerceBasepathV1 = "/ecommerce/checkout/v1";
const ecommerceIOBasepathV1 = "/ecommerce/io/v1";
const ecommerceIOWebviewBasepathV1 = "/ecommerce/webview/v1";
const ecommerceIOBasepathV1 = "/ecommerce/webview/v1";

module.exports = function (app) {
app.use(createProxyMiddleware(ecommerceBasepathV1, {
target: apiHost,
}));

app.use(createProxyMiddleware(ecommerceIOBasepathV1, {
target: apiHost,
target: apiHostIO,
}));

app.use(createProxyMiddleware(ecommerceIOWebviewBasepathV1, {
target: apiHost,
}));
}
12 changes: 12 additions & 0 deletions jest.noredirect.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
preset: "jest-puppeteer",
testRegex: "./no-redirect.test\\.ts$",
reporters: [
'default',
[ 'jest-junit', {
outputDirectory: './test_reports',
outputName: 'ecommerce-no-redirect-TEST.xml',
} ]
]
};

2 changes: 1 addition & 1 deletion mock/io-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const express = require("express");
const port = 8080;
const port = 8082;
const app = express();

app.get("/ecommerce/webview/v1/transactions/:transactionId", (req, res) => {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
"build": "rimraf .cache && rimraf dist && parcel build src/index.html --public-url /ecommerce-fe",
"dev": "rimraf .cache && rimraf dist && npm-run-all generate type-check dev:env dev:server",
"proxy": "npm-run-all generate type-check dev:env dev:proxy",
"proxy:noredirect": "npm-run-all generate type-check dev:env:noredirect dev:proxy",
"dev:env": "export $(grep -v '^#' .env.development | xargs) && chmod +x env.sh && ./env.sh",
"dev:env:noredirect": "export $(grep -vh '^#' .env.development .env.development.noredirect | xargs) && chmod +x env.sh && ./env.sh",
"dev:server": "parcel src/index.html &",
"dev:proxy": "parcel src/index.html",
"test": "jest --config=jest.config.js",
"test:integration": "jest --config=jest.integration.config.js",
"test:noredirect": "jest --config=jest.noredirect.config.js",
"test:coverage": "jest --coverage --passWithNoTests --config=package.json",
"preversion": "auto-changelog --config .auto-changelog.json --unreleased --commit-limit false --stdout --template preview.hbs",
"version": "auto-changelog -p --config .auto-changelog.json --unreleased && git add CHANGELOG.md",
Expand Down
60 changes: 60 additions & 0 deletions src/__integration_tests__/final-status-io.integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import "expect-puppeteer";

describe("Check final status on IO mapping tests", () => {
/**
* Test input and configuration
*/

const ECOMMERCE_FE_ESITO_PAGE = "http://localhost:1234/ecommerce-fe/esito#clientId=IO&sessionToken=test&transactionId=";

/**
* Add all mock flow. Reference to the flow defined into the checkout be mock
*/
const mockTransactionIdsWithExpectedResultMap = new Map([
["302054585254587560","0"],
["302054585254587561","0"],
["302054585254587562","1"],
["302054585254587563","0"],
["302054585254587564","1"],
["302054585254587565","1"],
["302054585254587566","1"],
["302054585254587567","1"],
["302054585254587568","1"],
["302054585254587569","4"],
["302054585254587570","8"],
["302054585254587571","8"],
["302054585254587572","1"],
["302054585254587573","8"],
["302054585254587574","1"],
["302054585254587575","2"],
["302054585254587576","17"],
["302054585254587577","1"],
["302054585254587578","0"],
["302054585254587579","17"]
]);


/**
* Default test timeout (80000ms)
*/
jest.setTimeout(80000);
jest.retryTimes(3);
page.setDefaultNavigationTimeout(80000);
page.setDefaultTimeout(80000);

beforeAll(async () => {
await page.goto(ECOMMERCE_FE_ESITO_PAGE);
await page.setViewport({ width: 1200, height: 907 });
})


for (const [transactionId, expectedOutcome] of mockTransactionIdsWithExpectedResultMap) {
it(`TransactionId ${transactionId} with expected outcome: ${expectedOutcome}`, async() => {
console.log(`Executing transactionId: [${transactionId}]. expected outcome: [${expectedOutcome}]`);
await page.goto(ECOMMERCE_FE_ESITO_PAGE + transactionId);
await page.waitForFunction("window.location.pathname.includes('ecommerce/io-outcomes/v1/transactions')")
const pollingOutcome = Number.parseInt(page.url().split("outcome=")[1]);
expect(pollingOutcome).toBe(Number.parseInt(expectedOutcome));
})
}
});
25 changes: 25 additions & 0 deletions src/__integration_tests__/no-redirect.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "expect-puppeteer";

describe("Test showing final button for continue to IO", () => {

const ECOMMERCE_FE_ESITO_PAGE = "http://localhost:1234/ecommerce-fe/esito#clientId=IO&sessionToken=test&transactionId=302054585254587560";

/**
* Default test timeout (80000ms)
*/
jest.setTimeout(80000);
jest.retryTimes(3);
page.setDefaultNavigationTimeout(80000);
page.setDefaultTimeout(80000);

beforeAll(async () => {
await page.setViewport({ width: 1200, height: 907 });
})


it(`Test IO button on success payment flow`, async() => {
console.log("Start outcome page with IO app redirect")
await page.goto(ECOMMERCE_FE_ESITO_PAGE);
await page.waitForSelector('#continueToIOBtn');
})
});

0 comments on commit f11dcac

Please sign in to comment.