diff --git a/shell-ui/package-lock.json b/shell-ui/package-lock.json index f595b08de6..a13ac2d7ed 100644 --- a/shell-ui/package-lock.json +++ b/shell-ui/package-lock.json @@ -1,5 +1,5 @@ { - "name": "solution-ui-navbar", + "name": "shell-ui", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -2128,6 +2128,20 @@ "@testing-library/dom": "^7.28.1" } }, + "@testing-library/react-hooks": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@testing-library/react-hooks/-/react-hooks-5.1.1.tgz", + "integrity": "sha512-52D2XnpelFDefnWpy/V6z2qGNj8JLIvW5DjYtelMvFXdEyWiykSaI7IXHwFy4ICoqXJDmmwHAiFRiFboub/U5g==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@types/react": ">=16.9.0", + "@types/react-dom": ">=16.9.0", + "@types/react-test-renderer": ">=16.9.0", + "filter-console": "^0.1.1", + "react-error-boundary": "^3.1.0" + } + }, "@testing-library/user-event": { "version": "13.0.10", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.0.10.tgz", @@ -2387,6 +2401,24 @@ } } }, + "@types/react-dom": { + "version": "17.0.3", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.3.tgz", + "integrity": "sha512-4NnJbCeWE+8YBzupn/YrJxZ8VnjcJq5iR1laqQ1vkpQgBiA7bwk0Rp24fxsdNinzJY2U+HHS4dJJDPdoMjdJ7w==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, + "@types/react-test-renderer": { + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-17.0.1.tgz", + "integrity": "sha512-3Fi2O6Zzq/f3QR9dRnlnHso9bMl7weKCviFmfF6B4LS1Uat6Hkm15k0ZAQuDz+UBq6B3+g+NM6IT2nr5QgPzCw==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/scheduler": { "version": "0.16.1", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.1.tgz", @@ -5176,6 +5208,12 @@ "to-regex-range": "^2.1.0" } }, + "filter-console": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/filter-console/-/filter-console-0.1.1.tgz", + "integrity": "sha512-zrXoV1Uaz52DqPs+qEwNJWJFAWZpYJ47UNmpN9q4j+/EYsz85uV0DC9k8tRND5kYmoVzL0W+Y75q4Rg8sRJCdg==", + "dev": true + }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -9848,6 +9886,15 @@ "scheduler": "^0.20.1" } }, + "react-error-boundary": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-3.1.1.tgz", + "integrity": "sha512-W3xCd9zXnanqrTUeViceufD3mIW8Ut29BUD+S2f0eO2XCOU8b6UrJfY46RDGe5lxCJzfe4j0yvIfh0RbTZhKJw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5" + } + }, "react-input-autosize": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/react-input-autosize/-/react-input-autosize-3.0.0.tgz", @@ -9906,6 +9953,46 @@ "react-transition-group": "^4.3.0" } }, + "react-shallow-renderer": { + "version": "16.14.1", + "resolved": "https://registry.npmjs.org/react-shallow-renderer/-/react-shallow-renderer-16.14.1.tgz", + "integrity": "sha512-rkIMcQi01/+kxiTE9D3fdS959U1g7gs+/rborw++42m1O9FAQiNI/UNRZExVUoAOprn4umcXf+pFRou8i4zuBg==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "react-is": "^16.12.0 || ^17.0.0" + } + }, + "react-test-renderer": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-17.0.2.tgz", + "integrity": "sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==", + "dev": true, + "requires": { + "object-assign": "^4.1.1", + "react-is": "^17.0.2", + "react-shallow-renderer": "^16.13.1", + "scheduler": "^0.20.2" + }, + "dependencies": { + "react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true + }, + "scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + } + } + }, "react-to-webcomponent": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/react-to-webcomponent/-/react-to-webcomponent-1.5.1.tgz", @@ -13049,12 +13136,6 @@ "iconv-lite": "0.4.24" } }, - "whatwg-fetch": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.1.tgz", - "integrity": "sha512-IEmN/ZfmMw6G1hgZpVd0LuZXOQDisrMOZrzYd5x3RAK4bMPlJohKUZWZ9t/QsTvH0dV9TbPDcc2OSuIDcihnHA==", - "dev": true - }, "whatwg-mimetype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", diff --git a/shell-ui/package.json b/shell-ui/package.json index a132f548f2..5934e0a60a 100644 --- a/shell-ui/package.json +++ b/shell-ui/package.json @@ -4,7 +4,8 @@ "main": "index.js", "scripts": { "test": "jest", - "start": "webpack serve --config webpack.config.dev.js", + "start:navbar": "webpack serve --config webpack.config.dev.js --env=entry=navbar", + "start:alerts": "webpack serve --config webpack.config.dev.js --env=entry=alerts", "build": "webpack --config webpack.config.prd.js" }, "devDependencies": { @@ -17,6 +18,7 @@ "@mdx-js/loader": "^1.6.22", "@testing-library/jest-dom": "^5.11.9", "@testing-library/react": "^11.2.5", + "@testing-library/react-hooks": "^5.1.1", "@testing-library/user-event": "^13.0.10", "babel-jest": "^26.6.3", "babel-loader": "^8.2.2", @@ -26,12 +28,13 @@ "jest": "^26.6.3", "jest-localstorage-mock": "^2.4.8", "msw": "^0.26.2", + "node-fetch": "^2.6.1", "prop-types": "^15.7.2", + "react-test-renderer": "^17.0.2", "style-loader": "^2.0.0", "webpack": "^5.17.0", "webpack-cli": "^4.4.0", - "webpack-dev-server": "^3.11.2", - "whatwg-fetch": "^3.6.1" + "webpack-dev-server": "^3.11.2" }, "dependencies": { "@scality/core-ui": "github:scality/core-ui.git#v0.13.0", diff --git a/shell-ui/src/navbar/setupTests.js b/shell-ui/src/setupTests.js similarity index 64% rename from shell-ui/src/navbar/setupTests.js rename to shell-ui/src/setupTests.js index 38be5ebd12..4c224d9ade 100644 --- a/shell-ui/src/navbar/setupTests.js +++ b/shell-ui/src/setupTests.js @@ -1,4 +1,4 @@ -import 'whatwg-fetch'; +import fetch from 'node-fetch'; import 'regenerator-runtime/runtime'; import '@testing-library/jest-dom/extend-expect'; import 'jest-localstorage-mock'; @@ -9,3 +9,8 @@ window.crypto = { return nodeCrypto.randomFillSync(buffer); }, }; + +window.fetch = (url, ...rest) => fetch( + /^https?:/.test(url) ? url : new URL(url, 'http://localhost'), + ...rest +);