From a40dab1556fbaff905d90aaa145213a01673cd7a Mon Sep 17 00:00:00 2001 From: Samuele Varianti <128470180+svariant@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:22:45 +0200 Subject: [PATCH] New Release 1.30.4 (#646) * [VAS-418] feat: Align tos page with design (#579) * Bump to version 1.26.0-1-next * merge * fix: PaymentNoticesDetailPage.tsx posteAuth (#577) * Bump to version 1.26.0-2-next * fix github.head_ref in the action * feat: Review channel flow (#573) * [VAS-998] feat: introducing ops review from channel * [VAS-998] feat: Updated ops review modal management for channels * [VAS-997] changed channels page structured and integrated new getChannels API * [VAS-997] updated tests * [VAS-998] feat: Updated addEdit, details and tests * [VAS-998] feat: Updated tests, introduced common header to avoid duplicates * [VAS-998] feat: temporary rollback test * [VAS-998] feat: Update GetChannelAlert.test.tsx * [VAS-998] feat: Update ci_code_review.yml * [VAS-998] feat: Updated GetChannelAlert.test.tsx * [VAS-997] fix after merge with VAS-998 * fix client after merge * [VAS-997] fix: Width row station name * [VAS-997] fix: Improve createdBy/modifiedBy station detail * [VAS-997] fix: Handle change page channels table * [VAS-997] feat: Add alert channels details * [VAS-997] chore: Refactor detail button station detail * [VAS-997] feat: Refactor ChannelDetail component & improve UI * [VAS-997] feat: New translations * [VAS-997] fix: Refactor & format + fix translations * [VAS-997] feat: Delete unused component * [VAS-997] fix: Wrapper status chip translation for operators * [VAS-997] chore: Clean code * fixed client * [VAS-997] fixed unit tests * [VAS-997] add unit tests * [VAS-997] improve tests * [VAS-997] improve coverage --------- Co-authored-by: Alessio Cialini Co-authored-by: svariant Co-authored-by: Samuele Varianti <128470180+svariant@users.noreply.github.com> Co-authored-by: Jacopo Carlini * Bump to version 1.26.0-3-next * [VAS-1123] feat: Remove unused Station and Channel API (#574) * [VAS-998] feat: introducing ops review from channel * [VAS-998] feat: Updated ops review modal management for channels * [VAS-997] changed channels page structured and integrated new getChannels API * [VAS-997] updated tests * [VAS-998] feat: Updated addEdit, details and tests * [VAS-998] feat: Updated tests, introduced common header to avoid duplicates * [VAS-998] feat: temporary rollback test * [VAS-998] feat: Update GetChannelAlert.test.tsx * [VAS-998] feat: Update ci_code_review.yml * [VAS-998] feat: Updated GetChannelAlert.test.tsx * [VAS-997] fix after merge with VAS-998 * fix client after merge * [VAS-1123] replace old merged API with new get Stations and Channels * [VAS-1123] fixed tests * [VAS-1123] fix after merge * [VAS-1123] fix test after merge * [VAS-1123] removed useless file and added tests * improve coverage * improve for coverage --------- Co-authored-by: Alessio Cialini Co-authored-by: Samuele Varianti <128470180+svariant@users.noreply.github.com> * Bump to version 1.26.0-4-next * [VAS-1104] feat: New bundle status for available but expired bundles (#580) * [VAS-1104] feat: New bundle status for available but expired bundles * [VAS-1104] feat: Add alert bundle expired * [VAS-1104] chore: BE openapi * [VAS-1104] feat: Changes after UI designer advice * [VAS-1104] chore: Fix unit tests * Bump to version 1.26.0-5-next * [VAS-1103] feat: Add new field pspBusinessName to bundle details (#583) * [VAS-1103] feat: Add new field pspBusinessName to bundle details * Update src/locale/it.json Co-authored-by: Jacopo Carlini * [VAS-1103] fix: Unit tests --------- Co-authored-by: Jacopo Carlini * Bump to version 1.26.0-6-next * [VAS-1095] feat: e2e PSP's & CI's actions on private bundle (#570) * [VAS-1096] feat: Define publicBundles e2e tests * [VAS-1096] feat: e2e validate bundle api * [VAS-1096] feat: Implement temporary new state for ci bundles + uniform code * [VAS-1096] feat: Conclude publicBundles e2e tests * [VAS-1095] feat: e2e private bundles * [VAS-1096] chore: fix unit tests * [VAS-1096] feat: Re-enable e2e paraller workers * [VAS-1095] fix: Click on popup * [VAS-1095] feat: Add control on login page * [VAS-1095] feat: Improve e2e tests * [VAS-1095] fix: Public bundles e2e * [VAS-1095] chore: Max number of failures e2e * [VAS-1095] fix: e2e subkey env name * {VAS-1095] fix: e2e Added condition * [VAS-1095] fix: Added timeout e2e * [VAS-1095] fix: Increase timeout * [VAS-1095] fix: Changed timeouts * [VAS-1095] fix: Increase timeout * [VAS-1095] chore: Delete obsolete puppeteer int test * [VAS-1095] fix: Improved check return homepage * [VAS-1095] timeout * [VAS-1095] fix: e2e change browser driver to firefox + timeout fixes * [VAS-1095] feat: Add delete bundle api to cleanup * [VAS-1095] chore: Add log response * [VAS-1095] feat: Add subkey int test keyvault * [VAS-1095] notify * [VAS-1095] fix: e2e clean up * [VAS-1095] special secret * [VAS-1095] debug * [VAS-1095] secret * [VAS-1095] create jwt * [VAS-1095] gitignore * [VAS-1095] github pages * [VAS-1095] chore: Re commit tsconfig * [VAS-1095] fix: e2e static analysis * [VAS-1095] chore: Sonar cpd exclusion e2e --------- Co-authored-by: Jacopo * Bump to version 1.26.0-7-next * chore: Merge main into next (#585) * build(deps-dev): Bump eslint-plugin-react from 7.30.0 to 7.34.3 Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.30.0 to 7.34.3. - [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases) - [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md) - [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.30.0...v7.34.3) --- updated-dependencies: - dependency-name: eslint-plugin-react dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1 (#565) * build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1 Bumps [react-use-scrollspy](https://github.com/Purii/react-use-scrollspy) from 3.0.2 to 3.1.1. - [Release notes](https://github.com/Purii/react-use-scrollspy/releases) - [Changelog](https://github.com/Purii/react-use-scrollspy/blob/main/CHANGELOG.md) - [Commits](https://github.com/Purii/react-use-scrollspy/compare/v3.0.2...v3.1.1) --- updated-dependencies: - dependency-name: react-use-scrollspy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * build(deps): Bump react-use-scrollspy from 3.0.2 to 3.1.1 Bumps [react-use-scrollspy](https://github.com/Purii/react-use-scrollspy) from 3.0.2 to 3.1.1. - [Release notes](https://github.com/Purii/react-use-scrollspy/releases) - [Changelog](https://github.com/Purii/react-use-scrollspy/blob/main/CHANGELOG.md) - [Commits](https://github.com/Purii/react-use-scrollspy/compare/v3.0.2...v3.1.1) --- updated-dependencies: - dependency-name: react-use-scrollspy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * [react-use-scrollspy-3] delete branch * [react-use-scrollspy-3] if condition delete branch --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo * build(deps-dev): Bump @babel/core from 7.24.4 to 7.24.7 (#567) Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.24.4 to 7.24.7. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.24.7/packages/babel-core) --- updated-dependencies: - dependency-name: "@babel/core" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * build(deps): Bump @mui/system from 5.15.15 to 5.15.20 (#566) Bumps [@mui/system](https://github.com/mui/material-ui/tree/HEAD/packages/mui-system) from 5.15.15 to 5.15.20. - [Release notes](https://github.com/mui/material-ui/releases) - [Changelog](https://github.com/mui/material-ui/blob/v5.15.20/CHANGELOG.md) - [Commits](https://github.com/mui/material-ui/commits/v5.15.20/packages/mui-system) --- updated-dependencies: - dependency-name: "@mui/system" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * added missing call for station in status TO_FIX_UPDATE (#581) Co-authored-by: Jacopo Carlini * Bump to version 1.26.1 [skip ci] * Pin actions/checkout action to ee0669b (#582) Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * fix delete branch * Update README.md * Update README.md --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini Co-authored-by: gioelemella <128155546+gioelemella@users.noreply.github.com> Co-authored-by: pagopa-github-bot Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com> * Bump to version 1.26.1-1-next * [VAS-1133] feat: Add new api key for printPaymentsNotice product (#584) * [VAS-1133] feat: Introduce print notice api key list element * [VAS-1133] fix: Api key products psp * [VAS-1133] feat: Refactor api key products * [VAS-1133] feat: Introduce flag print notice for api keys * [VAS-1133] chore: Api key unit test coverage * Bump to version 1.26.1-2-next * fix: Updated AddEditCommissionBundleForm.tsx to call brokerDelegation as an institution (#587) * Bump to version 1.26.1-3-next * [VAS-1070] feat; Change station and channel detail view on pending update (#586) * [VAS-1070] improved station API and removed wrapper status value from body * [VAS-1070] integrated new station and channel detail API and removed unused ones. * [VAS-1070] fix unit tests * [VAS-1070] handled station and channel with pending update * [VAS-1070] added common component for alert in station and channel detail page * [VAS-1070] removed created by when undefined * [VAS-1070] fix unit tests * [VAS-1070] fix title * [VAS-1070] rename variable * Bump to version 1.26.3-1-next * notify * fix missing translate (#596) * Bump to version 1.26.4-1-next * fix: Bugs found before release (#597) * fix: Bundle -> hide delete & disable invite EC buttons if bundle is expired * fix: Newconnectivity select channels * fix: Margin top checkbox channels edit page * fix: Unit tests * empty commit * Bump to version 1.26.4-2-next * [VAS-1146] feat: Implement new boolean "cart" for bundles (#605) * [VAS-1146] feat: Implement new switch for cart bool in bundle add/edit page * [VAS-1146] chore: Unit tests * [VAS-1146] chore: Update packagejson openapi command * empty commit * [VAS-1146] fix: Unit tests * [VAS-1146] feat: Swap api call getChannelsDetails with primitive version check on list elements * [VAS-1146] feat: Improve unit test * [VAS-1146] fix: Unit tests * [VAS-1146] fix: Unit tests * [VAS-1146] feat: Add cart bool to bundle details drawer * fix unit test * [VAS-1146] feat: Improve code * Bump to version 1.26.4-3-next * build(deps): Bump axios from 0.28.1 to 1.7.2 (#599) Bumps [axios](https://github.com/axios/axios) from 0.28.1 to 1.7.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.28.1...v1.7.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * Bump to version 1.27.0-1-next * build(deps): Bump @types/node from 20.10.1 to 20.14.10 (#600) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.10.1 to 20.14.10. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * Bump to version 1.27.0-2-next * build(deps): Bump @mui/icons-material from 5.15.9 to 5.16.1 (#608) Bumps [@mui/icons-material](https://github.com/mui/material-ui/tree/HEAD/packages/mui-icons-material) from 5.15.9 to 5.16.1. - [Release notes](https://github.com/mui/material-ui/releases) - [Changelog](https://github.com/mui/material-ui/blob/v5.16.1/CHANGELOG.md) - [Commits](https://github.com/mui/material-ui/commits/v5.16.1/packages/mui-icons-material) --- updated-dependencies: - dependency-name: "@mui/icons-material" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jacopo Carlini * Bump to version 1.27.0-3-next * [VAS-1166] feat: add tos and privacy pages (#607) * [VAS-1116] feat: add privacy and tos pages * [VAS-1116] feat: Updated footer config, and management for the snippet pages * [VAS-1116] feat: Updated tests * [VAS-1116] feat: Updated Snippet.tsx * [VAS-1116] feat: Updated Snippet.tsx and tests * [VAS-1116] feat: Updated App.test.tsx * [VAS-1116] feat: Updated App.test.tsx * Bump to version 1.26.4-4-VAS-1166-feat-add-tos-and-privacy-pages [skip ci] * [VAS-1116] feat: Updated App.test * Bump to version 1.26.4-5-VAS-1166-feat-add-tos-and-privacy-pages [skip ci] --------- Co-authored-by: pagopa-github-bot Co-authored-by: Jacopo Carlini * Bump to version 1.27.0-4-next * fix: errorBoundary labels (#619) * Bump to version 1.28.1-1-next * [VAS-785] feat: Introduce new flags "standIn" & "aca" for CI-station relation (#606) * [VAS-785] fix: Bug disable assosiate ec to station button * [VAS-785] chore: Change openapi pr pointer * [VAS-785] feat: Define new redux state for stationCi relationships * [VAS-785] feat: Implement API to update CI-station relation * [VAS-785] feat: Improve routing to stationEC associate page to implement edit mode * [VAS-785] feat: Define new action columns stationEC table * [VAS-785] feat: Define new paper section with standIn and ACA flags and edit mode for StationAssociateEcPage * [VAS-785] feat: Complete implementation standIn & aca flags * [VAS-785] feat: Add new columns aca & standin to ectable * [VAS-785] chore: Unit test ec table columns * [VAS-785] chore: Station ec table coverage * [VAS-785] chore: Unit test station associate ec page * [VAS-785] fix: Hook problems * [VAS-785] fix: Hook with redirect * [VAS-785] chore: coverage * [VAS-1116] feat: Updated creditorInstitutionService.ts * [VAS-1116] feat: Updated creditorInstitutionService.ts * [VAS-785] feat: Updated stations mock * [VAS-785] feat: Updated StationECTableColumns.test.tsx and StationECTableColumns.tsx * [VAS-785] feat: Updated StationECTableColumns.test.tsx and StationECTableColumns.tsx --------- Co-authored-by: Alessio Cialini * Bump to version 1.28.1-2-next * [VAS-1204] feat: Change "I miei enti" to "Enti gestiti" (#625) * Bump to version 1.28.1-3-next * [PPANTT-41] feat: Station's maintenance list page (#627) * fix: Default values associate-EC form * [PPANTT-41] chore: Generate api PR name * [PPANTT-41] feat: Station Maintenance page & table * [PPANTT-41] feat: Station Maintenance route & sidenav * [PPANTT-41] chore: Cleaned code & minor fixes * [PPANTT-41] feat: Station Maintenance translations * [PPANTT-41] feat: Improvements year filter * [PPANTT-41] feat: Remove sortable column headers * [PPANTT-41] feat: Implement getStationMaintenances API * [PPANTT-41] feat: Add button and subtitle station maintenance page * [PPANTT-41] chore: Improve placeholder code * [PPANTT-41] feat: Changed maximum year filter * [PPANTT-41] fix: Station maintenance table properties * [PPANTT-41] fix: Error boundary page translation * [PPANTT-41] feat: Trigger search when reset filters * [PPANTT-41] fix: Remove empty state link when maintenance finished * [PPANTT-41] feat: Hours summary section & clean code * [PPANTT-41] feat: Implement maintenance row actions * [PPANTT-41] feat: Add alert message row action * [PPANTT-41] feat: New loading const * [PPANTT-41] chore: Update generate openapi command * [PPANTT-41] feat: Implement get hours summary & delete maintenance & terminate maintenance APIs * [PPANTT-41] feat: Change maintenance table format date with minutes * [PPANTT-41] chore: Unit test maintenance service & columns * [PPANTT-41] fix: Unit test * [PPANTT-41] chore: Improve comments future developments * [PPANTT-41] chore: Station maintenances components unit tests * chore: Fix smell * Bump to version 1.28.1-4-next * Bump to version 1.28.1-5-next [skip ci] * [PPANTT-42] feat: Station maintenances create/edit/details page (#628) * fix: Default values associate-EC form * [PPANTT-41] chore: Generate api PR name * [PPANTT-41] feat: Station Maintenance page & table * [PPANTT-41] feat: Station Maintenance route & sidenav * [PPANTT-41] chore: Cleaned code & minor fixes * [PPANTT-41] feat: Station Maintenance translations * [PPANTT-41] feat: Improvements year filter * [PPANTT-41] feat: Remove sortable column headers * [PPANTT-41] feat: Implement getStationMaintenances API * [PPANTT-41] feat: Add button and subtitle station maintenance page * [PPANTT-41] chore: Improve placeholder code * [PPANTT-41] feat: Changed maximum year filter * [PPANTT-41] fix: Station maintenance table properties * [PPANTT-41] fix: Error boundary page translation * [PPANTT-41] feat: Trigger search when reset filters * [PPANTT-41] fix: Remove empty state link when maintenance finished * [PPANTT-41] feat: Hours summary section & clean code * [PPANTT-41] feat: Implement maintenance row actions * [PPANTT-41] feat: Add alert message row action * [PPANTT-41] feat: New loading const * [PPANTT-41] chore: Update generate openapi command * [PPANTT-41] feat: Implement get hours summary & delete maintenance & terminate maintenance APIs * [PPANTT-41] feat: Change maintenance table format date with minutes * [PPANTT-41] chore: Unit test maintenance service & columns * [PPANTT-41] fix: Unit test * [PPANTT-41] chore: Improve comments future developments * [PPANTT-41] chore: Station maintenances components unit tests * chore: Fix smell * [PPANTT-42] feat: Implement new page to create/edit/view station's maintenance * fix: Unit tests * [PPANTT-42] feat: Implement create & edit APIs + redux store + general improvements & validation * [PPANTT-42] feat: Major improvements to station maintenances pages * [PPANTT-42] feat: Add error minDate * [PPANTT-42] feat: Datepickers disabled text input * [PPANTT-42] fix: Init input date * Bump to version 1.28.1-4-PPANTT-42-station-maintenances-create-edit-detail-page [skip ci] * [PPANTT-42] fix: Hours formatter * Bump to version 1.28.1-5-PPANTT-42-station-maintenances-create-edit-detail-page [skip ci] * [PPANTT-42] feat: New loading task constant * Bump to version 1.28.1-6-PPANTT-42-station-maintenances-create-edit-detail-page [skip ci] * [PPANTT-42] fix: Unit tests * [PPANTT-42] fix: Error messages * Bump to version 1.28.1-7-PPANTT-42-station-maintenances-create-edit-detail-page [skip ci] * [PPANTT-42] chore: Unit tests * [PPANTT-42] feat: Add success alert layout * [PPANTT-42] chore: Unit test * [PPANTT-42] chore: Coverage --------- Co-authored-by: pagopa-github-bot * Bump to version 1.28.1-8-next * Merge main next 1.29.3 (#635) * Merge branch 'main' into next * empty commit * Bump to version 1.29.3-1-next * [PPANTT-93] feat: Add api key ACA (#645) * [PPANTT-93] feat: Add new ACA products to api keys * Bump to version 1.30.3-2-PPANTT-93-new-aca-apikey-product [skip ci] --------- Co-authored-by: pagopa-github-bot * Bump to version 1.30.3-3-next [skip ci] * [PPANTT-9] feat: e2e delegations' page (#643) * [PPANTT-9] feat: e2e delegations' page * [PPANTT-9] feat: Changed GHA e2e test cron schedule * Bump to version 1.30.3-4-next * [PPANTT-26] feat: Changed bundle's channel list autocomplete from client to server side (#644) * Bump to version 1.30.3-5-next * Bump to version 1.30.3-6-next [skip ci] --------- Signed-off-by: dependabot[bot] Co-authored-by: pagopa-github-bot Co-authored-by: Jacopo Co-authored-by: Alessio Cialini <63233981+alessio-cialini@users.noreply.github.com> Co-authored-by: gioelemella <128155546+gioelemella@users.noreply.github.com> Co-authored-by: Alessio Cialini Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: renovate-pagopa[bot] <164534245+renovate-pagopa[bot]@users.noreply.github.com> --- .github/workflows/ci_integration_test.yml | 2 +- e2e/tests/delegations.spec.ts | 62 + package.json | 4 +- src/api/BackofficeClient.ts | 2 +- src/locale/it.json | 3 +- src/model/ApiKey.tsx | 2 + src/model/__tests__/ApiKey.test.tsx | 3 +- .../AddEditCommissionBundleForm.tsx | 1476 +++++++++-------- .../AddEditCommissionBundleForm.test.tsx | 10 +- 9 files changed, 830 insertions(+), 734 deletions(-) create mode 100644 e2e/tests/delegations.spec.ts diff --git a/.github/workflows/ci_integration_test.yml b/.github/workflows/ci_integration_test.yml index 6d01512eb..b7edd683a 100644 --- a/.github/workflows/ci_integration_test.yml +++ b/.github/workflows/ci_integration_test.yml @@ -2,7 +2,7 @@ name: Integration Tests on: schedule: - - cron: '00 09 * * *' + - cron: '00 09 * * 1,2,3,4,5' workflow_call: inputs: diff --git a/e2e/tests/delegations.spec.ts b/e2e/tests/delegations.spec.ts new file mode 100644 index 000000000..ab139b7dc --- /dev/null +++ b/e2e/tests/delegations.spec.ts @@ -0,0 +1,62 @@ +import { Page, test } from '@playwright/test'; +import { changeToEcUser, checkReturnHomepage } from './utils/e2eUtils'; + +const STATION_ID = '99999000013_02'; +const ecName = 'EC Signed Direct'; +const segregationCode = '40'; + +test.setTimeout(100000); +test.describe('Delegations flow', () => { + // eslint-disable-next-line functional/no-let + let page: Page; + + test.beforeAll(async ({ browser }) => { + page = await browser.newPage({ storageState: undefined }); + await changeToEcUser(page); + }); + + test.afterAll(async () => { + await page.close(); + }); + + test('Associate station to EC', async () => { + await page.getByTestId('stations-test').click(); + await page.getByTestId('search-input').click(); + await page.getByTestId('search-input').fill(STATION_ID); + await page.waitForTimeout(2000); + await page.getByLabel('more').click(); + await page.getByRole('link', { name: 'Gestisci EC' }).click(); + await page.getByRole('link', { name: 'Associa EC' }).click(); + await page.getByLabel('Cerca EC').click(); + await page.getByTestId('ec-selection-id-test').getByLabel('Cerca EC').fill('EC'); + await page.getByRole('option', { name: ecName }).click(); + await page.getByRole('combobox', { name: '​', exact: true }).click(); + await page.getByRole('option', { name: segregationCode }).click(); + await page.getByTestId('confirm-btn-test').click(); + await checkReturnHomepage(page); + }); + + test('Test delegations page & details', async () => { + await page.getByTestId('delegations-test').click(); + await page.getByTestId('search-input').click(); + await page.getByTestId('search-input').fill(ecName); + await page.getByTestId('button-search').click(); + await page.waitForTimeout(2000); + await page.getByTestId('column-go-to-delegation-detail').click(); + }); + + test('Disassociate station', async () => { + await page.getByTestId('search-input').click(); + await page.getByTestId('search-input').fill(STATION_ID); + await page.getByTestId('button-search').click(); + await page.waitForTimeout(2000); + await page.getByTestId('column-station-detail-button').click(); + await page.getByTestId('station-detail-disassociate-station-button').click(); + await page.getByTestId('cancel-button-test').click(); + await page.getByTestId('column-station-detail-button').click(); + await page.getByTestId('station-detail-disassociate-station-button').click(); + await page.getByTestId('confirm-button-test').click(); + await page.getByTestId('exit-btn-test').click(); + await checkReturnHomepage(page); + }); +}); diff --git a/package.json b/package.json index 15d290c85..c203b3af0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pagopa-selfcare-backoffice-frontend", - "version": "1.30.3", + "version": "1.30.3-6-next", "homepage": "ui", "private": true, "scripts": { @@ -28,7 +28,7 @@ "clean:api-portal": "rimraf src/api/generated/portal && rimraf openApi/generated", "generate:api-portal": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/main/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", "generate:api-portal-next": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/next/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", - "generate:api-portal-pr": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/PPANTT-48-add-finish-maintenance-api/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", + "generate:api-portal-pr": "wget https://raw.githubusercontent.com/pagopa/pagopa-selfcare-ms-backoffice-backend/PPANTT-93-new-api-key-aca/openapi/openapi.json -O ./openApi/portal-api-docs.json && npm run generate:client", "generate:api-portal-local": "npm run generate:client", "generate:client": "jq 'walk(if type == \"object\" and has(\"parameters\") then .parameters |= map(select(.name != \"X-Request-Id\")) else . end)' ./openApi/portal-api-docs.json > ./openApi/portal-api-docs.json.temp && mv ./openApi/portal-api-docs.json.temp ./openApi/portal-api-docs.json && yarn run clean:api-portal && mkdirp openApi/generated && gen-api-models --api-spec openApi/portal-api-docs.json --out-dir src/api/generated/portal --no-strict --request-types --response-decoders --client && node openApi/scripts/api-portal_fixPostGen.js" }, diff --git a/src/api/BackofficeClient.ts b/src/api/BackofficeClient.ts index a38ff26b3..7e9a0f851 100644 --- a/src/api/BackofficeClient.ts +++ b/src/api/BackofficeClient.ts @@ -399,7 +399,7 @@ export const BackofficeApi = { const result = await backofficeClient.getChannels({ status: String(status), brokerCode, - channelCode, + ...(channelCode ? {channelCode} : {}), limit, page, }); diff --git a/src/locale/it.json b/src/locale/it.json index 3799db66f..abe9abb14 100644 --- a/src/locale/it.json +++ b/src/locale/it.json @@ -253,7 +253,8 @@ "FDR_PSP": "FdR - Flussi di Rendicontazione (PSP)", "BO_EXT_EC": "Backoffice External (EC)", "BO_EXT_PSP": "Backoffice External (PSP)", - "PRINT_NOTICE": "Stampa Avvisi" + "PRINT_NOTICE": "Stampa Avvisi", + "ACA": "ACA - paCreatePosition" } }, "channelsPage": { diff --git a/src/model/ApiKey.tsx b/src/model/ApiKey.tsx index 78015b250..11c041646 100644 --- a/src/model/ApiKey.tsx +++ b/src/model/ApiKey.tsx @@ -29,6 +29,7 @@ export const API_KEY_PRODUCTS = { BO_EXT_EC: { id: 'BO_EXT_EC', key: 'selfcareboexternalec-' }, BO_EXT_PSP: { id: 'BO_EXT_PSP', key: 'selfcareboexternalpsp-' }, PRINT_NOTICE: { id: 'PRINT_NOTICE', key: 'printnotice-' }, + ACA: {id: "ACA", key:"aca-"} }; export const getApiKeyProducts = ( @@ -44,6 +45,7 @@ export const getApiKeyProducts = ( API_KEY_PRODUCTS.GPD_REP, API_KEY_PRODUCTS.BIZ, API_KEY_PRODUCTS.BO_EXT_EC, + API_KEY_PRODUCTS.ACA ]; if (ENV.FEATURES.FDR.ENABLED) { diff --git a/src/model/__tests__/ApiKey.test.tsx b/src/model/__tests__/ApiKey.test.tsx index 9d2437247..2794f4da2 100644 --- a/src/model/__tests__/ApiKey.test.tsx +++ b/src/model/__tests__/ApiKey.test.tsx @@ -12,7 +12,8 @@ describe("Test ApiKey model methods", ()=> { API_KEY_PRODUCTS.BIZ, API_KEY_PRODUCTS.BO_EXT_EC, API_KEY_PRODUCTS.FDR_ORG, - API_KEY_PRODUCTS.PRINT_NOTICE + API_KEY_PRODUCTS.PRINT_NOTICE, + API_KEY_PRODUCTS.ACA ]) }) }) \ No newline at end of file diff --git a/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx b/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx index 86c425bb1..a68eb94f8 100644 --- a/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx +++ b/src/pages/commisionalBundles/addEditCommissionBundle/components/AddEditCommissionBundleForm.tsx @@ -1,758 +1,788 @@ /* eslint-disable functional/no-let */ /* eslint-disable complexity */ /* eslint-disable sonarjs/cognitive-complexity */ -import {InfoOutlined, MenuBook} from '@mui/icons-material'; +import { InfoOutlined, MenuBook } from '@mui/icons-material'; import BookmarkAddIcon from '@mui/icons-material/BookmarkAdd'; import DateRangeIcon from '@mui/icons-material/DateRange'; import EuroIcon from '@mui/icons-material/Euro'; import { - Autocomplete, - Box, - FormControl, - FormControlLabel, - FormLabel, - Grid, - InputLabel, - MenuItem, - Paper, - Radio, - RadioGroup, - Select, - Switch, - TextField, - TextFieldProps, - Tooltip, - Typography, + Autocomplete, + Box, + FormControl, + FormControlLabel, + FormLabel, + Grid, + InputLabel, + MenuItem, + Paper, + Radio, + RadioGroup, + Select, + Switch, + TextField, + TextFieldProps, + Tooltip, + Typography, } from '@mui/material'; -import {DesktopDatePicker, LocalizationProvider} from '@mui/x-date-pickers'; -import {AdapterDateFns} from '@mui/x-date-pickers/AdapterDateFns'; -import {theme} from '@pagopa/mui-italia'; -import {useErrorDispatcher, useLoading} from '@pagopa/selfcare-common-frontend'; -import {FormikProps} from 'formik'; -import {add, isBefore} from "date-fns"; -import {useEffect, useState} from 'react'; -import {useTranslation} from 'react-i18next'; -import {NumericFormat} from 'react-number-format'; -import {BundleRequest} from '../../../../api/generated/portal/BundleRequest'; -import {Delegation} from '../../../../api/generated/portal/Delegation'; -import {TypeEnum} from '../../../../api/generated/portal/PSPBundleResource'; -import {PaymentTypes} from '../../../../api/generated/portal/PaymentTypes'; -import {Touchpoints} from '../../../../api/generated/portal/Touchpoints'; +import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers'; +import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; +import { theme } from '@pagopa/mui-italia'; +import { useErrorDispatcher, useLoading } from '@pagopa/selfcare-common-frontend'; +import { FormikProps } from 'formik'; +import { add, isBefore } from 'date-fns'; +import { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { NumericFormat } from 'react-number-format'; +import { BundleRequest } from '../../../../api/generated/portal/BundleRequest'; +import { Delegation } from '../../../../api/generated/portal/Delegation'; +import { TypeEnum } from '../../../../api/generated/portal/PSPBundleResource'; +import { PaymentTypes } from '../../../../api/generated/portal/PaymentTypes'; +import { Touchpoints } from '../../../../api/generated/portal/Touchpoints'; import FormSectionTitle from '../../../../components/Form/FormSectionTitle'; -import {useFlagValue} from '../../../../hooks/useFeatureFlags'; -import {useOrganizationType} from '../../../../hooks/useOrganizationType'; -import {Party} from '../../../../model/Party'; -import {sortPaymentType} from '../../../../model/PaymentType'; -import {ConfigurationStatus} from '../../../../model/Station'; -import {useAppSelector} from '../../../../redux/hooks'; -import {partiesSelectors} from '../../../../redux/slices/partiesSlice'; -import {getTouchpoints} from '../../../../services/bundleService'; -import {getChannels} from '../../../../services/channelService'; -import {getPaymentTypes} from '../../../../services/configurationService'; -import {getBrokerDelegation} from '../../../../services/institutionService'; -import {addCurrentBroker} from '../../../../utils/channel-utils'; -import {LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, LOADING_TASK_GET_CHANNELS_IDS,} from '../../../../utils/constants'; -import {WrapperChannelResource} from '../../../../api/generated/portal/WrapperChannelResource'; +import { useFlagValue } from '../../../../hooks/useFeatureFlags'; +import { useOrganizationType } from '../../../../hooks/useOrganizationType'; +import { Party } from '../../../../model/Party'; +import { sortPaymentType } from '../../../../model/PaymentType'; +import { ConfigurationStatus } from '../../../../model/Station'; +import { useAppSelector } from '../../../../redux/hooks'; +import { partiesSelectors } from '../../../../redux/slices/partiesSlice'; +import { getTouchpoints } from '../../../../services/bundleService'; +import { getChannels } from '../../../../services/channelService'; +import { getPaymentTypes } from '../../../../services/configurationService'; +import { getBrokerDelegation } from '../../../../services/institutionService'; +import { addCurrentBroker } from '../../../../utils/channel-utils'; +import { + LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS, + LOADING_TASK_GET_CHANNELS_IDS, +} from '../../../../utils/constants'; +import { WrapperChannelResource } from '../../../../api/generated/portal/WrapperChannelResource'; type Props = { - formik: FormikProps; - isEdit: boolean; - idBrokerPsp: string | undefined; + formik: FormikProps; + isEdit: boolean; + idBrokerPsp: string | undefined; }; -const AddEditCommissionBundleForm = ({isEdit, formik, idBrokerPsp}: Props) => { - const {t} = useTranslation(); - const {orgIsPspDirect} = useOrganizationType(); - const setLoading = useLoading(LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS); - const setLoadingChannels = useLoading(LOADING_TASK_GET_CHANNELS_IDS); - const addError = useErrorDispatcher(); - const isPrivateEnabled = useFlagValue('commission-bundles-private'); - const isPublicEnabled = useFlagValue('commission-bundles-public'); - const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); - - const [paymentOptions, setPaymentOptions] = useState(); - const [touchpointList, setTouchpointList] = useState(); - const [brokerDelegationList, setBrokerDelegationList] = useState>([]); - const [channels, setChannels] = useState>([]); - const [isChannelV2, setIsChannelV2] = useState(false); +const AddEditCommissionBundleForm = ({ isEdit, formik, idBrokerPsp }: Props) => { + const { t } = useTranslation(); + const { orgIsPspDirect } = useOrganizationType(); + const setLoading = useLoading(LOADING_TASK_COMMISSION_BUNDLE_SELECT_DATAS); + const setLoadingChannels = useLoading(LOADING_TASK_GET_CHANNELS_IDS); + const addError = useErrorDispatcher(); + const isPrivateEnabled = useFlagValue('commission-bundles-private'); + const isPublicEnabled = useFlagValue('commission-bundles-public'); + const selectedParty = useAppSelector(partiesSelectors.selectPartySelected); - const inputGroupStyle = { - borderRadius: 1, - border: 1, - borderColor: theme.palette.divider, - p: 3, - mb: 3, - }; + const [paymentOptions, setPaymentOptions] = useState(); + const [touchpointList, setTouchpointList] = useState(); + const [brokerDelegationList, setBrokerDelegationList] = useState>([]); + const [channels, setChannels] = useState>([]); + const [isChannelV2, setIsChannelV2] = useState(false); - const getChannelsByBrokerCode = (selectedBrokerCode: string) => { - setLoadingChannels(true); - getChannels({status: ConfigurationStatus.ACTIVE, brokerCode: selectedBrokerCode}) - .then((data) => { - if (data?.channels && data.channels.length > 0) { - setChannels([...data.channels]); - handleIsChannelV2(formik.values.idChannel, [...data.channels]); - } else { - setChannels([]); - addError({ - id: 'GET_BROKER_DELEGATIONS_DATA', - blocking: false, - error: new Error(`An error occurred while getting data`), - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBrokerDelegations' - ), - component: 'Toast', - }); - } - }) - .catch((error) => { - setChannels([]); - addError({ - id: 'GET_CHANNEL_IDS_DATA', - blocking: false, - error: error as Error, - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageChannelIdsDataDesc' - ), - component: 'Toast', - }); - }) - .finally(() => setLoadingChannels(false)); - }; + const [filterChannelCode, setFilterChannelCode] = useState(null); - useEffect(() => { - setLoading(true); - Promise.all([ - getPaymentTypes(), - getTouchpoints(0, 50), - getBrokerDelegation(selectedParty?.partyId ?? '', undefined), - ]) - .then(([paymentTypes, touchpoints, brokerDelegation]) => { - if (paymentTypes) { - setPaymentOptions(paymentTypes); - } - if (touchpoints) { - setTouchpointList(touchpoints); - } - let listBroker = brokerDelegation?.delegation_list - ? [...brokerDelegation.delegation_list] - : []; - if (orgIsPspDirect) { - listBroker = addCurrentBroker(listBroker, selectedParty as Party); - } + const inputGroupStyle = { + borderRadius: 1, + border: 1, + borderColor: theme.palette.divider, + p: 3, + mb: 3, + }; - if (listBroker.length > 0) { - setBrokerDelegationList(listBroker); - if (isEdit && idBrokerPsp) { - const brokerTaxCode = listBroker?.find( - (el) => el.broker_tax_code === idBrokerPsp - )?.broker_tax_code; - if (brokerTaxCode) { - getChannelsByBrokerCode(brokerTaxCode); - } - } - } else { - addError({ - id: 'GET_BROKER_DATA', - blocking: false, - error: new Error(`An error occurred while getting data`), - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBroker' - ), - component: 'Toast', - }); - } - }) - .catch((reason) => { - addError({ - id: 'GET_ALL_DATA', - blocking: false, - error: reason as Error, - techDescription: `An error occurred while getting data`, - toNotify: true, - displayableTitle: t('general.errorTitle'), - displayableDescription: t( - 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageAllDataDesc' - ), - component: 'Toast', - }); - }) - .finally(() => { - setLoading(false); + const getChannelsByBrokerCode = (selectedBrokerCode: string, filterByChannel?: string, fromAutocomplete?: boolean) => { + if (!fromAutocomplete) { + setLoadingChannels(true); + } + getChannels({ + status: ConfigurationStatus.ACTIVE, + brokerCode: selectedBrokerCode, + channelCode: filterByChannel, + limit: 25 + }) + .then((data) => { + if (data?.channels && data.channels.length > 0) { + setChannels([...data.channels]); + handleIsChannelV2(formik.values.idChannel, [...data.channels]); + } else { + setChannels([]); + if (!fromAutocomplete) { + addError({ + id: 'GET_BROKER_DELEGATIONS_DATA', + blocking: false, + error: new Error(`An error occurred while getting data`), + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBrokerDelegations' + ), + component: 'Toast', }); - }, [selectedParty]); + } + } + }) + .catch((error) => { + setChannels([]); + addError({ + id: 'GET_CHANNEL_IDS_DATA', + blocking: false, + error: error as Error, + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageChannelIdsDataDesc' + ), + component: 'Toast', + }); + }) + .finally(() => setLoadingChannels(false)); + }; - function handleBrokerCodesSelection(value: string | null | undefined) { - formik.setFieldValue('idChannel', ''); - handleIsChannelV2(); - if (value === null || value === undefined) { - formik.setFieldValue('idBrokerPsp', ''); - setChannels([]); - } else { - const broker = brokerDelegationList?.find((el) => el.broker_name === value); - formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? ''); - if (broker?.broker_tax_code) { - getChannelsByBrokerCode(broker?.broker_tax_code); + useEffect(() => { + setLoading(true); + Promise.all([ + getPaymentTypes(), + getTouchpoints(0, 50), + getBrokerDelegation(selectedParty?.partyId ?? '', undefined), + ]) + .then(([paymentTypes, touchpoints, brokerDelegation]) => { + if (paymentTypes) { + setPaymentOptions(paymentTypes); + } + if (touchpoints) { + setTouchpointList(touchpoints); + } + let listBroker = brokerDelegation?.delegation_list + ? [...brokerDelegation.delegation_list] + : []; + if (orgIsPspDirect) { + listBroker = addCurrentBroker(listBroker, selectedParty as Party); + } + + if (listBroker.length > 0) { + setBrokerDelegationList(listBroker); + if (isEdit && idBrokerPsp) { + const brokerTaxCode = listBroker?.find( + (el) => el.broker_tax_code === idBrokerPsp + )?.broker_tax_code; + if (brokerTaxCode) { + getChannelsByBrokerCode(brokerTaxCode); } + } + } else { + addError({ + id: 'GET_BROKER_DATA', + blocking: false, + error: new Error(`An error occurred while getting data`), + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageNoBroker' + ), + component: 'Toast', + }); } + }) + .catch((reason) => { + addError({ + id: 'GET_ALL_DATA', + blocking: false, + error: reason as Error, + techDescription: `An error occurred while getting data`, + toNotify: true, + displayableTitle: t('general.errorTitle'), + displayableDescription: t( + 'commissionBundlesPage.addEditCommissionBundle.error.errorMessageAllDataDesc' + ), + component: 'Toast', + }); + }) + .finally(() => { + setLoading(false); + }); + }, [selectedParty]); + + function handleBrokerCodesSelection(value: string | null | undefined) { + formik.setFieldValue('idChannel', ''); + handleIsChannelV2(); + if (value === null || value === undefined) { + formik.setFieldValue('idBrokerPsp', ''); + setChannels([]); + } else { + const broker = brokerDelegationList?.find((el) => el.broker_name === value); + formik.handleChange('idBrokerPsp')(broker?.broker_tax_code ?? ''); + if (broker?.broker_tax_code) { + getChannelsByBrokerCode(broker?.broker_tax_code); + } } + } - const handleIsChannelV2 = ( - channelCode?: string | null, - channelList?: Array - ) => { - let bool = false; - if (channelCode) { - const arrayChannel = channelList ?? channels; - bool = arrayChannel.find((el) => el.channel_code === channelCode)?.primitive_version === 2; - } + const handleIsChannelV2 = ( + channelCode?: string | null, + channelList?: Array + ) => { + let bool = false; + if (channelCode) { + const arrayChannel = channelList ?? channels; + bool = arrayChannel.find((el) => el.channel_code === channelCode)?.primitive_version === 2; + } - setIsChannelV2(bool); - if (!bool) { - formik.setFieldValue('cart', false); - } - }; + setIsChannelV2(bool); + if (!bool) { + formik.setFieldValue('cart', false); + } + }; - const handleChangeChannel = (value: string | null) => { - formik.handleChange('idChannel')(value ?? ''); - handleIsChannelV2(value); - }; + const handleChangeChannel = (value: string | null) => { + formik.handleChange('idChannel')(value ?? ''); + handleIsChannelV2(value); + }; - return ( - <> - - - {t('commissionBundlesPage.addEditCommissionBundle.form.bundleType')} - + useEffect(() => { + const timeout = setTimeout(() => { + if (formik.values.idBrokerPsp && filterChannelCode !== null) { + getChannelsByBrokerCode(formik.values.idBrokerPsp, filterChannelCode, true); + } + }, 300); + return () => clearTimeout(timeout); + }, [filterChannelCode]); - - formik.setFieldValue('type', e.target.value)} - data-testid="bundle-type-test" - value={`${formik.values.type}`} - > - } - label={t('commissionBundlesPage.globalBundles')} - sx={{pr: 8}} - disabled={isEdit} - /> - } - label={t('commissionBundlesPage.publicBundles')} - sx={{pr: 8}} - disabled={isEdit || !isPublicEnabled} - /> - } - label={t('commissionBundlesPage.privateBundles')} - disabled={isEdit || !isPrivateEnabled} - /> - - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.bundleConfiguration')} - + return ( + <> + + + {t('commissionBundlesPage.addEditCommissionBundle.form.bundleType')} + + + + formik.setFieldValue('type', e.target.value)} + data-testid="bundle-type-test" + value={`${formik.values.type}`} + > + } + label={t('commissionBundlesPage.globalBundles')} + sx={{ pr: 8 }} + disabled={isEdit} + /> + } + label={t('commissionBundlesPage.publicBundles')} + sx={{ pr: 8 }} + disabled={isEdit || !isPublicEnabled} + /> + } + label={t('commissionBundlesPage.privateBundles')} + disabled={isEdit || !isPrivateEnabled} + /> + + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.bundleConfiguration')} + - - - } - /> - - - formik.handleChange(e)} - error={formik.touched.name && Boolean(formik.errors.name)} - helperText={formik.touched.name && formik.errors.name} - inputProps={{ - 'data-testid': 'name-test', - }} - /> - + + + } + /> + + + formik.handleChange(e)} + error={formik.touched.name && Boolean(formik.errors.name)} + helperText={formik.touched.name && formik.errors.name} + inputProps={{ + 'data-testid': 'name-test', + }} + /> + - - formik.handleChange(e)} - error={formik.touched.description && Boolean(formik.errors.description)} - helperText={formik.touched.description && formik.errors.description} - inputProps={{ - 'data-testid': 'description-test', - }} - /> - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.paymentType')} - - - - - - - - {t('commissionBundlesPage.addEditCommissionBundle.form.touchpoint')} - - - - - + + formik.handleChange(e)} + error={formik.touched.description && Boolean(formik.errors.description)} + helperText={formik.touched.description && formik.errors.description} + inputProps={{ + 'data-testid': 'description-test', + }} + /> + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.paymentType')} + + + + + + + + {t('commissionBundlesPage.addEditCommissionBundle.form.touchpoint')} + + + + + - - } - /> - - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('minPaymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={ - formik.touched.minPaymentAmount && Boolean(formik.errors.minPaymentAmount) - } - helperText={formik.touched.minPaymentAmount && formik.errors.minPaymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{'data-testid': 'min-import-test'}} - /> - + + } + /> + + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('minPaymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={ + formik.touched.minPaymentAmount && Boolean(formik.errors.minPaymentAmount) + } + helperText={formik.touched.minPaymentAmount && formik.errors.minPaymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{ 'data-testid': 'min-import-test' }} + /> + - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('maxPaymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={ - formik.touched.maxPaymentAmount && Boolean(formik.errors.maxPaymentAmount) - } - helperText={formik.touched.maxPaymentAmount && formik.errors.maxPaymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{'data-testid': 'max-import-test'}} - /> - - - + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('maxPaymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={ + formik.touched.maxPaymentAmount && Boolean(formik.errors.maxPaymentAmount) + } + helperText={formik.touched.maxPaymentAmount && formik.errors.maxPaymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{ 'data-testid': 'max-import-test' }} + /> + + + - - } - /> - - - { - const numericValue = parseFloat(value.replace(',', '.')); - formik.setFieldValue('paymentAmount', numericValue * 100); - }} - thousandSeparator="" - decimalSeparator="," - allowNegative={false} - decimalScale={2} - fixedDecimalScale={false} - error={formik.touched.paymentAmount && Boolean(formik.errors.paymentAmount)} - helperText={formik.touched.paymentAmount && formik.errors.paymentAmount} - InputProps={{ - endAdornment: , - }} - inputProps={{'data-testid': 'payment-amount-test'}} - /> - - - - - - } - /> - - - el?.broker_name ?? '') - ?.sort((a, b) => a.localeCompare(b))} - disabled={!(brokerDelegationList && brokerDelegationList.length > 0)} - value={ - brokerDelegationList?.find( - (el) => el.broker_tax_code === formik.values.idBrokerPsp - )?.broker_name ?? '' - } - onChange={(_, value) => { - handleBrokerCodesSelection(value); - }} - fullWidth - renderInput={(params) => ( - - )} - PaperComponent={({children}) => ( - {children} - )} - noOptionsText={t( - 'commissionBundlesPage.addEditCommissionBundle.form.noBrokersOption' - )} - data-testid="broker-code-test" - /> - - - el.channel_code).sort((a, b) => a.localeCompare(b))} - disabled={!(channels && channels.length > 0)} - onChange={(_event, value) => handleChangeChannel(value)} - value={formik.values.idChannel} - fullWidth - renderInput={(params) => ( - - )} - PaperComponent={({children}) => ( - {children} - )} - noOptionsText={t( - 'commissionBundlesPage.addEditCommissionBundle.form.noChannelsOption' - )} - data-testid="channels-id-test" - /> - - - formik.setFieldValue('cart', e.target.checked)} - checked={formik.values.cart ?? false} - disabled={!isChannelV2} - data-testid="bundle-cart" - /> - } - label={ -
- {t('commissionBundlesPage.addEditCommissionBundle.form.cart')} - - - -
- } - /> -
-
-
- - } - /> - - - - - {t( - 'commissionBundlesPage.addEditCommissionBundle.form.paymentWithDigitalStamp' - )} - - - formik.setFieldValue('digitalStamp', e.target.value === 'true') - } - row - data-testid="digital-stamp-test" - value={formik.values.digitalStamp ? `${formik.values.digitalStamp}` : 'false'} - > - } - label={t('general.no')} - sx={{pr: 3}} - /> - } - disabled={formik.values.digitalStampRestriction} - label={t('general.yes')} - /> - - - - - - - {t( - 'commissionBundlesPage.addEditCommissionBundle.form.paymentOnlyDigitalStamp' - )} - - - formik.setFieldValue('digitalStampRestriction', e.target.value === 'true') - } - row - data-testid="digital-stamp-restriction-test" - value={ - formik.values.digitalStampRestriction - ? `${formik.values.digitalStampRestriction}` - : 'false' - } - > - } - label={t('general.no')} - sx={{pr: 3}} - /> - } - disabled={formik.values.digitalStamp} - label={t('general.yes')} - /> - - - - - - - } - /> - - - - { - formik.setFieldValue('validityDateFrom', value); - if (formik.values.validityDateTo && value - && isBefore(formik.values.validityDateTo, value)) { - formik.setFieldValue('validityDateTo', null); - } - }} - renderInput={(params: TextFieldProps) => ( - - )} - shouldDisableDate={(date: Date) => { - let limit = new Date(); - limit = add(limit, {days: 2}); - return date < limit; - }} - disabled={isEdit} - /> - - - - - formik.setFieldValue('validityDateTo', value)} - renderInput={(params: TextFieldProps) => ( - - )} - shouldDisableDate={(date: Date) => isBefore(date, formik.values.validityDateFrom ?? new Date())} - /> - - - - -
-
- - ); + + } + /> + + + { + const numericValue = parseFloat(value.replace(',', '.')); + formik.setFieldValue('paymentAmount', numericValue * 100); + }} + thousandSeparator="" + decimalSeparator="," + allowNegative={false} + decimalScale={2} + fixedDecimalScale={false} + error={formik.touched.paymentAmount && Boolean(formik.errors.paymentAmount)} + helperText={formik.touched.paymentAmount && formik.errors.paymentAmount} + InputProps={{ + endAdornment: , + }} + inputProps={{ 'data-testid': 'payment-amount-test' }} + /> + + + + + + } + /> + + + el?.broker_name ?? '') + ?.sort((a, b) => a.localeCompare(b))} + disabled={!(brokerDelegationList && brokerDelegationList.length > 0)} + value={ + brokerDelegationList?.find( + (el) => el.broker_tax_code === formik.values.idBrokerPsp + )?.broker_name ?? '' + } + onChange={(_, value) => { + handleBrokerCodesSelection(value); + }} + fullWidth + renderInput={(params) => ( + + )} + PaperComponent={({ children }) => ( + {children} + )} + noOptionsText={t( + 'commissionBundlesPage.addEditCommissionBundle.form.noBrokersOption' + )} + data-testid="broker-code-test" + /> + + + el.channel_code).sort((a, b) => a.localeCompare(b))} + disabled={!formik.values.idBrokerPsp} + onChange={(_event, value) => handleChangeChannel(value)} + value={formik.values.idChannel} + fullWidth + filterOptions={(x) => x} + onInputChange={(_, value) => setFilterChannelCode(value)} + renderInput={(params) => ( + + )} + PaperComponent={({ children }) => ( + {children} + )} + noOptionsText={t( + 'commissionBundlesPage.addEditCommissionBundle.form.noChannelsOption' + )} + data-testid="channels-id-test" + /> + + + formik.setFieldValue('cart', e.target.checked)} + checked={formik.values.cart ?? false} + disabled={!isChannelV2} + data-testid="bundle-cart" + /> + } + label={ +
+ {t('commissionBundlesPage.addEditCommissionBundle.form.cart')} + + + +
+ } + /> +
+
+
+ + } + /> + + + + + {t( + 'commissionBundlesPage.addEditCommissionBundle.form.paymentWithDigitalStamp' + )} + + + formik.setFieldValue('digitalStamp', e.target.value === 'true') + } + row + data-testid="digital-stamp-test" + value={formik.values.digitalStamp ? `${formik.values.digitalStamp}` : 'false'} + > + } + label={t('general.no')} + sx={{ pr: 3 }} + /> + } + disabled={formik.values.digitalStampRestriction} + label={t('general.yes')} + /> + + + + + + + {t( + 'commissionBundlesPage.addEditCommissionBundle.form.paymentOnlyDigitalStamp' + )} + + + formik.setFieldValue('digitalStampRestriction', e.target.value === 'true') + } + row + data-testid="digital-stamp-restriction-test" + value={ + formik.values.digitalStampRestriction + ? `${formik.values.digitalStampRestriction}` + : 'false' + } + > + } + label={t('general.no')} + sx={{ pr: 3 }} + /> + } + disabled={formik.values.digitalStamp} + label={t('general.yes')} + /> + + + + + + + } + /> + + + + { + formik.setFieldValue('validityDateFrom', value); + if ( + formik.values.validityDateTo && + value && + isBefore(formik.values.validityDateTo, value) + ) { + formik.setFieldValue('validityDateTo', null); + } + }} + renderInput={(params: TextFieldProps) => ( + + )} + shouldDisableDate={(date: Date) => { + let limit = new Date(); + limit = add(limit, { days: 2 }); + return date < limit; + }} + disabled={isEdit} + /> + + + + + formik.setFieldValue('validityDateTo', value)} + renderInput={(params: TextFieldProps) => ( + + )} + shouldDisableDate={(date: Date) => + isBefore(date, formik.values.validityDateFrom ?? new Date()) + } + /> + + + + + +
+ + ); }; export default AddEditCommissionBundleForm; diff --git a/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx b/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx index b42bbad4f..c3e16ee26 100644 --- a/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx +++ b/src/pages/commisionalBundles/addEditCommissionBundle/components/__tests__/AddEditCommissionBundleForm.test.tsx @@ -7,8 +7,7 @@ import { Provider } from 'react-redux'; import React from 'react'; import { mockedBundleRequest, - mockedBundleRequestForEdit, - mockedChannelsIdList, + mockedBundleRequestForEdit } from '../../../../../services/__mocks__/bundleService'; import { partiesActions } from '../../../../../redux/slices/partiesSlice'; import { pspOperatorSignedDirect } from '../../../../../services/__mocks__/partyService'; @@ -24,6 +23,7 @@ import * as useUserRole from '../../../../../hooks/useUserRole'; import { ROLE } from '../../../../../model/RolePermission'; import { TypeEnum } from '../../../../../api/generated/portal/PSPBundleResource'; import * as useOrganizationType from '../../../../../hooks/useOrganizationType'; +import { mockedChannels, channelCode } from '../../../../../services/__mocks__/channelService'; let spyOnGetPaymentTypes: jest.SpyInstance; let spyOnGetTouchpoint: jest.SpyInstance; @@ -306,16 +306,16 @@ describe('', () => { // Change channel id fireEvent.change(input.channelList, { - target: { value: mockedChannelsIdList[0] }, + target: { value: mockedChannels.channels[4].channel_code }, }); input.channelList.focus(); fireEvent.change(document.activeElement as Element, { - target: { value: mockedChannelsIdList[0] }, + target: { value: mockedChannels.channels[4].channel_code }, }); fireEvent.keyDown(document.activeElement as Element, { key: 'ArrowDown' }); fireEvent.keyDown(document.activeElement as Element, { key: 'Enter' }); - expect(input.channelList.value).toEqual(mockedChannelsIdList[0]); + expect(input.channelList.value).toEqual(mockedChannels.channels[4].channel_code); //Change radio buttons digitalStamp expect(input.digitalStampYes.checked).toBe(false);