diff --git a/package-lock.json b/package-lock.json index 6dfd0fd89691449cc123b3ed5a1c8d33957f2561..c3791abe6160a76664edb97750677ee2ddf8ea1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@next/font": "^13.5.2", "@reduxjs/toolkit": "^1.9.6", "@types/node": "20.6.2", + "@types/openlayers": "^4.6.20", "@types/react": "18.2.21", "@types/react-dom": "18.2.7", "autoprefixer": "10.4.15", @@ -19,7 +20,9 @@ "axios-hooks": "^5.0.0", "eslint-config-next": "13.4.19", "next": "13.4.19", + "ol": "^8.1.0", "postcss": "8.4.29", + "query-string": "7.1.3", "react": "18.2.0", "react-accessible-accordion": "^5.0.0", "react-dom": "18.2.0", @@ -58,9 +61,10 @@ "jest-junit": "^16.0.0", "jest-watch-typeahead": "^2.2.2", "lint-staged": "^14.0.1", + "next-router-mock": "^0.9.10", "prettier": "^3.0.3", "prettier-2": "npm:prettier@^2", - "prettier-plugin-tailwindcss": "^0.5.4", + "prettier-plugin-tailwindcss": "^0.5.6", "typescript": "^5.2.2", "zod-fixture": "^2.5.0" } @@ -1876,6 +1880,11 @@ "node": ">= 8" } }, + "node_modules/@petamoriken/float16": { + "version": "3.8.4", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.4.tgz", + "integrity": "sha512-kB+NJ5Br56ZhElKsf0pM7/PQfrDdDVMRz8f0JM6eVOGE+L89z9hwcst9QvWBBnazzuqGTGtPsJNZoQ1JdNiGSQ==" + }, "node_modules/@reduxjs/toolkit": { "version": "1.9.6", "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.6.tgz", @@ -2239,6 +2248,11 @@ "integrity": "sha512-lqa4UEhhv/2sjjIQgjX8B+RBjj47eo0mzGasklVJ78UKGQY1r0VpB9XHDaZZO9qzEFDdy4MrXLuEaSmPrPSe/A==", "dev": true }, + "node_modules/@types/openlayers": { + "version": "4.6.20", + "resolved": "https://registry.npmjs.org/@types/openlayers/-/openlayers-4.6.20.tgz", + "integrity": "sha512-TYgdyK1WyLFcwlFkz2A7lK0stj3MFdVZeUc6+AWCmqsAHk+0o9V8TOgMqdPpb0cVIxknHwxty/g8VawWTt/FRw==" + }, "node_modules/@types/prop-types": { "version": "15.7.8", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.8.tgz", @@ -4308,6 +4322,14 @@ "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==", "dev": true }, + "node_modules/decode-uri-component": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", @@ -4530,6 +4552,11 @@ "node": ">=4" } }, + "node_modules/earcut": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", + "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -5811,6 +5838,14 @@ "node": ">=8" } }, + "node_modules/filter-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", + "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/find-node-modules": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/find-node-modules/-/find-node-modules-2.1.3.tgz", @@ -6007,6 +6042,34 @@ "node": ">=6.9.0" } }, + "node_modules/geotiff": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.7.tgz", + "integrity": "sha512-FKvFTNowMU5K6lHYY2f83d4lS2rsCNdpUC28AX61x9ZzzqPNaWFElWv93xj0eJFaNyOYA63ic5OzJ88dHpoA5Q==", + "dependencies": { + "@petamoriken/float16": "^3.4.7", + "lerc": "^3.0.0", + "pako": "^2.0.4", + "parse-headers": "^2.0.2", + "quick-lru": "^6.1.1", + "web-worker": "^1.2.0", + "xml-utils": "^1.0.2" + }, + "engines": { + "node": ">=10.19" + } + }, + "node_modules/geotiff/node_modules/quick-lru": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.2.tgz", + "integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -6509,7 +6572,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -8508,6 +8570,11 @@ "node": "> 0.8" } }, + "node_modules/lerc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lerc/-/lerc-3.0.0.tgz", + "integrity": "sha512-Rm4J/WaHhRa93nCN2mwWDZFoRVF18G1f47C+kvQWyHGEZxFpTUi73p7lMVSAndyxGt6lJ2/CFbOcf9ra5p8aww==" + }, "node_modules/leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -9445,6 +9512,16 @@ } } }, + "node_modules/next-router-mock": { + "version": "0.9.10", + "resolved": "https://registry.npmjs.org/next-router-mock/-/next-router-mock-0.9.10.tgz", + "integrity": "sha512-bK6sRb/xGNFgHVUZuvuApn6KJBAKTPiP36A7a9mO77U4xQO5ukJx9WHlU67Tv8AuySd09pk0+Hu8qMVIAmLO6A==", + "dev": true, + "peerDependencies": { + "next": ">=10.0.0", + "react": ">=17.0.0" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.14", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", @@ -9669,6 +9746,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/ol": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/ol/-/ol-8.1.0.tgz", + "integrity": "sha512-cx3SH2plpFS9fM8pp1nCypgQXGJD7Mcb1E3mEySmy5XEw1DUEo+kkNzgtAZz5qupekqi7aU9iBJEjCoMfqvO2Q==", + "dependencies": { + "earcut": "^2.2.3", + "geotiff": "^2.0.7", + "pbf": "3.2.1", + "rbush": "^3.0.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/openlayers" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -9798,6 +9890,11 @@ "node": ">=6" } }, + "node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -9809,6 +9906,11 @@ "node": ">=6" } }, + "node_modules/parse-headers": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", + "integrity": "sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA==" + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -9885,6 +9987,18 @@ "node": ">=8" } }, + "node_modules/pbf": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz", + "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==", + "dependencies": { + "ieee754": "^1.1.12", + "resolve-protobuf-schema": "^2.1.0" + }, + "bin": { + "pbf": "bin/pbf" + } + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -10169,9 +10283,9 @@ } }, "node_modules/prettier-plugin-tailwindcss": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.5.5.tgz", - "integrity": "sha512-voy0CjWv/CM8yeaduv5ZwovovpTGMR5LbzlhGF+LtEvMJt9wBeVTVnW781hL38R/RcDXCJwN2rolsgr94B/n0Q==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.5.6.tgz", + "integrity": "sha512-2Xgb+GQlkPAUCFi3sV+NOYcSI5XgduvDBL2Zt/hwJudeKXkyvRS65c38SB0yb9UB40+1rL83I6m0RtlOQ8eHdg==", "dev": true, "engines": { "node": ">=14.21.3" @@ -10316,6 +10430,11 @@ "react-is": "^16.13.1" } }, + "node_modules/protocol-buffers-schema": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz", + "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -10376,6 +10495,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/query-string": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", + "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==", + "dependencies": { + "decode-uri-component": "^0.2.2", + "filter-obj": "^1.1.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", @@ -10410,6 +10546,11 @@ "node": ">=8" } }, + "node_modules/quickselect": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz", + "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==" + }, "node_modules/randexp": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", @@ -10423,6 +10564,14 @@ "node": ">=4" } }, + "node_modules/rbush": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/rbush/-/rbush-3.0.1.tgz", + "integrity": "sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==", + "dependencies": { + "quickselect": "^2.0.0" + } + }, "node_modules/react": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", @@ -10860,6 +11009,14 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, + "node_modules/resolve-protobuf-schema": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz", + "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==", + "dependencies": { + "protocol-buffers-schema": "^3.3.1" + } + }, "node_modules/resolve.exports": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", @@ -11204,6 +11361,14 @@ "integrity": "sha512-lpT8hSQp9jAKp9mhtBU4Xjon8LPGBvLIuBiSVhMEtmLecTh2mO0tlqrAMp47tBXzMr13NJMQ2lf7RpQGLJ3HsQ==", "dev": true }, + "node_modules/split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", + "engines": { + "node": ">=6" + } + }, "node_modules/split2": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", @@ -11285,6 +11450,14 @@ "node": ">=10.0.0" } }, + "node_modules/strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", + "engines": { + "node": ">=4" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -12181,6 +12354,11 @@ "defaults": "^1.0.3" } }, + "node_modules/web-worker": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", + "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==" + }, "node_modules/webidl-conversions": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", @@ -12402,6 +12580,11 @@ "node": ">=12" } }, + "node_modules/xml-utils": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.7.0.tgz", + "integrity": "sha512-bWB489+RQQclC7A9OW8e5BzbT8Tu//jtAOvkYwewFr+Q9T9KDGvfzC1lp0pYPEQPEoPQLDkmxkepSC/2gIAZGw==" + }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", diff --git a/package.json b/package.json index a7feaab56721eecfb48ad854e60c0ac989dd447d..1a9bd09169fddc2c35feb6141a1548d4567e11f8 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@next/font": "^13.5.2", "@reduxjs/toolkit": "^1.9.6", "@types/node": "20.6.2", + "@types/openlayers": "^4.6.20", "@types/react": "18.2.21", "@types/react-dom": "18.2.7", "autoprefixer": "10.4.15", @@ -33,7 +34,9 @@ "axios-hooks": "^5.0.0", "eslint-config-next": "13.4.19", "next": "13.4.19", + "ol": "^8.1.0", "postcss": "8.4.29", + "query-string": "7.1.3", "react": "18.2.0", "react-accessible-accordion": "^5.0.0", "react-dom": "18.2.0", @@ -72,9 +75,10 @@ "jest-junit": "^16.0.0", "jest-watch-typeahead": "^2.2.2", "lint-staged": "^14.0.1", + "next-router-mock": "^0.9.10", "prettier": "^3.0.3", "prettier-2": "npm:prettier@^2", - "prettier-plugin-tailwindcss": "^0.5.4", + "prettier-plugin-tailwindcss": "^0.5.6", "typescript": "^5.2.2", "zod-fixture": "^2.5.0" }, diff --git a/prettier.config.js b/prettier.config.js index 7946df2239da49eb1b21142cd0f61e667ceedefe..fd41c7ea28115342ff628216fd2269ac7fb37e53 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -3,7 +3,7 @@ const config = { trailingComma: 'all', printWidth: 100, arrowParens: 'avoid', - plugins: ['prettier-plugin-tailwindcss'], + plugins: [import('prettier-plugin-tailwindcss')], tailwindConfig: './tailwind.config.ts', tailwindFunctions: ['twMerge'], }; diff --git a/setupTests.ts b/setupTests.ts index 7b0828bfa80fb3c4504510349e22dc4cf5bc0a7b..c74f9623495588d60aa54799a64cc29f91d2d56b 100644 --- a/setupTests.ts +++ b/setupTests.ts @@ -1 +1,3 @@ import '@testing-library/jest-dom'; + +jest.mock('next/router', () => require('next-router-mock')); diff --git a/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.test.tsx b/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.test.tsx index a8c934f4cdc75817e2fd45ff6bdbd5dadb301fc5..e61a7403b87cc2c30538e1946f58e5456be9b530 100644 --- a/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.test.tsx +++ b/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.test.tsx @@ -1,6 +1,7 @@ -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { StoreType } from '@/redux/store'; +import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; import { fireEvent, render, screen } from '@testing-library/react'; +import mockedRouter from 'next-router-mock'; import { SearchBar } from './SearchBar.component'; const renderComponent = (): { store: StoreType } => { @@ -50,4 +51,55 @@ describe('SearchBar - component', () => { expect(input).toBeDisabled(); }); + + it('should set parameters on the url when the user enters a value in the search bar and clicks Enter', () => { + renderComponent(); + + const input = screen.getByTestId<HTMLInputElement>('search-input'); + fireEvent.change(input, { target: { value: 'park7' } }); + + const button = screen.getByRole('button'); + fireEvent.click(button); + + expect(button).toBeDisabled(); + + expect(mockedRouter).toMatchObject({ + asPath: '/?search=park7', + pathname: '/', + query: { search: 'park7' }, + }); + }); + + it('should set parameters on the url when the user enters a value in the search bar and clicks lens button', () => { + renderComponent(); + + const input = screen.getByTestId<HTMLInputElement>('search-input'); + fireEvent.change(input, { target: { value: 'park7' } }); + + fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', charCode: 13 }); + + expect(input).toBeDisabled(); + + expect(mockedRouter).toMatchObject({ + asPath: '/?search=park7', + pathname: '/', + query: { search: 'park7' }, + }); + }); + + it('should set the value on the input filed when the user has query parameters in the url', () => { + renderComponent(); + + mockedRouter.push('/?search=park7'); + + const input = screen.getByTestId<HTMLInputElement>('search-input'); + + expect(input.value).toBe('park7'); + + expect(mockedRouter).toMatchObject({ + asPath: '/?search=park7', + pathname: '/', + query: { search: 'park7' }, + }); + }); }); diff --git a/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.tsx b/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.tsx index 4cce8b0a86bcf5b80f073ca763b0e5ab2a0e2fb8..e683755aba3e0111f6c1c650e25f4ba115af4818 100644 --- a/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.tsx +++ b/src/components/FunctionalArea/TopBar/SearchBar/SearchBar.component.tsx @@ -1,4 +1,5 @@ import lensIcon from '@/assets/vectors/icons/lens.svg'; +import { useParamsQuery } from '@/components/FunctionalArea/TopBar/SearchBar/hooks/useParamsQuery'; import { isDrawerOpenSelector } from '@/redux/drawer/drawer.selectors'; import { openSearchDrawer } from '@/redux/drawer/drawer.slice'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; @@ -14,12 +15,15 @@ import { useSelector } from 'react-redux'; const ENTER_KEY_CODE = 'Enter'; export const SearchBar = (): JSX.Element => { - const [searchValue, setSearchValue] = useState<string>(''); - const dispatch = useAppDispatch(); const isPendingSearchStatus = useSelector(isPendingSearchStatusSelector); const prevSearchValue = useSelector(searchValueSelector); const isDrawerOpen = useSelector(isDrawerOpenSelector); + const { setSearchQueryInRouter, searchParams } = useParamsQuery(); + + const [searchValue, setSearchValue] = useState<string>((searchParams?.search as string) || ''); + const dispatch = useAppDispatch(); + const isSameSearchValue = prevSearchValue === searchValue; const openSearchDrawerIfClosed = (): void => { @@ -34,6 +38,7 @@ export const SearchBar = (): JSX.Element => { const onSearchClick = (): void => { if (!isSameSearchValue) { dispatch(getSearchData(searchValue)); + setSearchQueryInRouter(searchValue); openSearchDrawerIfClosed(); } }; @@ -41,6 +46,7 @@ export const SearchBar = (): JSX.Element => { const handleKeyPress = (event: KeyboardEvent<HTMLInputElement>): void => { if (!isSameSearchValue && event.code === ENTER_KEY_CODE) { dispatch(getSearchData(searchValue)); + setSearchQueryInRouter(searchValue); openSearchDrawerIfClosed(); } }; diff --git a/src/components/FunctionalArea/TopBar/SearchBar/hooks/useParamsQuery.ts b/src/components/FunctionalArea/TopBar/SearchBar/hooks/useParamsQuery.ts new file mode 100644 index 0000000000000000000000000000000000000000..c332beda9c2f6ce79499c2435ddca59b7c7fba19 --- /dev/null +++ b/src/components/FunctionalArea/TopBar/SearchBar/hooks/useParamsQuery.ts @@ -0,0 +1,38 @@ +import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; +import { getSearchData } from '@/redux/search/search.thunks'; +import { useRouter } from 'next/router'; +import type { ParsedQuery } from 'query-string'; +import qs from 'query-string'; +import { useEffect } from 'react'; + +type UseParamsQuery = { + setSearchQueryInRouter: (searchValue: string) => void; + searchParams: ParsedQuery<string>; +}; + +export const useParamsQuery = (): UseParamsQuery => { + const router = useRouter(); + const dispatch = useAppDispatch(); + + const path = router.asPath; + + // The number of the character from which to cut the characters from path. + const sliceFromCharNumber = 2; + // The number of the character at which to end the cut string from path. + const sliceToCharNumber = path.length; + const searchParams = qs.parse(path.slice(sliceFromCharNumber, sliceToCharNumber)); + + const setSearchQueryInRouter = (searchValue: string): void => { + const searchQuery = { + search: searchValue, + }; + + router.push(`?${qs.stringify(searchQuery)}`); + }; + + useEffect(() => { + if (searchParams?.search) dispatch(getSearchData(searchParams.search as string)); + }, [dispatch]); + + return { setSearchQueryInRouter, searchParams }; +}; diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx index 5658068f5953fd41e2e1dc507a6a37a178597ef9..3e62bb01794f181da42cfbce620a9161f9463ff7 100644 --- a/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx +++ b/src/components/Map/Drawer/SearchDrawerWrapper/GroupedSearchResults/BioEntitiesAccordion/BioEntitiesAccordion.component.test.tsx @@ -59,8 +59,7 @@ describe('BioEntitiesAccordion - component', () => { }); expect(screen.getByText('Content (10)')).toBeInTheDocument(); - expect(screen.getByText('Core PD map (3)')).toBeInTheDocument(); - expect(screen.getByText('Histamine signaling (4)')).toBeInTheDocument(); - expect(screen.getByText('PRKN substrates (3)')).toBeInTheDocument(); + expect(screen.getByText('Core PD map (8)')).toBeInTheDocument(); + expect(screen.getByText('Histamine signaling (2)')).toBeInTheDocument(); }); }); diff --git a/src/constants/map.ts b/src/constants/map.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8bde744a06a6337ec5a2dcc83aa720c364c3fd1 --- /dev/null +++ b/src/constants/map.ts @@ -0,0 +1,19 @@ +import { Point } from '@/types/map'; + +export const DEFAULT_TILE_SIZE = 256; +export const DEFAULT_MIN_ZOOM = 2; +export const DEFAULT_MAX_ZOOM = 9; +export const DEFAULT_ZOOM = 5; +export const DEFAULT_CENTER_X = 0; +export const DEFAULT_CENTER_Y = 0; + +export const DEFAULT_CENTER_POINT: Point = { + x: DEFAULT_CENTER_X, + y: DEFAULT_CENTER_Y, + z: DEFAULT_ZOOM, +}; + +export const OPTIONS = { + showFullExtent: false, + wrapXInTileLayer: false, +}; diff --git a/src/models/bioEntitySchema.ts b/src/models/bioEntitySchema.ts index ae92c4e49cd9d83cd8a312288ea8a31ecb302b38..51f1880c44af38be603d8633c84bb0b8d7dc1432 100644 --- a/src/models/bioEntitySchema.ts +++ b/src/models/bioEntitySchema.ts @@ -18,7 +18,7 @@ export const bioEntitySchema = z.object({ references: z.array(referenceSchema), z: z.number(), notes: z.string(), - symbol: z.union([z.string(), z.null()]), + symbol: z.string().nullable(), homodimer: z.number(), nameX: z.number(), nameY: z.number(), @@ -32,24 +32,24 @@ export const bioEntitySchema = z.object({ transparencyLevel: z.string(), synonyms: z.array(z.string()), formerSymbols: z.array(z.string()), - fullName: z.union([z.string(), z.null()]), - abbreviation: z.union([z.string(), z.null()]), - formula: z.union([z.string(), z.null()]), - glyph: z.union([glyphSchema, z.null()]), + fullName: z.string().nullable(), + abbreviation: z.string().nullable(), + formula: z.string().nullable(), + glyph: glyphSchema.nullable(), activity: z.boolean(), - structuralState: z.union([structuralStateSchema, z.null()]), - hypothetical: z.union([z.boolean(), z.null()]), + structuralState: structuralStateSchema.nullable(), + hypothetical: z.boolean().nullable(), boundaryCondition: z.boolean(), constant: z.boolean(), - initialAmount: z.union([z.number(), z.null()]), - initialConcentration: z.union([z.number(), z.null()]), - charge: z.union([z.number(), z.null()]), - substanceUnits: z.union([z.string(), z.null()]), + initialAmount: z.number().nullable(), + initialConcentration: z.number().nullable(), + charge: z.number().nullable(), + substanceUnits: z.string().nullable(), onlySubstanceUnits: z.boolean(), modificationResidues: z.optional(z.array(modificationResiduesSchema)), - complex: z.union([z.number(), z.null()]), - compartment: z.union([z.number(), z.null()]), - submodel: z.union([submodelSchema, z.null()]), + complex: z.number().nullable(), + compartment: z.number().nullable(), + submodel: submodelSchema.nullable(), x: z.number(), y: z.number(), lineWidth: z.number(), @@ -58,8 +58,8 @@ export const bioEntitySchema = z.object({ fillColor: colorSchema, borderColor: colorSchema, smiles: z.optional(z.string()), - inChI: z.optional(z.string()), - inChIKey: z.optional(z.string()), + inChI: z.optional(z.string().nullable()), + inChIKey: z.optional(z.string().nullable()), thickness: z.optional(z.number()), outerWidth: z.optional(z.number()), innerWidth: z.optional(z.number()), @@ -70,11 +70,11 @@ export const bioEntitySchema = z.object({ upperBound: z.optional(z.boolean()), subsystem: z.optional(z.string()), geneProteinReaction: z.optional(z.string()), - kinetics: z.union([z.null(), z.undefined()]), - products: z.union([z.array(productsSchema), z.undefined()]), - reactants: z.union([z.array(productsSchema), z.undefined()]), - modifiers: z.union([z.array(productsSchema), z.undefined()]), - processCoordinates: z.union([z.null(), z.undefined()]), - line: z.union([lineSchema, z.undefined()]), - operators: z.union([z.array(operatorSchema), z.undefined()]), + kinetics: z.optional(z.null()), + products: z.optional(z.array(productsSchema)), + reactants: z.optional(z.array(productsSchema)), + modifiers: z.optional(z.array(productsSchema)), + processCoordinates: z.optional(z.null()), + line: z.optional(lineSchema), + operators: z.optional(z.array(operatorSchema)), }); diff --git a/src/models/modelSchema.ts b/src/models/modelSchema.ts index 64752c8c1bd4043d1ff24cc0de26022f5f22daa2..0c8a488d7f340dc182ec0b62a1fbe785089d9340 100644 --- a/src/models/modelSchema.ts +++ b/src/models/modelSchema.ts @@ -15,17 +15,17 @@ export const modelSchema = z.object({ /** size of the png tile used to visualize in frontend */ tileSize: z.number(), /** default x center used in frontend visualization */ - defaultCenterX: z.union([z.number(), z.null()]), + defaultCenterX: z.number().nullable(), /** default y center used in frontend visualization */ - defaultCenterY: z.union([z.number(), z.null()]), + defaultCenterY: z.number().nullable(), /** default zoom level used in frontend visualization */ - defaultZoomLevel: z.union([z.number(), z.null()]), + defaultZoomLevel: z.number().nullable(), /** minimum zoom level availbale for the map */ minZoom: z.number(), /** maximum zoom level available for the map */ maxZoom: z.number(), authors: z.array(authorSchema), references: z.array(referenceSchema), - creationDate: z.union([z.string(), z.null()]), + creationDate: z.string().nullable(), modificationDates: z.array(z.string()), }); diff --git a/src/models/modificationResiduesSchema.ts b/src/models/modificationResiduesSchema.ts index 4b71bf72f4df2272b829b7bcb920a864982f8191..884ebe4b5c2f5c5fe59eec89a2c115123b8adb73 100644 --- a/src/models/modificationResiduesSchema.ts +++ b/src/models/modificationResiduesSchema.ts @@ -9,7 +9,7 @@ export const modificationResiduesSchema = z.object({ position: positionSchema, z: z.number(), borderColor: colorSchema, - state: z.union([z.string(), z.number(), z.null()]), + state: z.union([z.string(), z.number()]).nullable(), size: z.number(), elementId: z.string(), }); diff --git a/src/models/products.ts b/src/models/products.ts index cfc9b6b5c8cb96665afbfdbb3f66f8ab97a42e9f..4807c4862dbe9be1abe5be98890bcbc5066b3509 100644 --- a/src/models/products.ts +++ b/src/models/products.ts @@ -2,6 +2,6 @@ import { z } from 'zod'; export const productsSchema = z.object({ aliasId: z.number(), - stoichiometry: z.union([z.number(), z.null()]), - type: z.union([z.string(), z.undefined()]), + stoichiometry: z.number().nullable(), + type: z.optional(z.string()), }); diff --git a/src/models/referenceSchema.ts b/src/models/referenceSchema.ts index 432f0eeceb6f7b1f3778e283ebbc7db050fd74be..30a31e287cfdc79348e9655b635a417a0729a34b 100644 --- a/src/models/referenceSchema.ts +++ b/src/models/referenceSchema.ts @@ -2,7 +2,7 @@ import { z } from 'zod'; import { articleSchema } from './articleSchema'; export const referenceSchema = z.object({ - link: z.union([z.string(), z.null()]), + link: z.string().nullable(), article: articleSchema.optional(), type: z.string(), resource: z.string(), diff --git a/src/redux/bioEntity/bioEntity.reducers.test.ts b/src/redux/bioEntity/bioEntity.reducers.test.ts index e73215b52ef2b7465385dc0f59d64c34a991503e..ed3afdbda94f2b9a5ed7641b292337e7a6ce57af 100644 --- a/src/redux/bioEntity/bioEntity.reducers.test.ts +++ b/src/redux/bioEntity/bioEntity.reducers.test.ts @@ -1,5 +1,5 @@ import { bioEntityResponseFixture } from '@/models/fixtures/bioEntityContentsFixture'; -import { mockNetworkExperimentalAPIResponse } from '@/utils/mockNetworkResponse'; +import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, @@ -10,7 +10,7 @@ import { getBioEntity } from './bioEntity.thunks'; import bioEntityContentsReducer from './bioEntity.slice'; import { BioEntityContentsState } from './bioEntity.types'; -const mockedAxiosClient = mockNetworkExperimentalAPIResponse(); +const mockedAxiosClient = mockNetworkNewAPIResponse(); const SEARCH_QUERY = 'park7'; const INITIAL_STATE: BioEntityContentsState = { diff --git a/src/redux/bioEntity/bioEntity.thunks.test.ts b/src/redux/bioEntity/bioEntity.thunks.test.ts index f180cfe2a36400a5c62c30c527e0965b784b45bb..b5b51d289aa49fa406b619e3e1fa1924a5afd9f1 100644 --- a/src/redux/bioEntity/bioEntity.thunks.test.ts +++ b/src/redux/bioEntity/bioEntity.thunks.test.ts @@ -1,5 +1,5 @@ import { bioEntityResponseFixture } from '@/models/fixtures/bioEntityContentsFixture'; -import { mockNetworkExperimentalAPIResponse } from '@/utils/mockNetworkResponse'; +import { mockNetworkNewAPIResponse } from '@/utils/mockNetworkResponse'; import { ToolkitStoreWithSingleSlice, createStoreInstanceUsingSliceReducer, @@ -10,7 +10,7 @@ import { getBioEntity } from './bioEntity.thunks'; import contentsReducer from './bioEntity.slice'; import { BioEntityContentsState } from './bioEntity.types'; -const mockedAxiosClient = mockNetworkExperimentalAPIResponse(); +const mockedAxiosClient = mockNetworkNewAPIResponse(); const SEARCH_QUERY = 'park7'; describe('bioEntityContents thunks', () => { diff --git a/src/redux/bioEntity/bioEntity.thunks.ts b/src/redux/bioEntity/bioEntity.thunks.ts index fbc7c2e0622a9cef59f02c3b4e64129e522a56f6..c175948124fa5fd2e193f5e0cca003d9743fad44 100644 --- a/src/redux/bioEntity/bioEntity.thunks.ts +++ b/src/redux/bioEntity/bioEntity.thunks.ts @@ -1,5 +1,5 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; -import { axiosInstanceExperimentalAPI } from '@/services/api/utils/axiosInstance'; +import { axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance'; import { BioEntityContent, BioEntityResponse } from '@/types/models'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; import { apiPath } from '@/redux/apiPath'; @@ -8,7 +8,7 @@ import { bioEntityResponseSchema } from '@/models/bioEntityResponseSchema'; export const getBioEntity = createAsyncThunk( 'project/getBioEntityContents', async (searchQuery: string): Promise<BioEntityContent[] | undefined> => { - const response = await axiosInstanceExperimentalAPI.get<BioEntityResponse>( + const response = await axiosInstanceNewAPI.get<BioEntityResponse>( apiPath.getBioEntityContentsStringWithQuery(searchQuery), ); diff --git a/src/redux/map/map.constants.ts b/src/redux/map/map.constants.ts new file mode 100644 index 0000000000000000000000000000000000000000..19bf5fb562d94a93ce85bdfac206caafe498cb96 --- /dev/null +++ b/src/redux/map/map.constants.ts @@ -0,0 +1,27 @@ +import { PROJECT_ID } from '@/constants'; +import { + DEFAULT_CENTER_POINT, + DEFAULT_MAX_ZOOM, + DEFAULT_MIN_ZOOM, + DEFAULT_TILE_SIZE, +} from '@/constants/map'; +import { MapData } from './map.types'; + +export const MAP_DATA_INITIAL_STATE: MapData = { + projectId: PROJECT_ID, + meshId: '', + modelId: 0, + overlaysIds: [], + position: DEFAULT_CENTER_POINT, + show: { + legend: false, + comments: false, + }, + size: { + width: 0, + height: 0, + tileSize: DEFAULT_TILE_SIZE, + minZoom: DEFAULT_MIN_ZOOM, + maxZoom: DEFAULT_MAX_ZOOM, + }, +}; diff --git a/src/redux/map/map.reducers.ts b/src/redux/map/map.reducers.ts new file mode 100644 index 0000000000000000000000000000000000000000..95d763254f76bcea970ec8f428e2082e80fba5d2 --- /dev/null +++ b/src/redux/map/map.reducers.ts @@ -0,0 +1,9 @@ +import { PayloadAction } from '@reduxjs/toolkit'; +import { MapData, MapState } from './map.types'; + +export const setMapDataReducer = ( + state: MapState, + action: PayloadAction<Partial<MapData> | undefined>, +): void => { + state.data = { ...state.data, ...action.payload }; +}; diff --git a/src/redux/map/map.selectors.ts b/src/redux/map/map.selectors.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e559fd44e250809c36021ac18690da90cf1d92e --- /dev/null +++ b/src/redux/map/map.selectors.ts @@ -0,0 +1,4 @@ +import { createSelector } from '@reduxjs/toolkit'; +import { rootSelector } from '@/redux/root/root.selectors'; + +export const mapDataSelector = createSelector(rootSelector, state => state.map); diff --git a/src/redux/map/map.slice.ts b/src/redux/map/map.slice.ts new file mode 100644 index 0000000000000000000000000000000000000000..62b95df2be671ec12d4dec2341978c586ef235c2 --- /dev/null +++ b/src/redux/map/map.slice.ts @@ -0,0 +1,22 @@ +import { createSlice } from '@reduxjs/toolkit'; +import { MAP_DATA_INITIAL_STATE } from './map.constants'; +import { setMapDataReducer } from './map.reducers'; +import { MapState } from './map.types'; + +const initialState: MapState = { + data: MAP_DATA_INITIAL_STATE, + loading: 'idle', + error: { name: '', message: '' }, +}; + +const mapSlice = createSlice({ + name: 'map', + initialState, + reducers: { + setMapData: setMapDataReducer, + }, +}); + +export const { setMapData } = mapSlice.actions; + +export default mapSlice.reducer; diff --git a/src/redux/map/map.types.ts b/src/redux/map/map.types.ts new file mode 100644 index 0000000000000000000000000000000000000000..245bd58a7867dc4b6e3602a0079c3cbc0e63b646 --- /dev/null +++ b/src/redux/map/map.types.ts @@ -0,0 +1,29 @@ +import { Loading } from '@/types/loadingState'; +import { Point } from '@/types/map'; + +export interface MapSize { + width: number; + height: number; + tileSize: number; + minZoom: number; + maxZoom: number; +} + +export type MapData = { + projectId: string; + meshId: string; + modelId: number; + overlaysIds: number[]; + size: MapSize; + position: Point; + show: { + legend: boolean; + comments: boolean; + }; +}; + +export type MapState = { + data: MapData; + loading: Loading; + error: Error; +}; diff --git a/src/redux/search/search.reducers.test.ts b/src/redux/search/search.reducers.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..46495b268efc8f5c87e8da6a144117478dd65426 --- /dev/null +++ b/src/redux/search/search.reducers.test.ts @@ -0,0 +1,51 @@ +import { getSearchData } from '@/redux/search/search.thunks'; +import type { SearchState } from '@/redux/search/search.types'; +import { + ToolkitStoreWithSingleSlice, + createStoreInstanceUsingSliceReducer, +} from '@/utils/createStoreInstanceUsingSliceReducer'; +import searchReducer from './search.slice'; + +const SEARCH_QUERY = 'Corticosterone'; + +const INITIAL_STATE: SearchState = { + searchValue: '', + loading: 'idle', +}; + +describe('search reducer', () => { + let store = {} as ToolkitStoreWithSingleSlice<SearchState>; + beforeEach(() => { + store = createStoreInstanceUsingSliceReducer('search', searchReducer); + }); + + it('should match initial state', () => { + const action = { type: 'unknown' }; + + expect(searchReducer(undefined, action)).toEqual(INITIAL_STATE); + }); + + it('should update store after succesfull getSearchData query', async () => { + await store.dispatch(getSearchData(SEARCH_QUERY)); + + const { searchValue, loading } = store.getState().search; + expect(searchValue).toEqual(SEARCH_QUERY); + expect(loading).toEqual('succeeded'); + }); + + it('should update store on loading getSearchData query', async () => { + const searchPromise = store.dispatch(getSearchData(SEARCH_QUERY)); + + const { searchValue, loading } = store.getState().search; + expect(searchValue).toEqual(SEARCH_QUERY); + expect(loading).toEqual('pending'); + + searchPromise.then(() => { + const { searchValue: searchValueFulfilled, loading: promiseFulfilled } = + store.getState().search; + + expect(searchValueFulfilled).toEqual(SEARCH_QUERY); + expect(promiseFulfilled).toEqual('succeeded'); + }); + }); +}); diff --git a/src/redux/search/search.reducers.ts b/src/redux/search/search.reducers.ts index 28226ca9200f8dfef935eae8ff1f6b45fb6f3337..21e30af3a9bc50deca0e7800746589bb792ef7fd 100644 --- a/src/redux/search/search.reducers.ts +++ b/src/redux/search/search.reducers.ts @@ -8,7 +8,8 @@ export const getSearchDataReducer = (builder: ActionReducerMapBuilder<SearchStat state.searchValue = action.meta.arg; state.loading = 'pending'; }); - builder.addCase(getSearchData.fulfilled, state => { + builder.addCase(getSearchData.fulfilled, (state, action) => { + state.searchValue = action.meta.arg; state.loading = 'succeeded'; }); builder.addCase(getSearchData.rejected, state => { diff --git a/src/redux/store.ts b/src/redux/store.ts index cc60130e8db8dbfdf5e32608a934f4f200580e85..35208d7d0978999cb466ecac53889822ed814312 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -2,6 +2,7 @@ import bioEntityReducer from '@/redux/bioEntity/bioEntity.slice'; import chemicalsReducer from '@/redux/chemicals/chemicals.slice'; import drawerReducer from '@/redux/drawer/drawer.slice'; import drugsReducer from '@/redux/drugs/drugs.slice'; +import mapReducer from '@/redux/map/map.slice'; import mirnasReducer from '@/redux/mirnas/mirnas.slice'; import modelsReducer from '@/redux/models/models.slice'; import projectSlice from '@/redux/project/project.slice'; @@ -17,6 +18,7 @@ export const store = configureStore({ chemicals: chemicalsReducer, bioEntity: bioEntityReducer, drawer: drawerReducer, + map: mapReducer, models: modelsReducer, }, devTools: true, diff --git a/src/services/api/utils/axiosInstance.ts b/src/services/api/utils/axiosInstance.ts index 67e1f618c49dfec3f89413170b729c9a9340fcb6..aaa17d287f1f0d3023f1d178e7ac54adf57ea9a8 100644 --- a/src/services/api/utils/axiosInstance.ts +++ b/src/services/api/utils/axiosInstance.ts @@ -5,6 +5,6 @@ export const axiosInstance = axios.create({ baseURL: BASE_API_URL, }); -export const axiosInstanceExperimentalAPI = axios.create({ +export const axiosInstanceNewAPI = axios.create({ baseURL: BASE_NEW_API_URL, }); diff --git a/src/types/map.ts b/src/types/map.ts new file mode 100644 index 0000000000000000000000000000000000000000..8dedc23f1526474dcc10d639b9e3e76312a86996 --- /dev/null +++ b/src/types/map.ts @@ -0,0 +1,7 @@ +export interface Point { + x: number; + y: number; + z?: number; +} + +export type LatLng = [number, number]; diff --git a/src/utils/mockNetworkResponse.ts b/src/utils/mockNetworkResponse.ts index 5da43a50207f60216ccb865297bbfba033b16cff..67077e0286c5b06b4c8c190f267db9170d8c1be7 100644 --- a/src/utils/mockNetworkResponse.ts +++ b/src/utils/mockNetworkResponse.ts @@ -1,13 +1,13 @@ // eslint-disable-next-line import/no-extraneous-dependencies import MockAdapter from 'axios-mock-adapter'; -import { axiosInstance, axiosInstanceExperimentalAPI } from '@/services/api/utils/axiosInstance'; +import { axiosInstance, axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance'; export const mockNetworkResponse = (): MockAdapter => { const mock = new MockAdapter(axiosInstance); return mock; }; -export const mockNetworkExperimentalAPIResponse = (): MockAdapter => { - const mock = new MockAdapter(axiosInstanceExperimentalAPI); +export const mockNetworkNewAPIResponse = (): MockAdapter => { + const mock = new MockAdapter(axiosInstanceNewAPI); return mock; }; diff --git a/src/utils/testing/getReduxWrapperWithStore.tsx b/src/utils/testing/getReduxWrapperWithStore.tsx index 292ba729cea050ae72e5e20dae4c65fc6fb72aca..05e4a4536cec509deef92d9c296584e77de2f3e3 100644 --- a/src/utils/testing/getReduxWrapperWithStore.tsx +++ b/src/utils/testing/getReduxWrapperWithStore.tsx @@ -2,6 +2,7 @@ import bioEntityReducer from '@/redux/bioEntity/bioEntity.slice'; import chemicalsReducer from '@/redux/chemicals/chemicals.slice'; import drawerReducer from '@/redux/drawer/drawer.slice'; import drugsReducer from '@/redux/drugs/drugs.slice'; +import mapReducer from '@/redux/map/map.slice'; import mirnasReducer from '@/redux/mirnas/mirnas.slice'; import modelsReducer from '@/redux/models/models.slice'; import projectReducer from '@/redux/project/project.slice'; @@ -34,6 +35,7 @@ export const getReduxWrapperWithStore: GetReduxWrapperUsingSliceReducer = ( bioEntity: bioEntityReducer, drawer: drawerReducer, models: modelsReducer, + map: mapReducer, }, preloadedState, });