From dfbe7f76b408aa0557b64029af79b87beff107bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=CD=8B=CC=B5=CD=89=CC=94=CD=9Ea=CC=A4=CD=98=CC=84=CD=83?= =?UTF-8?q?=CC=8Dl=CC=99=CC=91=CC=BE=CD=96=CD=A3l=CC=99=CC=91=CC=BE=CD=96?= =?UTF-8?q?=CD=A3u=CD=95=CC=87=CC=A1=CC=AD=CC=9Bm=CD=85=CD=81=CC=AC=CC=8F?= =?UTF-8?q?=CD=A4=20M=CC=85=CD=AE=CD=92=CD=89=CD=A4a=CC=A4=CD=98=CC=84?= =?UTF-8?q?=CD=83=CC=8Dc=CC=95=CD=95=CD=97=CD=A4=CC=95p=CC=9A=CC=88=CC=9E?= =?UTF-8?q?=CD=91=CD=9Eh=CC=96=CC=87=CD=9B=CC=93=CC=BBe=CC=95=CC=A3=CC=BF?= =?UTF-8?q?=CD=8B=CC=92r=CC=A6=CD=95=CC=9D=CC=B4=CC=A8s=CC=A0=D2=89=CD=85?= =?UTF-8?q?=CD=8A=CD=8Do=CC=8A=CD=A2=CC=AF=CC=B1=CD=8An=CC=A3=CD=9B=CC=92?= =?UTF-8?q?=CC=8D=CC=A4?= <88662046+LBHCallumM@users.noreply.github.com> Date: Mon, 5 Jan 2026 10:25:44 +0000 Subject: [PATCH 1/2] Upgrade to Next@15 (#1247) * Upgrade to next 15 --- .circleci/config.yml | 30 +- .eslintrc | 1 + .gitignore | 2 + jest.config.js | 4 + lambda/package.json | 10 + lambda/yarn.lock | 192 + next-env.d.ts | 3 +- next.config.js | 13 +- package.json | 34 +- sentry.server.config.js | 24 - serverless.yml | 33 +- setupTests.js | 33 +- .../__snapshots__/index.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 2 +- .../CautionaryAlertsTable.test.js.snap | 2 +- .../Contract/ContractSection.tsx | 1 + .../ContractListItem.test.js.snap | 8 +- .../ContractListItems.test.js.snap | 30 +- .../Contractor/ContractorView.test.js | 12 +- .../Contractor/ContractorView.tsx | 2 +- .../ContractorListItem.test.js.snap | 50 +- .../ContractorListItems.test.js.snap | 272 +- .../__snapshots__/ContractorView.test.js.snap | 50 +- .../__snapshots__/SorSearch.test.js.snap | 6 +- .../__snapshots__/index.test.js.snap | 8 +- src/components/Form/Radios/index.tsx | 1 + src/components/Form/TextArea/index.tsx | 1 + src/components/Layout/Header/index.js | 2 +- .../Layout/MultiButton/index.test.js | 10 +- .../__snapshots__/index.test.js.snap | 2 +- src/components/Operatives/OperativeForm.tsx | 1 + src/components/Operatives/OperativeList.js | 5 +- .../__snapshots__/OperativeList.test.js.snap | 2 +- .../SelectOperatives.test.js.snap | 2 +- ...WorkingPastWorkOrderListItems.test.js.snap | 190 +- .../PastWorkOrdersDatePicker.test.js.snap | 2 +- .../PropertiesTable.test.js.snap | 2 +- .../TenantsContactTable.test.js.snap | 2 +- .../__snapshots__/ContactsTable.test.js.snap | 2 +- .../__snapshots__/index.test.js.snap | 2 +- src/components/Property/PropertyDetails.tsx | 2 +- .../Property/PropertyDetailsAddress.js | 2 +- .../__snapshots__/index.test.js.snap | 2 +- src/components/Property/PropertyRow.js | 2 +- .../RaiseWorkOrder/RaiseWorkOrderForm.test.js | 47 +- .../RaiseWorkOrder/RaiseWorkOrderForm.tsx | 5 +- .../RaiseWorkOrder/RateScheduleItemView.js | 2 +- .../RaiseWorkOrder/SelectPriority.tsx | 5 + .../BudgetCodeItemView.test.js.snap | 3 +- .../RaiseWorkOrderForm.test.js.snap | 1336 ++++- .../__snapshots__/SelectPriority.test.js.snap | 2 +- .../Property/RaiseWorkOrderLink.tsx | 2 +- .../Property/RaiseWorkOrderStatus.tsx | 5 +- .../RepairsFinder/RepairsFinderInput.test.js | 53 +- .../RepairsFinderInput.test.js.snap | 23 +- .../WorkOrdersHistory/WorkOrdersHistoryRow.js | 1 + .../WorkOrdersHistoryTable.test.js.snap | 14 +- .../__snapshots__/Alerts.test.js.snap | 2 +- .../PropertyDetails.test.js.snap | 2 +- .../__snapshots__/TenureDetail.test.js.snap | 2 +- .../Search/__snapshots__/Search.test.tsx.snap | 2 +- .../__snapshots__/index.test.js.snap | 2 +- src/components/SuccessPage/index.tsx | 2 +- src/components/Tabs/VariationSummaryTab.tsx | 2 + .../Tabs/__snapshots__/index.test.js.snap | 53 +- src/components/Template/WarningInfoBox.tsx | 1 + src/components/UserContext/index.js | 4 +- src/components/UserLogin/index.js | 2 +- .../Appointment/NoAvailableAppointments.js | 2 +- .../Appointment/PropertyDetails.test.js | 13 +- .../PropertyDetails.test.js.snap | 2 +- .../__snapshots__/WorkOrderTasks.test.js.snap | 2 +- .../Authorisation/AuthorisationView.js | 2 +- .../VariationAuthorisationView.tsx | 7 +- ...VariationAuthorisationSummary.test.js.snap | 2 +- .../CancelWorkOrderForm.test.js.snap | 2 +- .../WorkOrder/MobileWorkingWorkOrder.test.js | 53 +- .../WorkOrder/MobileWorkingWorkOrder.tsx | 6 +- .../MobileWorkingWorkOrderDetails.test.js | 11 +- .../__snapshots__/index.test.js.snap | 2 +- .../__snapshots__/NoteEntry.test.js.snap | 2 +- .../__snapshots__/NotesForm.test.js.snap | 2 +- .../__snapshots__/NotesTimeline.test.js.snap | 2 +- .../ControlledFileInput.test.js.snap | 2 +- .../PhotoGroupDescriptionForm.test.js.snap | 2 +- .../PhotoListWithPreview.test.js.snap | 2 +- .../PhotoUploadPreview.test.js.snap | 2 +- .../__snapshots__/PhotoViewList.test.js.snap | 2 +- .../UploadPhotosForm.test.js.snap | 2 +- .../ScheduleAppointment.test.js.snap | 4 +- .../WorkOrder/ScheduleDRSAppointmentLink.tsx | 1 + .../ScheduleInternalAppointmentLink.tsx | 2 +- .../WorkOrder/TasksAndSors/EditTaskForm.js | 6 +- .../WorkOrder/TasksAndSors/TasksAndSorsRow.js | 4 +- ...obileWorkingTasksAndSorsTable.test.js.snap | 2 +- .../TasksAndSorsTable.test.js.snap | 2 +- src/components/WorkOrder/Update/Summary.js | 4 +- .../Update/__snapshots__/Form.test.js.snap | 8 +- .../Update/__snapshots__/Summary.test.js.snap | 2 +- .../AppointmentDetails.test.js.snap | 2 +- .../AppointmentHeader.test.js.snap | 2 +- .../__snapshots__/BudgetCode.test.js.snap | 2 +- .../__snapshots__/EditWorkOrder.test.js.snap | 4 +- .../MobileWorkingWorkOrder.test.js.snap | 2 +- ...MobileWorkingWorkOrderDetails.test.js.snap | 2 +- ...obileWorkingWorkOrderListItem.test.js.snap | 88 +- .../__snapshots__/Operatives.test.js.snap | 2 +- .../PrintJobTicketDetails.test.js.snap | 2 +- .../WorkOrderDetails.test.js.snap | 2 +- .../WorkOrderHeader.test.js.snap | 2 +- .../__snapshots__/WorkOrderInfo.test.js.snap | 2 +- .../WorkOrderInfoTable.test.js.snap | 2 +- .../WorkOrders/CloseWorkOrderForm.tsx | 1 + .../FollowOnRequestTypeOfWorkForm.tsx | 1 + .../WorkOrdersFilter.test.js.snap | 2 +- ...> MobileWorkingCloseWorkOrderForm.test.js} | 14 +- .../RelatedWorkOrderViewList.test.js.snap | 2 +- src/components/WorkOrders/WorkOrderRow.js | 2 +- .../CloseWorkOrderForm.test.js.snap | 26 +- ...ileWorkingCloseWorkOrderForm.test.js.snap} | 2 +- .../SummaryCloseWorkOrder.test.js.snap | 2 +- .../WorkOrdersTable.test.js.snap | 2 +- src/hooks/useClickOutside.test.js | 10 +- src/lambda.js | 38 +- src/utils/serviceApiClient.js | 49 - tsconfig.json | 6 +- yarn.lock | 4966 +++++++++-------- 127 files changed, 4906 insertions(+), 3118 deletions(-) create mode 100644 lambda/package.json create mode 100644 lambda/yarn.lock delete mode 100644 sentry.server.config.js rename src/components/WorkOrders/{MobileWorkingCloseWorkOrderForm.test.tsx => MobileWorkingCloseWorkOrderForm.test.js} (84%) rename src/components/WorkOrders/__snapshots__/{MobileWorkingCloseWorkOrderForm.test.tsx.snap => MobileWorkingCloseWorkOrderForm.test.js.snap} (98%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 55c48300a..09f1d26b5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ orbs: executors: node-executor: docker: - - image: cimg/node:22.16.0-browsers + - image: cimg/node:24.11-browsers docker-python: docker: - image: cimg/python:3.12 @@ -115,20 +115,18 @@ jobs: export NEXT_PUBLIC_REPAIRS_FINDER_INTEGRATION_ENABLED=$REPAIRS_FINDER_INTEGRATION_ENABLED_DEVELOPMENT export NEXT_PUBLIC_REPAIRS_FINDER_LINK=$REPAIRS_FINDER_LINK_DEVELOPMENT - # Build application yarn build # Fetch production dependencies rm -rf node_modules + + # node_modules specific for lambda.js + cd lambda yarn install --production --frozen-lockfile + cd .. - # view size of /@next npx --yes serverless deploy --stage development - - # Keep in case of later build size issues - # du -sh ./build/_next/* 2>/dev/null | sort -hr - # ls -lh .serverless/*.zip - + build-deploy-staging: executor: node-executor steps: @@ -159,8 +157,15 @@ jobs: export NEXT_PUBLIC_REPAIRS_FINDER_LINK=$REPAIRS_FINDER_LINK_STAGING yarn build + + # Fetch production dependencies rm -rf node_modules + + # node_modules specific for lambda.js + cd lambda yarn install --production --frozen-lockfile + cd .. + npx --yes serverless deploy --stage staging @@ -192,10 +197,17 @@ jobs: export NEXT_PUBLIC_WARRANTIES_SPREADSHEET_ID=$WARRANTIES_SPREADSHEET_ID export NEXT_PUBLIC_REPAIRS_FINDER_INTEGRATION_ENABLED=$REPAIRS_FINDER_INTEGRATION_ENABLED_PRODUCTION export NEXT_PUBLIC_REPAIRS_FINDER_LINK=$REPAIRS_FINDER_LINK_PRODUCTION - + yarn build + + # Fetch production dependencies rm -rf node_modules + + # node_modules specific for lambda.js + cd lambda yarn install --production --frozen-lockfile + cd .. + npx --yes serverless deploy --stage production assume-role-development: diff --git a/.eslintrc b/.eslintrc index c2542824c..bce361f7a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,6 +14,7 @@ "jsx": true } }, + "ignorePatterns": ["next-env.d.ts", "node_modules/", ".next/"], "plugins": ["react", "@typescript-eslint"], "extends": [ "eslint:recommended", diff --git a/.gitignore b/.gitignore index 3b4f5a1ef..b65a8c3da 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ /.pnp .pnp.js +/lambda/node_modules + # testing /coverage diff --git a/jest.config.js b/jest.config.js index 4fb8ed09a..3fdf03d3b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -27,4 +27,8 @@ module.exports = { '^@/utils/(.*)$': '/src/utils/$1', }, reporters: ['default'], + testEnvironment: 'jsdom', + testEnvironmentOptions: { + customExportConditions: [''], + }, } diff --git a/lambda/package.json b/lambda/package.json new file mode 100644 index 000000000..549ed6470 --- /dev/null +++ b/lambda/package.json @@ -0,0 +1,10 @@ +{ + "name": "repairs-hub-frontend", + "version": "0.1.0", + "private": true, + "dependencies": { + "restana": "^4.8.0", + "serve-static": "^1.14.1", + "serverless-http": "^2.6.0" + } +} diff --git a/lambda/yarn.lock b/lambda/yarn.lock new file mode 100644 index 000000000..e6aef1ff8 --- /dev/null +++ b/lambda/yarn.lock @@ -0,0 +1,192 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"0http@^3.5.3": + version "3.5.3" + resolved "https://registry.yarnpkg.com/0http/-/0http-3.5.3.tgz#829824cd1135a55a712cfeb99829d1d1b7261037" + integrity sha512-iqiI8f1f6gXWkb9HBr2OQUjK/UdLcH/TLSHm8EvPG2SWVpZq2EbErfubJTlQoYojwcHQGp8IcsRQupC/hdR7uw== + dependencies: + lru-cache "^10.2.0" + regexparam "^3.0.0" + trouter "^3.2.1" + +"@types/aws-lambda@^8.10.56": + version "8.10.157" + resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.157.tgz#0ef9fbe5790f5593f938b7ef5170b0a0ff7b2738" + integrity sha512-ofjcRCO1N7tMZDSO11u5bFHPDfUFD3Q9YK9g4S4w8UDKuG3CNlw2lNK1sd3Itdo7JORygZmG4h9ZykS8dlXvMA== + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + +encodeurl@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-2.0.0.tgz#7b8ea898077d7e409d3ac45474ea38eaf0857a58" + integrity sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +inherits@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +lru-cache@^10.2.0: + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +regexparam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" + integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g== + +regexparam@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-3.0.0.tgz#1673e09d41cb7fd41eaafd4040a6aa90daa0a21a" + integrity sha512-RSYAtP31mvYLkAHrOlh25pCNQ5hWnT106VukGaaFfuJrZFkGRX5GhUAdPqpSDXxOhA2c4akmRuplv1mRqnBn6Q== + +restana@^4.8.0: + version "4.9.9" + resolved "https://registry.yarnpkg.com/restana/-/restana-4.9.9.tgz#a3f10f12a8179c84f4027b1f0486f03726d5d9ca" + integrity sha512-tJjLoMjnme9gP0b4HGzzr+IAuJVCFt6pzqXVPpV9jbHxujhYxfy1MHEYRe4PTdCtGIjFlVFb1ngtsQg5MzKCQg== + dependencies: + "0http" "^3.5.3" + +send@0.19.0: + version "0.19.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.19.0.tgz#bbc5a388c8ea6c048967049dbeac0e4a3f09d7f8" + integrity sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + +serve-static@^1.14.1: + version "1.16.2" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.16.2.tgz#b6a5343da47f6bdd2673848bf45754941e803296" + integrity sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw== + dependencies: + encodeurl "~2.0.0" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.19.0" + +serverless-http@^2.6.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/serverless-http/-/serverless-http-2.7.0.tgz#352ca38cbbba58dc71dcfb11bb27c92c3c81fe69" + integrity sha512-iWq0z1X2Xkuvz6wL305uCux/SypbojHlYsB5bzmF5TqoLYsdvMNIoCsgtWjwqWoo3AR2cjw3zAmHN2+U6mF99Q== + optionalDependencies: + "@types/aws-lambda" "^8.10.56" + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +trouter@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/trouter/-/trouter-3.2.1.tgz#a07e6f39a48fa0950a0157897075b633265b0fd9" + integrity sha512-oY3CmIiEYOe1YMEzh++I67lrNOUldtCeuLL0vRPydvQLHZpSJ03B5dgDFlpFsiriMq6e//NDjjopjUzXOztHow== + dependencies: + regexparam "^1.3.0" diff --git a/next-env.d.ts b/next-env.d.ts index 4f11a03dc..42fc89c3a 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. diff --git a/next.config.js b/next.config.js index 62ebe38fd..dceba3b00 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,3 @@ -const { withSentryConfig } = require('@sentry/nextjs') - const cspHeader = ` frame-ancestors 'none'; ` @@ -29,6 +27,7 @@ async function headers() { const moduleExports = { distDir: 'build/_next', productionBrowserSourceMaps: false, + output: 'standalone', swcMinify: true, images: { domains: ['utfs.io'], @@ -36,12 +35,4 @@ const moduleExports = { headers: () => headers(), } -const { NODE_ENV, SENTRY_RELEASE } = process.env - -const sentryWebpackPluginOptions = { - dryRun: !(NODE_ENV === 'production'), - release: SENTRY_RELEASE, - silent: !(NODE_ENV === 'production'), -} - -module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions) +module.exports = moduleExports diff --git a/package.json b/package.json index 62c8b2d91..dd1d25759 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "start": "yarn next start -p 5001", "start-server": "yarn next start -p 5001", "tests": "yarn test:unit && yarn test:e2e", - "test:unit": "NODE_ENV=test node --expose-gc ./node_modules/.bin/jest --runInBand --logHeapUsage", + "test:unit": "NODE_ENV=test node --expose-gc ./node_modules/.bin/jest --logHeapUsage --maxWorkers 2", "test:unit-windows": "node ./node_modules/jest/bin/jest.js", "test:unit-win-upd": "node ./node_modules/jest/bin/jest.js --updateSnapshot", "lint": "yarn eslint . && echo 'Lint complete.'", @@ -35,6 +35,7 @@ "dayjs": "^1.11.7", "dotenv": "^8.2.0", "easy-soap-request": "5", + "eslint-config-next": "15", "filesize": "^10.1.4", "http-status-codes": "^2.1.4", "idb": "^7.1.1", @@ -42,44 +43,44 @@ "lbh-frontend": "^3.5.3", "loglevel": "^1.8.0", "mockdate": "^3.0.2", - "next": "^12.3.4", + "next": "15", "path": "^0.12.7", "qs": "^6.10.1", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "19", + "react-dom": "19", "react-hook-form": "^6.14.0", "react-hook-form-persist": "^3.0.0", "react-hotjar": "^5.0.0", "react-photo-view": "^1.2.6", "react-query": "^3.39.3", - "restana": "^4.8.0", "retry": "^0.13.1", "sass": "^1.29.0", - "serve-static": "^1.14.1", - "serverless-http": "^2.6.0", "universal-cookie": "^4.0.4", "uuid": "^8.3.2", "xml2js": "^0.6.2", "xpath": "^0.0.32" }, "devDependencies": { - "@babel/core": "^7.23.2", + "@babel/core": "^7.28.5", "@babel/eslint-parser": "^7.17.0", "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-transform-private-methods": "^7.22.5", "@faker-js/faker": "^10.1.0", - "@jest/types": "^30.2.0", - "@testing-library/dom": "^8.20.1", - "@testing-library/jest-dom": "5", - "@testing-library/react": "12", - "@testing-library/user-event": "^13.1.9", + "@jest/globals": "^30.2.0", + "@jest/types": "29", + "@testing-library/dom": "^10.4.1", + "@testing-library/jest-dom": "^6.9.1", + "@testing-library/react": "^16.3.0", + "@testing-library/user-event": "^14.6.1", + "@types/axios-mock-adapter": "^1.10.4", "@types/node": "^22.1.0", "@types/qs": "^6.9.15", - "@types/react": "^18.3.3", + "@types/react": "19", "@types/retry": "^0.12.5", "@typescript-eslint/eslint-plugin": "^8.0.1", "@typescript-eslint/parser": "^8.0.1", - "babel-jest": "26", + "axios-mock-adapter": "^2.1.0", + "babel-jest": "^30.2.0", "cypress": "13", "cypress-dotenv": "^1.2.2", "cypress-dotenv-flow": "^1.2.2", @@ -93,7 +94,8 @@ "eslint-plugin-prettier": "^3.2.0", "eslint-plugin-react": "^7.21.5", "fishery": "^1.3.1", - "jest": "26", + "jest": "^30.2.0", + "jest-environment-jsdom": "^30.2.0", "lint-staged": "^10.5.3", "mocha-junit-reporter": "^2.2.1", "node-mocks-http": "^1.10.0", diff --git a/sentry.server.config.js b/sentry.server.config.js deleted file mode 100644 index 1d8995da5..000000000 --- a/sentry.server.config.js +++ /dev/null @@ -1,24 +0,0 @@ -// This file configures the initialization of Sentry on the server. -// The config you add here will be used whenever the server handles a request. -// https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -import * as Sentry from '@sentry/nextjs' - -const { - SENTRY_DSN, - SENTRY_RELEASE, - SENTRY_ENVIRONMENT, - SENTRY_DEBUG, - NODE_ENV, -} = process.env - -Sentry.init({ - dsn: SENTRY_DSN, - tracesSampleRate: 0.1, - environment: SENTRY_ENVIRONMENT, - release: SENTRY_RELEASE, - debug: SENTRY_DEBUG === 'true', - enabled: NODE_ENV === 'production', -}) - -export { Sentry } diff --git a/serverless.yml b/serverless.yml index 2524622fe..3e107caf6 100644 --- a/serverless.yml +++ b/serverless.yml @@ -3,7 +3,7 @@ service: repairs-hub-frontend provider: name: aws runtime: nodejs20.x - timeout: 30 + timeout: 29 region: eu-west-2 stage: ${opt:stage} lambdaHashingVersion: 20201221 @@ -24,35 +24,15 @@ functions: handler: src/lambda.handler package: individually: true - exclude: - - ./** patterns: - # Include + - 'build/_next/standalone/**' + - '!build/_next/standalone/.next/cache/**' + - 'build/_next/static/**' - src/lambda.js - next.config.js - public/** - - 'build/_next/BUILD_ID' - - 'build/_next/*.json' - - 'build/_next/server/**' - - 'build/_next/static/**' - - 'node_modules/**' - # Exclude - - '!node_modules/@next/swc-darwin*/**' - - '!node_modules/@next/swc-win32*/**' - - '!node_modules/@next/swc-freebsd*/**' - - '!node_modules/@next/swc-android*/**' - - '!node_modules/@next/swc-linux-x64-musl*/**' - - '!node_modules/@types/**' - - '!node_modules/browserslist/**' - - '!node_modules/caniuse-lite/**' - - '!node_modules/@aws-sdk/**' - - '!node_modules/@babel/***' - - '!node_modules/sass/**' - - '!node_modules/@rollup/**' - - '!node_modules/rollup/**' - - '!node_modules/leaflet/**' - - '!node_modules/sass/**' - - '!node_modules/dotenv/**' + - '!node_modules/**' + - 'lambda/node_modules/**' events: - http: ANY / @@ -61,6 +41,7 @@ functions: securityGroupIds: ${self:custom.securityGroups.${self:provider.stage}} subnetIds: ${self:custom.subnets.${self:provider.stage}} environment: + NODE_PATH: '/var/task/lambda/node_modules' S3_BUCKET_NAME: repairs-api-images-${self:provider.stage} AGENTS_GOOGLE_GROUPNAME_REGEX: ${ssm:/repairs-hub/${self:provider.stage}/agents-group-regex} AUTHORISATION_MANAGERS_GOOGLE_GROUPNAME: ${ssm:/repairs-hub/${self:provider.stage}/authorisation-managers-group} diff --git a/setupTests.js b/setupTests.js index 4bfaa1cf6..f411db433 100644 --- a/setupTests.js +++ b/setupTests.js @@ -1,6 +1,7 @@ import '@testing-library/jest-dom' - +import { jest } from '@jest/globals' import dotenvFlow from 'dotenv-flow' + dotenvFlow.config({ silent: true }) // Mock Sentry module so tests can load API routes @@ -26,3 +27,33 @@ jest.mock('@sentry/nextjs', () => { getCurrentScope: jest.fn(() => mockScope), } }) + +jest.mock('next/router', () => ({ + useRouter: jest.fn(), +})) + +import { useRouter } from 'next/router' + +useRouter.mockReturnValue({ + route: '/', + pathname: '/', + query: {}, + asPath: '/', + basePath: '', + push: jest.fn(), + replace: jest.fn(), + reload: jest.fn(), + back: jest.fn(), + forward: jest.fn(), + prefetch: jest.fn().mockResolvedValue(undefined), + beforePopState: jest.fn(), + events: { + on: jest.fn(), + off: jest.fn(), + emit: jest.fn(), + }, + isFallback: false, + isLocaleDomain: false, + isReady: true, + isPreview: false, +}) diff --git a/src/components/BackOffice/Components/NewSORCode/__snapshots__/index.test.js.snap b/src/components/BackOffice/Components/NewSORCode/__snapshots__/index.test.js.snap index ba8060ca0..55bfd6f05 100644 --- a/src/components/BackOffice/Components/NewSORCode/__snapshots__/index.test.js.snap +++ b/src/components/BackOffice/Components/NewSORCode/__snapshots__/index.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`NewSORCode component should render the component 1`] = ` diff --git a/src/components/BackOffice/SORContracts/__snapshots__/index.test.js.snap b/src/components/BackOffice/SORContracts/__snapshots__/index.test.js.snap index 48b342a6a..d631a1895 100644 --- a/src/components/BackOffice/SORContracts/__snapshots__/index.test.js.snap +++ b/src/components/BackOffice/SORContracts/__snapshots__/index.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`SORContracts component should render the component 1`] = ` diff --git a/src/components/CautionaryAlerts/__snapshots__/CautionaryAlertsTable.test.js.snap b/src/components/CautionaryAlerts/__snapshots__/CautionaryAlertsTable.test.js.snap index b32656c6d..34674d8d4 100644 --- a/src/components/CautionaryAlerts/__snapshots__/CautionaryAlertsTable.test.js.snap +++ b/src/components/CautionaryAlerts/__snapshots__/CautionaryAlertsTable.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`CautionaryAlertsTable component when logged in as an operative and has NO queries should render properly: with NO highlithed codes 1`] = ` diff --git a/src/components/ContractsDashboard/Contract/ContractSection.tsx b/src/components/ContractsDashboard/Contract/ContractSection.tsx index c8acfed56..02f870c28 100644 --- a/src/components/ContractsDashboard/Contract/ContractSection.tsx +++ b/src/components/ContractsDashboard/Contract/ContractSection.tsx @@ -3,6 +3,7 @@ import ContractListItems from './ContractListItems' import Spinner from '../../Spinner' import WarningInfoBox from '../../Template/WarningInfoBox' import ErrorMessage from '../../Errors/ErrorMessage' +import { JSX } from 'react' interface ContractSectionProps { heading?: string diff --git a/src/components/ContractsDashboard/Contract/__snapshots__/ContractListItem.test.js.snap b/src/components/ContractsDashboard/Contract/__snapshots__/ContractListItem.test.js.snap index 76f2e912c..398f4bcf7 100644 --- a/src/components/ContractsDashboard/Contract/__snapshots__/ContractListItem.test.js.snap +++ b/src/components/ContractsDashboard/Contract/__snapshots__/ContractListItem.test.js.snap @@ -1,10 +1,10 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Contractors list item component Contractor page should render a contract with relevant fields 1`] = `
  • @@ -8,7 +8,7 @@ exports[`Contractors list items component should render active contracts with re >
  • { const { asFragment } = render() expect(asFragment()).toMatchSnapshot() }) + it('should render component with sor code contracts displayed', async () => { useQuery.mockImplementation((key) => { const queryKey = Array.isArray(key) ? key[0] : key @@ -74,15 +75,18 @@ describe('Contracts dashboard component', () => { } } }) - const { asFragment } = render() - await act(async () => { + const { asFragment } = await act(() => + render() + ) + + await act(() => fireEvent.change(screen.getByTestId('input-search'), { target: { value: 'ABC123' }, }) + ) + await act(() => fireEvent.click(screen.getByTestId('submit-search'))) - fireEvent.click(screen.getByTestId('submit-search')) - }) expect(asFragment()).toMatchSnapshot() }) }) diff --git a/src/components/ContractsDashboard/Contractor/ContractorView.tsx b/src/components/ContractsDashboard/Contractor/ContractorView.tsx index 18fedf5e6..a683a9a9a 100644 --- a/src/components/ContractsDashboard/Contractor/ContractorView.tsx +++ b/src/components/ContractsDashboard/Contractor/ContractorView.tsx @@ -87,7 +87,7 @@ const ContractorView = ({ contractorReference }: ContractorViewProps) => { const handleSubmit = (e: React.FormEvent) => { e.preventDefault() - refetchSorContracts() + refetchSorContracts && refetchSorContracts() } return ( diff --git a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItem.test.js.snap b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItem.test.js.snap index b63529180..dd6c14161 100644 --- a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItem.test.js.snap +++ b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItem.test.js.snap @@ -1,33 +1,37 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Contractors list item component should render the component 1`] = ` -
  • -
    -

    +

    + Sycous Limited +

    +

    + Active contracts: + +

    +
    +
    - Sycous Limited - -

    - Active contracts: -

    -
    -
    - -
    -
  • + + +
    `; diff --git a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItems.test.js.snap b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItems.test.js.snap index 93a4ceca9..edf3fa7c7 100644 --- a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItems.test.js.snap +++ b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorListItems.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Contractors list items component should render the component 1`] = ` @@ -7,151 +7,171 @@ exports[`Contractors list items component should render the component 1`] = ` class="lbh-list mobile-working-work-order-list" data-test-id="contractors-list" > -
  • -
    -

    - No ltd -

    -

    - Active contracts: - - 0 - -

    -
    -
    - -
    -
  • -
  • +

    + Active contracts: + + 0 + +

    + +
    + +
    +
  • + + -
    -

    - Yes ltd -

    -

    - Active contracts: - - 1 - -

    -
    -
    - -
    - -
  • +

    + Active contracts: + + 1 + +

    + +
    + +
    +
  • +
    + -
    -

    - Rat ltd -

    -

    - Active contracts: - - 0 - -

    -
    -
    - -
    - -
  • +

    + Active contracts: + + 0 + +

    + +
    + +
    +
  • +
    + -
    -

    - Cat ltd -

    -

    - Active contracts: - - 0 - -

    -
    -
    - -
    - -
  • +

    + Active contracts: + + 0 + +

    + +
    + +
    +
  • +
    + -
    -

    - Dog ltd -

    -

    - Active contracts: - - 1 - -

    -
    -
    - -
    - + Dog ltd + +

    + Active contracts: + + 1 + +

    + +
    + +
    + +
    diff --git a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorView.test.js.snap b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorView.test.js.snap index 990c42328..e807217b9 100644 --- a/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorView.test.js.snap +++ b/src/components/ContractsDashboard/Contractor/__snapshots__/ContractorView.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Contracts dashboard component should render component with sor code contracts displayed 1`] = ` @@ -24,7 +24,7 @@ exports[`Contracts dashboard component should render component with sor code con >
  • @@ -56,7 +56,7 @@ exports[`SorSearch component should render contracts with sor code that has been >
  • @@ -24,7 +24,7 @@ exports[`Contracts dashboard component should render the component 1`] = ` >
  • {
    - +
    { expect(screen.getAllByText('Bar').length).toBe(2) }) - it('closes the details panel after an option is clicked', () => { + it('closes the details panel after an option is clicked', async () => { render() expect(screen.getByTestId('details').getAttribute('open')).toBe(null) - act(() => { - userEvent.click(screen.getByText('Select action')) + await act(async () => { + await userEvent.click(screen.getByText('Select action')) }) expect(screen.getByTestId('details').getAttribute('open')).toBe('') - act(() => { - userEvent.click(screen.getByText('Bar')) + await act(async () => { + await userEvent.click(screen.getByText('Bar')) }) expect(screen.getByTestId('details').getAttribute('open')).toBe(null) diff --git a/src/components/Layout/TruncateText/__snapshots__/index.test.js.snap b/src/components/Layout/TruncateText/__snapshots__/index.test.js.snap index 80e6328e9..61beb19f2 100644 --- a/src/components/Layout/TruncateText/__snapshots__/index.test.js.snap +++ b/src/components/Layout/TruncateText/__snapshots__/index.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`TruncateText component should render truncate text, with truncate line of 3 1`] = ` diff --git a/src/components/Operatives/OperativeForm.tsx b/src/components/Operatives/OperativeForm.tsx index e1485a258..c10a5f33f 100644 --- a/src/components/Operatives/OperativeForm.tsx +++ b/src/components/Operatives/OperativeForm.tsx @@ -43,6 +43,7 @@ const OperativeForm = (props: Props) => { getValues={getValues} totalSMV={totalSMV} currentUserPayrollNumber={currentUserPayrollNumber} + jobIsSplitByOperative={undefined} /> (
  • - + {operativeDisplay}
  • diff --git a/src/components/Operatives/__snapshots__/OperativeList.test.js.snap b/src/components/Operatives/__snapshots__/OperativeList.test.js.snap index 61316e7b1..1e2ad4b41 100644 --- a/src/components/Operatives/__snapshots__/OperativeList.test.js.snap +++ b/src/components/Operatives/__snapshots__/OperativeList.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`OperativeList component should render operative list, each as an individual link 1`] = ` diff --git a/src/components/Operatives/__snapshots__/SelectOperatives.test.js.snap b/src/components/Operatives/__snapshots__/SelectOperatives.test.js.snap index 4b43d4780..0dad103b2 100644 --- a/src/components/Operatives/__snapshots__/SelectOperatives.test.js.snap +++ b/src/components/Operatives/__snapshots__/SelectOperatives.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`SelectOperatives component should disable the current operative when a current user payroll number is supplied 1`] = ` diff --git a/src/components/PastWorkOrders/MobileWorkingPastWorkOrdersView/__snapshots__/MobileWorkingPastWorkOrderListItems.test.js.snap b/src/components/PastWorkOrders/MobileWorkingPastWorkOrdersView/__snapshots__/MobileWorkingPastWorkOrderListItems.test.js.snap index 9c4c7a3d9..ecd1664be 100644 --- a/src/components/PastWorkOrders/MobileWorkingPastWorkOrdersView/__snapshots__/MobileWorkingPastWorkOrderListItems.test.js.snap +++ b/src/components/PastWorkOrders/MobileWorkingPastWorkOrdersView/__snapshots__/MobileWorkingPastWorkOrderListItems.test.js.snap @@ -1,116 +1,124 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`MobileWorkingPastWorkOrderListItems Component should be empty when there are no orders 1`] = ``; exports[`MobileWorkingPastWorkOrderListItems Component should match snapshot when there are work orders 1`] = ` -
  • -
    -
    +
    +
    +

    + 08:00 – 16:15 +

    + + Completed + +
    +

    + [e] emergency +

    - 08:00 – 16:15 + WO 1

    - - Completed - + 1 Hackney +

    +

    + N16 +

    +

    + Work order 1 +

    -

    - [e] emergency -

    -

    - WO 1 -

    -

    - 1 Hackney -

    -

    - N16 -

    -

    - Work order 1 -

    -
    -
    - -
    -
  • -
  • + +
  • + + -
    -
    +
    +
    +

    + 08:00 – 16:15 +

    + + Completed + +
    +

    + [e] emergency +

    - 08:00 – 16:15 + WO 2

    - - Completed - + 1 Hackney +

    +

    + N16 +

    +

    + Work order 2 +

    -

    - [e] emergency -

    -

    - WO 2 -

    -

    - 1 Hackney -

    -

    - N16 -

    -

    - Work order 2 -

    -
    -
    - -
    - + +
    + +
    `; diff --git a/src/components/PastWorkOrdersDatePicker/__snapshots__/PastWorkOrdersDatePicker.test.js.snap b/src/components/PastWorkOrdersDatePicker/__snapshots__/PastWorkOrdersDatePicker.test.js.snap index 1e773f566..f8b99c581 100644 --- a/src/components/PastWorkOrdersDatePicker/__snapshots__/PastWorkOrdersDatePicker.test.js.snap +++ b/src/components/PastWorkOrdersDatePicker/__snapshots__/PastWorkOrdersDatePicker.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`PastWorkOrdersDatePicker Component should be populated with the previous 5 working days 1`] = ` diff --git a/src/components/Properties/__snapshots__/PropertiesTable.test.js.snap b/src/components/Properties/__snapshots__/PropertiesTable.test.js.snap index ffa597a7b..63db70721 100644 --- a/src/components/Properties/__snapshots__/PropertiesTable.test.js.snap +++ b/src/components/Properties/__snapshots__/PropertiesTable.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`PropertiesTable component should render properly 1`] = ` diff --git a/src/components/Property/Contacts/TenantsContactTable/__snapshots__/TenantsContactTable.test.js.snap b/src/components/Property/Contacts/TenantsContactTable/__snapshots__/TenantsContactTable.test.js.snap index 592dc35cd..1df99c639 100644 --- a/src/components/Property/Contacts/TenantsContactTable/__snapshots__/TenantsContactTable.test.js.snap +++ b/src/components/Property/Contacts/TenantsContactTable/__snapshots__/TenantsContactTable.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`TenantsContactTable component when supplied with a list of tenants with phone numbers renders a table with a row for each contact 1`] = ` diff --git a/src/components/Property/Contacts/__snapshots__/ContactsTable.test.js.snap b/src/components/Property/Contacts/__snapshots__/ContactsTable.test.js.snap index bba966b94..f14d2dd0a 100644 --- a/src/components/Property/Contacts/__snapshots__/ContactsTable.test.js.snap +++ b/src/components/Property/Contacts/__snapshots__/ContactsTable.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`ContactsTable component when supplied with a list of contacts renders a table with a row for each contact 1`] = ` diff --git a/src/components/Property/PropertyBoilerHouseDetails/__snapshots__/index.test.js.snap b/src/components/Property/PropertyBoilerHouseDetails/__snapshots__/index.test.js.snap index e2b94c367..f323ba544 100644 --- a/src/components/Property/PropertyBoilerHouseDetails/__snapshots__/index.test.js.snap +++ b/src/components/Property/PropertyBoilerHouseDetails/__snapshots__/index.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`PropertyBoilerHouseDetails shows an error message when request fails 1`] = ` diff --git a/src/components/Property/PropertyDetails.tsx b/src/components/Property/PropertyDetails.tsx index 9b484feda..092d5e413 100644 --- a/src/components/Property/PropertyDetails.tsx +++ b/src/components/Property/PropertyDetails.tsx @@ -63,7 +63,7 @@ const PropertyDetails = ({ {isCurrentTimeOutOfHours() && (
    - +

    {hasLinkToProperty ? ( - +
    diff --git a/src/components/Property/PropertyFlags/__snapshots__/index.test.js.snap b/src/components/Property/PropertyFlags/__snapshots__/index.test.js.snap index b7b493cec..f59972cb5 100644 --- a/src/components/Property/PropertyFlags/__snapshots__/index.test.js.snap +++ b/src/components/Property/PropertyFlags/__snapshots__/index.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`PropertyFlags should render tenure and alerts 1`] = ` diff --git a/src/components/Property/PropertyRow.js b/src/components/Property/PropertyRow.js index 84e581d43..e6c74b941 100644 --- a/src/components/Property/PropertyRow.js +++ b/src/components/Property/PropertyRow.js @@ -10,7 +10,7 @@ const PropertyRow = ({ }) => ( - + {address} diff --git a/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.test.js b/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.test.js index 4e2b1907f..91e2ca1f6 100644 --- a/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.test.js +++ b/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.test.js @@ -1,9 +1,4 @@ -import { - act, - render, - screen, - waitForElementToBeRemoved, -} from '@testing-library/react' +import { act, render, screen, waitFor } from '@testing-library/react' import { EMERGENCY_PRIORITY_CODE, IMMEDIATE_PRIORITY_CODE, @@ -18,15 +13,19 @@ import { agent } from 'factories/agent' import { authorisationManager } from 'factories/authorisation_manager' import UserContext from '@/components/UserContext' -const axios = require('axios') +import axios from 'axios' -jest.mock('axios', () => jest.fn()) +jest.mock('axios') describe('RaiseWorkOrderForm component', () => { - axios.mockResolvedValue({ - data: { - alerts: [], - }, + axios.get.mockImplementation((url) => { + if (url.includes('alert')) { + return Promise.resolve({ + data: { + alerts: [], + }, + }) + } }) const props = { @@ -116,10 +115,10 @@ describe('RaiseWorkOrderForm component', () => { ) - await act(async () => { - await waitForElementToBeRemoved([ - screen.getByTestId('spinner-propertyFlags'), - ]) + await waitFor(() => { + expect( + screen.queryByTestId('spinner-propertyFlags') + ).not.toBeInTheDocument() }) expect(asFragment()).toMatchSnapshot() @@ -154,10 +153,10 @@ describe('RaiseWorkOrderForm component', () => { ) - await act(async () => { - await waitForElementToBeRemoved([ - screen.getByTestId('spinner-propertyFlags'), - ]) + await waitFor(() => { + expect( + screen.queryByTestId('spinner-propertyFlags') + ).not.toBeInTheDocument() }) expect(asFragment()).toMatchSnapshot() @@ -223,10 +222,10 @@ describe('RaiseWorkOrderForm component', () => { ) - await act(async () => { - await waitForElementToBeRemoved([ - screen.getByTestId('spinner-propertyFlags'), - ]) + await waitFor(() => { + expect( + screen.queryByTestId('spinner-propertyFlags') + ).not.toBeInTheDocument() }) expect(asFragment()).toMatchSnapshot() diff --git a/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.tsx b/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.tsx index 3a195fe00..f10d871c0 100644 --- a/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.tsx +++ b/src/components/Property/RaiseWorkOrder/RaiseWorkOrderForm.tsx @@ -14,9 +14,8 @@ import { IMMEDIATE_PRIORITY_CODE } from '@/utils/helpers/priorities' import { daysInHours } from '@/utils/time' import SelectPriority from './SelectPriority' import RaiseWorkOrderFollowOn from './RaiseWorkOrderFollowOn/RaiseWorkOrderFollowOn' -import UserContext from '../../UserContext' +import UserContext from '@/components/UserContext' import { canAssignFollowOnRelationship } from '@/root/src/utils/userPermissions' -import { useFeatureToggles } from '@/root/src/utils/frontEndApiClient/hooks/useFeatureToggles' import { Priority } from '@/root/src/models/priority' import { BudgetCode } from '@/root/src/models/budgetCode' import Contractor from '@/root/src/models/contractor' @@ -95,7 +94,7 @@ const RaiseWorkOrderForm = (props: Props) => { }) const { user } = useContext(UserContext) - const { simpleFeatureToggles } = useFeatureToggles() + const [priorityCode, setPriorityCode] = useState() const [totalCost, setTotalCost] = useState('') const overSpendLimit = totalCost > raiseLimit diff --git a/src/components/Property/RaiseWorkOrder/RateScheduleItemView.js b/src/components/Property/RaiseWorkOrder/RateScheduleItemView.js index 391e545d1..2176e4fe9 100644 --- a/src/components/Property/RaiseWorkOrder/RateScheduleItemView.js +++ b/src/components/Property/RaiseWorkOrder/RateScheduleItemView.js @@ -29,7 +29,7 @@ const RateScheduleItemView = ({ useEffect(() => { if (arrayOfRateScheduleItemComponentIndexes.length > 1) { if ( - formState.rateScheduleItems.length < + formState.rateScheduleItems?.length < arrayOfRateScheduleItemComponentIndexes.length ) { arrayOfRateScheduleItemComponentIndexes.pop() diff --git a/src/components/Property/RaiseWorkOrder/SelectPriority.tsx b/src/components/Property/RaiseWorkOrder/SelectPriority.tsx index e64475cf7..cb0f59326 100644 --- a/src/components/Property/RaiseWorkOrder/SelectPriority.tsx +++ b/src/components/Property/RaiseWorkOrder/SelectPriority.tsx @@ -91,6 +91,11 @@ const SelectPriority = (props: Props) => { })} error={errors && errors.priorityCode} widthClass="govuk-!-width-full" + hint={undefined} + children={undefined} + ignoreValue={undefined} + defaultValue={undefined} + value={undefined} /> {drsScheduled && ( <> diff --git a/src/components/Property/RaiseWorkOrder/__snapshots__/BudgetCodeItemView.test.js.snap b/src/components/Property/RaiseWorkOrder/__snapshots__/BudgetCodeItemView.test.js.snap index 092bd27e2..71ac57067 100644 --- a/src/components/Property/RaiseWorkOrder/__snapshots__/BudgetCodeItemView.test.js.snap +++ b/src/components/Property/RaiseWorkOrder/__snapshots__/BudgetCodeItemView.test.js.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`BudgetCodeItemView component should render a datalist with formatted budget codes as options 1`] = ` @@ -32,7 +32,6 @@ exports[`BudgetCodeItemView component should render a datalist with formatted bu id="budgetCode" list="autocomplete-list-budgetCode" name="budgetCode" - value="" /> `; +exports[`RaiseWorkOrderForm component should limit the priorities list to voids when H02 contract is selected 1`] = ` + + + Back + +
    +
    + + New repair + +

    + : +

    + + + Error: + + Error loading legal disrepair status: undefined with message: undefined + +
    + + + Error: + + Oops an error occurred with error status: undefined with message: undefined + +
      +
    • + Tenure: Secure +
    • +
    +
    +

    + Work order task details +

    +
    +
    + + + + +
    + +
    +
    + + + +
    +
    + +
    +
    + + + +
    + +
    +
    +
    +
    +
    + + + +
    + + +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    + +