From e08238e9b388f0bf7593543f1f2d68b67809b26a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:26:06 -0700 Subject: [PATCH 1/9] chore(deps): bump @mui/x-data-grid from 7.11.0 to 7.15.0 (#2237) Bumps [@mui/x-data-grid](https://github.com/mui/mui-x/tree/HEAD/packages/x-data-grid) from 7.11.0 to 7.15.0. - [Release notes](https://github.com/mui/mui-x/releases) - [Changelog](https://github.com/mui/mui-x/blob/master/CHANGELOG.md) - [Commits](https://github.com/mui/mui-x/commits/v7.15.0/packages/x-data-grid) --- updated-dependencies: - dependency-name: "@mui/x-data-grid" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 77 ++++++++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5460740ca3..2b85f6cd78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@mui/private-theming": "^5.15.12", "@mui/system": "^5.14.12", "@mui/x-charts": "^7.8.0", - "@mui/x-data-grid": "^7.11.0", + "@mui/x-data-grid": "^7.15.0", "@mui/x-date-pickers": "^7.11.1", "@pdfme/generator": "^1.2.6", "bootstrap": "^5.3.3", @@ -2290,9 +2290,9 @@ "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" }, "node_modules/@babel/runtime": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", - "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -4527,14 +4527,13 @@ } }, "node_modules/@mui/x-data-grid": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-7.11.0.tgz", - "integrity": "sha512-dXaIw3Noxc4d6xenS7J+zMPORG9ptkTW7B81P6QFovILSEuI/qebQhijy/IkqRvcCsuZYLL3nA89bp+EDI503Q==", - "dependencies": { - "@babel/runtime": "^7.24.8", - "@mui/system": "^5.16.2", - "@mui/utils": "^5.16.2", - "@mui/x-internals": "7.11.0", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-7.15.0.tgz", + "integrity": "sha512-S7FLp+SUz/fo+JAQcM4npnL70tGnL4qcYYMkjK4tPkPLrTnBWlm47D5OoGNzpPO1CnOAryFR5h0rdwbeHZmAWg==", + "dependencies": { + "@babel/runtime": "^7.25.4", + "@mui/utils": "^5.16.6", + "@mui/x-internals": "7.15.0", "clsx": "^2.1.1", "prop-types": "^15.8.1", "reselect": "^4.1.8" @@ -4547,9 +4546,20 @@ "url": "https://opencollective.com/mui-org" }, "peerDependencies": { - "@mui/material": "^5.15.14", + "@emotion/react": "^11.9.0", + "@emotion/styled": "^11.8.1", + "@mui/material": "^5.15.14 || ^6.0.0", + "@mui/system": "^5.15.14 || ^6.0.0", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + } } }, "node_modules/@mui/x-data-grid/node_modules/clsx": { @@ -4633,12 +4643,12 @@ } }, "node_modules/@mui/x-internals": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-7.11.0.tgz", - "integrity": "sha512-GqCYylKiB4cLH9tK4JweJlT2JvPjnpXjS3TEIqtHB4BcSsezhdRrMGzHOO5zCJqkasqTirJh2t6X16Qw1llr4Q==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-7.15.0.tgz", + "integrity": "sha512-Q/IZvZhHpe64Ost1mRbdp6ML8KQQBprwwgzqo6pZbrCaWMPB2gk2jcUwdCwnLsc+gutaEPVhZ8N7it8VZcHtbg==", "dependencies": { - "@babel/runtime": "^7.24.8", - "@mui/utils": "^5.16.2" + "@babel/runtime": "^7.25.4", + "@mui/utils": "^5.16.6" }, "engines": { "node": ">=14.0.0" @@ -26755,9 +26765,9 @@ "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" }, "@babel/runtime": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", - "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "requires": { "regenerator-runtime": "^0.14.0" }, @@ -28114,14 +28124,13 @@ } }, "@mui/x-data-grid": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-7.11.0.tgz", - "integrity": "sha512-dXaIw3Noxc4d6xenS7J+zMPORG9ptkTW7B81P6QFovILSEuI/qebQhijy/IkqRvcCsuZYLL3nA89bp+EDI503Q==", - "requires": { - "@babel/runtime": "^7.24.8", - "@mui/system": "^5.16.2", - "@mui/utils": "^5.16.2", - "@mui/x-internals": "7.11.0", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-7.15.0.tgz", + "integrity": "sha512-S7FLp+SUz/fo+JAQcM4npnL70tGnL4qcYYMkjK4tPkPLrTnBWlm47D5OoGNzpPO1CnOAryFR5h0rdwbeHZmAWg==", + "requires": { + "@babel/runtime": "^7.25.4", + "@mui/utils": "^5.16.6", + "@mui/x-internals": "7.15.0", "clsx": "^2.1.1", "prop-types": "^15.8.1", "reselect": "^4.1.8" @@ -28156,12 +28165,12 @@ } }, "@mui/x-internals": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-7.11.0.tgz", - "integrity": "sha512-GqCYylKiB4cLH9tK4JweJlT2JvPjnpXjS3TEIqtHB4BcSsezhdRrMGzHOO5zCJqkasqTirJh2t6X16Qw1llr4Q==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-7.15.0.tgz", + "integrity": "sha512-Q/IZvZhHpe64Ost1mRbdp6ML8KQQBprwwgzqo6pZbrCaWMPB2gk2jcUwdCwnLsc+gutaEPVhZ8N7it8VZcHtbg==", "requires": { - "@babel/runtime": "^7.24.8", - "@mui/utils": "^5.16.2" + "@babel/runtime": "^7.25.4", + "@mui/utils": "^5.16.6" } }, "@nicolo-ribaudo/eslint-scope-5-internals": { diff --git a/package.json b/package.json index f9d29778a5..de4c7304b6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@mui/private-theming": "^5.15.12", "@mui/system": "^5.14.12", "@mui/x-charts": "^7.8.0", - "@mui/x-data-grid": "^7.11.0", + "@mui/x-data-grid": "^7.15.0", "@mui/x-date-pickers": "^7.11.1", "@pdfme/generator": "^1.2.6", "bootstrap": "^5.3.3", From efd84c976f7957d85453c65a6bf2e69d13cb61e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:35:55 -0700 Subject: [PATCH 2/9] chore(deps): bump @testing-library/jest-dom from 6.4.8 to 6.5.0 (#2240) Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 6.4.8 to 6.5.0. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](https://github.com/testing-library/jest-dom/compare/v6.4.8...v6.5.0) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 17 +++++++---------- package.json | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b85f6cd78..3439d4cbbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", - "@testing-library/jest-dom": "^6.4.2", + "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/inquirer": "^9.0.7", @@ -5703,14 +5703,12 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.4.8", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.8.tgz", - "integrity": "sha512-JD0G+Zc38f5MBHA4NgxQMR5XtO5Jx9g86jqturNTt2WUfRmLDIY7iKkWHDCCTiDuFMre6nxAD5wHw9W5kI4rGw==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", + "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", "dev": true, - "license": "MIT", "dependencies": { "@adobe/css-tools": "^4.4.0", - "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", @@ -28843,13 +28841,12 @@ } }, "@testing-library/jest-dom": { - "version": "6.4.8", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.8.tgz", - "integrity": "sha512-JD0G+Zc38f5MBHA4NgxQMR5XtO5Jx9g86jqturNTt2WUfRmLDIY7iKkWHDCCTiDuFMre6nxAD5wHw9W5kI4rGw==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", + "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", "dev": true, "requires": { "@adobe/css-tools": "^4.4.0", - "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", diff --git a/package.json b/package.json index de4c7304b6..7096d7ca06 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", - "@testing-library/jest-dom": "^6.4.2", + "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/inquirer": "^9.0.7", From 0cb4988f43da7e02933f37098a3d74f57288cf52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:36:42 -0700 Subject: [PATCH 3/9] chore(deps): bump @mui/icons-material from 5.16.1 to 5.16.7 (#2239) Bumps [@mui/icons-material](https://github.com/mui/material-ui/tree/HEAD/packages/mui-icons-material) from 5.16.1 to 5.16.7. - [Release notes](https://github.com/mui/material-ui/releases) - [Changelog](https://github.com/mui/material-ui/blob/v5.16.7/CHANGELOG.md) - [Commits](https://github.com/mui/material-ui/commits/v5.16.7/packages/mui-icons-material) --- updated-dependencies: - dependency-name: "@mui/icons-material" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3439d4cbbe..ab7bc8b7af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@dicebear/core": "^8.0.2", "@emotion/react": "^11.13.0", "@emotion/styled": "^11.13.0", - "@mui/icons-material": "^5.16.1", + "@mui/icons-material": "^5.16.7", "@mui/material": "^5.16.7", "@mui/private-theming": "^5.15.12", "@mui/system": "^5.14.12", @@ -4250,9 +4250,9 @@ } }, "node_modules/@mui/icons-material": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.16.1.tgz", - "integrity": "sha512-ogQPweYba4+5XZykilwxn2/oS78uwoQ0BVBpOhhCJo0ooZsqTTsalhzP2qD/RdGqMQ8xyXPz1sYM2djTruVVVA==", + "version": "5.16.7", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.16.7.tgz", + "integrity": "sha512-UrGwDJCXEszbDI7yV047BYU5A28eGJ79keTCP4cc74WyncuVrnurlmIRxaHL8YK+LI1Kzq+/JM52IAkNnv4u+Q==", "dependencies": { "@babel/runtime": "^7.23.9" }, @@ -27992,9 +27992,9 @@ "integrity": "sha512-RtsCt4Geed2/v74sbihWzzRs+HsIQCfclHeORh5Ynu2fS4icIKozcSubwuG7vtzq2uW3fOR1zITSP84TNt2GoQ==" }, "@mui/icons-material": { - "version": "5.16.1", - "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.16.1.tgz", - "integrity": "sha512-ogQPweYba4+5XZykilwxn2/oS78uwoQ0BVBpOhhCJo0ooZsqTTsalhzP2qD/RdGqMQ8xyXPz1sYM2djTruVVVA==", + "version": "5.16.7", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.16.7.tgz", + "integrity": "sha512-UrGwDJCXEszbDI7yV047BYU5A28eGJ79keTCP4cc74WyncuVrnurlmIRxaHL8YK+LI1Kzq+/JM52IAkNnv4u+Q==", "requires": { "@babel/runtime": "^7.23.9" } diff --git a/package.json b/package.json index 7096d7ca06..183133b25e 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@dicebear/core": "^8.0.2", "@emotion/react": "^11.13.0", "@emotion/styled": "^11.13.0", - "@mui/icons-material": "^5.16.1", + "@mui/icons-material": "^5.16.7", "@mui/material": "^5.16.7", "@mui/private-theming": "^5.15.12", "@mui/system": "^5.14.12", From b9c77749d605d121d0b138477d2c9c0c2e578b8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:07:39 -0700 Subject: [PATCH 4/9] chore(deps): bump @types/node from 20.12.12 to 22.5.2 (#2238) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.12.12 to 22.5.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 30 +++++++++++++++--------------- package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab7bc8b7af..9915dc3e59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69,7 +69,7 @@ "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", - "@types/node": "^20.12.12", + "@types/node": "^22.5.2", "@types/node-fetch": "^2.6.10", "@types/react": "^17.0.14", "@types/react-beautiful-dnd": "^13.1.8", @@ -6020,11 +6020,11 @@ "peer": true }, "node_modules/@types/node": { - "version": "20.12.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", - "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "version": "22.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", + "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/@types/node-fetch": { @@ -24076,9 +24076,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", @@ -29134,11 +29134,11 @@ "peer": true }, "@types/node": { - "version": "20.12.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", - "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "version": "22.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", + "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", "requires": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "@types/node-fetch": { @@ -42323,9 +42323,9 @@ } }, "undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", diff --git a/package.json b/package.json index 183133b25e..9a8931bdc8 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", - "@types/node": "^20.12.12", + "@types/node": "^22.5.2", "@types/node-fetch": "^2.6.10", "@types/react": "^17.0.14", "@types/react-beautiful-dnd": "^13.1.8", From 7bfb5dc68e3c58fe929dab6b9d4611b701446b78 Mon Sep 17 00:00:00 2001 From: Peter Harrison <16875803+palisadoes@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:09:13 -0700 Subject: [PATCH 5/9] Update .node-version --- .node-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.node-version b/.node-version index 790e1105f2..751f4c9f38 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -v20.10.0 +v22.7.0 From 7e80b17f15b04ca96140e21100955785967b1348 Mon Sep 17 00:00:00 2001 From: Peter Harrison <16875803+palisadoes@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:10:57 -0700 Subject: [PATCH 6/9] Update pull-request.yml --- .github/workflows/pull-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 32f9cee912..3846371ed5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,7 +30,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '22.x' - name: Install Dependencies run: npm install @@ -176,7 +176,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '22.x' - name: Install Dependencies run: npm install @@ -221,7 +221,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '22.x' - name: resolve dependency run: npm install -g @graphql-inspector/cli From fc346d25d21f2d3b9c6d21bd364ba2dd86fafd0f Mon Sep 17 00:00:00 2001 From: Peter Harrison <16875803+palisadoes@users.noreply.github.com> Date: Mon, 2 Sep 2024 12:11:33 -0700 Subject: [PATCH 7/9] Update push.yml --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index bc86d1b7d8..67e49556b4 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20.x] + node-version: [22.x] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 9869bdee3cfa83ca58692be11a9aed033731cee8 Mon Sep 17 00:00:00 2001 From: Anshul Kahar <60067250+AnshulKahar2729@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:24:05 +0530 Subject: [PATCH 8/9] Fix : #2112 by including client side validation for donation amount. (#2211) * fix the donate input bug * add the tests * fix the test * test clear of donate * prettier check * added translation for other languages * added the additional conditions as per review. * testcases passed * husky file unchanged * Revert * Final acc to discussion * fix the testcase --------- Co-authored-by: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> --- public/locales/en/translation.json | 5 +- public/locales/fr/translation.json | 5 +- public/locales/hi/translation.json | 5 +- public/locales/sp/translation.json | 5 +- public/locales/zh/translation.json | 5 +- src/screens/UserPortal/Donate/Donate.test.tsx | 107 ++++++++++++++++++ src/screens/UserPortal/Donate/Donate.tsx | 27 ++++- 7 files changed, 153 insertions(+), 6 deletions(-) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 3b7b875821..112eae5892 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -854,7 +854,10 @@ "yourPreviousDonations": "Your Previous Donations", "donate": "Donate", "nothingToShow": "Nothing to show here.", - "success": "Donation Successful" + "success": "Donation Successful", + "invalidAmount": "Please enter a numerical value for the donation amount.", + "donationAmountDescription": "Please enter the numerical value for the donation amount.", + "donationOutOfRange": "Donation amount must be between {{min}} and {{max}}." }, "userEvents": { "title": "Events", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index ac72be3def..1498607e51 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -854,7 +854,10 @@ "yourPreviousDonations": "Vos dons précédents", "donate": "Faire un don", "nothingToShow": "Rien à montrer ici.", - "success": "Don réussi" + "success": "Don réussi", + "invalidAmount": "Veuillez saisir une valeur numérique pour le montant du don.", + "donationAmountDescription": "Veuillez saisir la valeur numérique du montant du don.", + "donationOutOfRange": "Le montant du don doit être compris entre {{min}} et {{max}}." }, "userEvents": { "title": "Événements", diff --git a/public/locales/hi/translation.json b/public/locales/hi/translation.json index 0f74a5978e..0de147b21a 100644 --- a/public/locales/hi/translation.json +++ b/public/locales/hi/translation.json @@ -854,7 +854,10 @@ "yourPreviousDonations": "आपका पिछला दान", "donate": "दान करें", "nothingToShow": "यहां दिखाने के लिए कुछ भी नहीं है.", - "success": "दान सफल" + "success": "दान सफल", + "invalidAmount": "कृपया दान राशि के लिए संख्यात्मक मान दर्ज करें.", + "donationAmountDescription": "कृपया दान राशि के लिए संख्यात्मक मान दर्ज करें.", + "donationOutOfRange": "दान राशि {{min}} और {{max}} के बीच होनी चाहिए." }, "userEvents": { "title": "ईवेंट", diff --git a/public/locales/sp/translation.json b/public/locales/sp/translation.json index 5d32d79368..d68701c261 100644 --- a/public/locales/sp/translation.json +++ b/public/locales/sp/translation.json @@ -1063,7 +1063,10 @@ "yourPreviousDonations": "Tus donaciones anteriores", "donate": "Donar", "nothingToShow": "Nada que mostrar aquí.", - "success": "Donación exitosa" + "success": "Donación exitosa", + "invalidAmount": "Ingrese un valor numérico para el monto de la donación.", + "donationAmountDescription": "Ingrese el valor numérico del monto de la donación.", + "donationOutOfRange": "El monto de la donación debe estar entre {{min}} y {{max}}." }, "userEvents": { "title": "Eventos", diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index 56d93b13da..074c03dc0e 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -854,7 +854,10 @@ "yourPreviousDonations": "您之前的捐款", "donate": "捐", "nothingToShow": "这里没有什么可显示的。", - "success": "捐赠成功" + "success": "捐赠成功", + "invalidAmount": "请输入捐赠金额的数值。", + "donationAmountDescription": "请输入捐款金额的数值。", + "donationOutOfRange": "捐款金额必须在 {{min}} 和 {{max}} 之间。" }, "userEvents": { "title": "活动", diff --git a/src/screens/UserPortal/Donate/Donate.test.tsx b/src/screens/UserPortal/Donate/Donate.test.tsx index fc30ba7503..63083bd297 100644 --- a/src/screens/UserPortal/Donate/Donate.test.tsx +++ b/src/screens/UserPortal/Donate/Donate.test.tsx @@ -16,6 +16,7 @@ import Donate from './Donate'; import userEvent from '@testing-library/user-event'; import useLocalStorage from 'utils/useLocalstorage'; import { DONATE_TO_ORGANIZATION } from 'GraphQl/Mutations/mutations'; +import { toast } from 'react-toastify'; const MOCKS = [ { @@ -136,6 +137,13 @@ jest.mock('react-router-dom', () => ({ useParams: () => ({ orgId: '' }), })); +jest.mock('react-toastify', () => ({ + toast: { + error: jest.fn(), + success: jest.fn(), + }, +})); + describe('Testing Donate Screen [User Portal]', () => { Object.defineProperty(window, 'matchMedia', { writable: true, @@ -280,4 +288,103 @@ describe('Testing Donate Screen [User Portal]', () => { userEvent.click(screen.getByTestId('donateBtn')); await wait(); }); + + test('displays error toast for donation amount below minimum', async () => { + render( + + + + + + + + + , + ); + + await wait(); + + userEvent.type(screen.getByTestId('donationAmount'), '0.5'); + userEvent.click(screen.getByTestId('donateBtn')); + + await wait(); + + expect(toast.error).toHaveBeenCalledWith( + 'Donation amount must be between 1 and 10000000.', + ); + }); + + test('displays error toast for donation amount above maximum', async () => { + render( + + + + + + + + + , + ); + + await wait(); + + userEvent.type(screen.getByTestId('donationAmount'), '10000001'); + userEvent.click(screen.getByTestId('donateBtn')); + + await wait(); + + expect(toast.error).toHaveBeenCalledWith( + 'Donation amount must be between 1 and 10000000.', + ); + }); + + test('displays error toast for empty donation amount', async () => { + render( + + + + + + + + + , + ); + + await wait(); + + userEvent.click(screen.getByTestId('donateBtn')); + + await wait(); + + expect(toast.error).toHaveBeenCalledWith( + 'Please enter a numerical value for the donation amount.', + ); + }); + + test('displays error toast for invalid (non-numeric) donation amount', async () => { + render( + + + + + + + + + , + ); + + await wait(); + + userEvent.type(screen.getByTestId('donationAmount'), 'abc'); + userEvent.click(screen.getByTestId('donateBtn')); + + await wait(); + + expect(toast.error).toHaveBeenCalledWith( + 'Please enter a numerical value for the donation amount.', + ); + }); }); diff --git a/src/screens/UserPortal/Donate/Donate.tsx b/src/screens/UserPortal/Donate/Donate.tsx index 4a87bd2490..84ad62a06a 100644 --- a/src/screens/UserPortal/Donate/Donate.tsx +++ b/src/screens/UserPortal/Donate/Donate.tsx @@ -128,6 +128,28 @@ export default function donate(): JSX.Element { }, [donationData]); const donateToOrg = (): void => { + // check if the amount is non empty and is a number + if (amount === '' || Number.isNaN(Number(amount))) { + toast.error(t(`invalidAmount`)); + return; + } + + // check if the amount is non negative and within the range + const minDonation = 1; + const maxDonation = 10000000; + if ( + Number(amount) <= 0 || + Number(amount) < minDonation || + Number(amount) > maxDonation + ) { + toast.error( + t(`donationOutOfRange`, { min: minDonation, max: maxDonation }), + ); + return; + } + + const formattedAmount = Number(amount.trim()); + try { donate({ variables: { @@ -135,7 +157,7 @@ export default function donate(): JSX.Element { createDonationOrgId2: organizationId, payPalId: 'paypalId', nameOfUser: userName, - amount: Number(amount), + amount: formattedAmount, nameOfOrg: organizationDetails.name, }, }); @@ -216,6 +238,9 @@ export default function donate(): JSX.Element { /> + + {t('donationAmountDescription')} +
diff --git a/src/components/EventManagement/EventActionItems/EventActionItems.test.tsx b/src/components/EventManagement/EventActionItems/EventActionItems.test.tsx index 9da0b5247a..3d1e5fa7bc 100644 --- a/src/components/EventManagement/EventActionItems/EventActionItems.test.tsx +++ b/src/components/EventManagement/EventActionItems/EventActionItems.test.tsx @@ -1,9 +1,8 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { - act, fireEvent, render, screen, diff --git a/src/components/EventManagement/EventActionItems/EventActionItems.tsx b/src/components/EventManagement/EventActionItems/EventActionItems.tsx index cbe878fa07..0f9d723adc 100644 --- a/src/components/EventManagement/EventActionItems/EventActionItems.tsx +++ b/src/components/EventManagement/EventActionItems/EventActionItems.tsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; import styles from './EventActionItems.module.css'; import { DataGrid } from '@mui/x-data-grid'; -import type { GridCellParams } from '@mui/x-data-grid'; +// import type { GridCellParams } from '@mui/x-data-grid'; import { Stack } from '@mui/material'; import Modal from 'react-bootstrap/Modal'; import { @@ -156,7 +156,7 @@ function eventActionItems(props: { eventId: string }): JSX.Element { setDueDate(new Date()); actionItemsRefetch(); hideCreateModal(); - toast.success(t('successfulCreation')); + toast.success(t('successfulCreation') as string); } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); @@ -188,7 +188,7 @@ function eventActionItems(props: { eventId: string }): JSX.Element { actionItemsRefetch(); hideUpdateModal(); hideActionItemStatusModal(); - toast.success(t('successfulUpdation')); + toast.success(t('successfulUpdation') as string); } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); @@ -206,7 +206,7 @@ function eventActionItems(props: { eventId: string }): JSX.Element { actionItemsRefetch(); toggleDeleteModal(); hidePreviewModal(); - toast.success(t('successfulDeletion')); + toast.success(t('successfulDeletion') as string); } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); diff --git a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.test.tsx b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.test.tsx index b1b3ed6094..3bce7ad11e 100644 --- a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.test.tsx +++ b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.test.tsx @@ -14,7 +14,7 @@ import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import i18n from 'utils/i18nForTest'; -import { toast } from 'react-toastify'; +// import { toast } from 'react-toastify'; import { LocalizationProvider } from '@mui/x-date-pickers'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; @@ -26,7 +26,7 @@ import EventAgendaItems from './EventAgendaItems'; import { MOCKS, MOCKS_ERROR_QUERY, - MOCKS_ERROR_MUTATION, + // MOCKS_ERROR_MUTATION, } from './EventAgendaItemsMocks'; jest.mock('react-toastify', () => ({ @@ -41,6 +41,15 @@ jest.mock('react-router-dom', () => ({ useParams: () => ({ eventId: '123' }), })); +//temporarily fixes react-beautiful-dnd droppable method's depreciation error +//needs to be fixed in React 19 +jest.spyOn(console, 'error').mockImplementation((message) => { + if (message.includes('Support for defaultProps will be removed')) { + return; + } + console.error(message); +}); + async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { @@ -51,7 +60,7 @@ async function wait(ms = 100): Promise { const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink(MOCKS_ERROR_QUERY, true); -const link3 = new StaticMockLink(MOCKS_ERROR_MUTATION, true); +// const link3 = new StaticMockLink(MOCKS_ERROR_MUTATION, true); const translations = JSON.parse( JSON.stringify(i18n.getDataByLanguage('en')?.translation.agendaItems), diff --git a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.tsx b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.tsx index 73a074ba9f..b49ade4626 100644 --- a/src/components/EventManagement/EventAgendaItems/EventAgendaItems.tsx +++ b/src/components/EventManagement/EventAgendaItems/EventAgendaItems.tsx @@ -126,7 +126,7 @@ function EventAgendaItems(props: { eventId: string }): JSX.Element { }); hideCreateModal(); refetchAgendaItem(); - toast.success(t('agendaItemCreated')); + toast.success(t('agendaItemCreated') as string); } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); @@ -153,20 +153,20 @@ function EventAgendaItems(props: { eventId: string }): JSX.Element { // Show error message if there is an error loading data if (agendaItemError || agendaCategoryError) { + const errorMessage = + agendaCategoryError?.message || + (agendaItemError as Error)?.message || + 'Unknown error'; + return (
Error occurred while loading{' '} - {agendaCategoryError - ? 'Agenda Categories' - : agendaItemError && 'Agenda Items'} - Data + {agendaCategoryError ? 'Agenda Categories' : 'Agenda Items'} Data
- {agendaCategoryError - ? agendaCategoryError.message - : agendaItemError && (agendaItemError as Error).message} + {errorMessage}
diff --git a/src/components/EventRegistrantsModal/EventRegistrantsModal.tsx b/src/components/EventRegistrantsModal/EventRegistrantsModal.tsx index 85fa1ca426..bd2adc8a2c 100644 --- a/src/components/EventRegistrantsModal/EventRegistrantsModal.tsx +++ b/src/components/EventRegistrantsModal/EventRegistrantsModal.tsx @@ -81,11 +81,13 @@ export const EventRegistrantsModal = (props: ModalPropType): JSX.Element => { }, }) .then(() => { - toast.success(tCommon('addedSuccessfully', { item: 'Attendee' })); + toast.success( + tCommon('addedSuccessfully', { item: 'Attendee' }) as string, + ); attendeesRefetch(); // Refresh the list of attendees }) .catch((err) => { - toast.error(t('errorAddingAttendee')); + toast.error(t('errorAddingAttendee') as string); toast.error(err.message); }); }; @@ -100,11 +102,13 @@ export const EventRegistrantsModal = (props: ModalPropType): JSX.Element => { }, }) .then(() => { - toast.success(tCommon('removedSuccessfully', { item: 'Attendee' })); + toast.success( + tCommon('removedSuccessfully', { item: 'Attendee' }) as string, + ); attendeesRefetch(); // Refresh the list of attendees }) .catch((err) => { - toast.error(t('errorRemovingAttendee')); + toast.error(t('errorRemovingAttendee') as string); toast.error(err.message); }); }; diff --git a/src/components/LeftDrawer/LeftDrawer.test.tsx b/src/components/LeftDrawer/LeftDrawer.test.tsx index 3873d66dc2..6701d2d4bb 100644 --- a/src/components/LeftDrawer/LeftDrawer.test.tsx +++ b/src/components/LeftDrawer/LeftDrawer.test.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { act } from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; @@ -63,102 +63,131 @@ afterEach(() => { }); describe('Testing Left Drawer component for SUPERADMIN', () => { - test('Component should be rendered properly', () => { - setItem('UserImage', ''); - setItem('UserImage', ''); - setItem('SuperAdmin', true); - setItem('FirstName', 'John'); - setItem('LastName', 'Doe'); + test('Component should be rendered properly', async () => { setItem('UserImage', ''); setItem('SuperAdmin', true); setItem('FirstName', 'John'); setItem('LastName', 'Doe'); - render( - - - - - - - , - ); + + await act(async () => { + render( + + + + + + + , + ); + }); expect(screen.getByText('My Organizations')).toBeInTheDocument(); expect(screen.getByText('Users')).toBeInTheDocument(); expect(screen.getByText('Community Profile')).toBeInTheDocument(); - expect(screen.getByText('Community Profile')).toBeInTheDocument(); expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument(); const orgsBtn = screen.getByTestId(/orgsBtn/i); const rolesBtn = screen.getByTestId(/rolesBtn/i); const communityProfileBtn = screen.getByTestId(/communityProfileBtn/i); - orgsBtn.click(); + await act(async () => { + orgsBtn.click(); + }); + expect( orgsBtn.className.includes('text-white btn btn-success'), ).toBeTruthy(); expect(rolesBtn.className.includes('text-secondary btn')).toBeTruthy(); - expect(rolesBtn.className.includes('text-secondary btn')).toBeTruthy(); expect( communityProfileBtn.className.includes('text-secondary btn'), ).toBeTruthy(); - // Send to roles screen - userEvent.click(rolesBtn); + await act(async () => { + userEvent.click(rolesBtn); + }); + expect(global.window.location.pathname).toContain('/users'); - userEvent.click(communityProfileBtn); + + await act(async () => { + userEvent.click(communityProfileBtn); + }); }); - test('Testing Drawer when hideDrawer is null', () => { + test('Testing Drawer when hideDrawer is null', async () => { const tempProps: InterfaceLeftDrawerProps = { ...props, hideDrawer: false, }; - render( - - - - - - - , - ); + await act(async () => { + render( + + + + + + + , + ); + }); }); - test('Testing Drawer when hideDrawer is false', () => { + + test('Testing Drawer when hideDrawer is false', async () => { const tempProps: InterfaceLeftDrawerProps = { ...props, hideDrawer: false, }; + + await act(async () => { + render( + + + + + + + , + ); + }); }); - test('Testing Drawer when the screen size is less than or equal to 820px', () => { + + test('Testing Drawer when the screen size is less than or equal to 820px', async () => { const tempProps: InterfaceLeftDrawerProps = { ...props, hideDrawer: false, }; resizeWindow(800); - render( - - - - - - - , - ); + + await act(async () => { + render( + + + + + + + , + ); + }); + expect(screen.getByText('My Organizations')).toBeInTheDocument(); expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument(); const orgsBtn = screen.getByTestId(/orgsBtn/i); - orgsBtn.click(); + await act(async () => { + orgsBtn.click(); + }); + expect( orgsBtn.className.includes('text-white btn btn-success'), ).toBeTruthy(); }); +}); - describe('Testing Left Drawer component for ADMIN', () => { - test('Components should be rendered properly', () => { +describe('Testing Left Drawer component for ADMIN', () => { + test('Components should be rendered properly', async () => { + await act(async () => { render( @@ -168,24 +197,30 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { , ); + }); + + expect(screen.getByText('My Organizations')).toBeInTheDocument(); + expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument(); - expect(screen.getByText('My Organizations')).toBeInTheDocument(); - expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument(); + expect(screen.getAllByText(/admin/i)).toHaveLength(1); - expect(screen.getAllByText(/admin/i)).toHaveLength(1); - expect(screen.getAllByText(/admin/i)).toHaveLength(1); + const orgsBtn = screen.getByTestId(/orgsBtn/i); - const orgsBtn = screen.getByTestId(/orgsBtn/i); + await act(async () => { orgsBtn.click(); - expect( - orgsBtn.className.includes('text-white btn btn-success'), - ).toBeTruthy(); + }); - // These screens arent meant for admins so they should not be present - expect(screen.queryByTestId(/rolesBtn/i)).toBeNull(); + expect( + orgsBtn.className.includes('text-white btn btn-success'), + ).toBeTruthy(); + // These screens aren't meant for admins, so they should not be present + expect(screen.queryByTestId(/rolesBtn/i)).toBeNull(); + + await act(async () => { userEvent.click(orgsBtn); - expect(global.window.location.pathname).toContain('/orglist'); }); + + expect(global.window.location.pathname).toContain('/orglist'); }); }); diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx index 58a7168552..7dc8330c84 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { act } from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; @@ -12,7 +12,6 @@ import { Provider } from 'react-redux'; import { MockedProvider } from '@apollo/react-testing'; import { store } from 'state/store'; import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries'; -import { act } from 'react-dom/test-utils'; import { StaticMockLink } from 'utils/StaticMockLink'; import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations'; import useLocalStorage from 'utils/useLocalstorage'; diff --git a/src/components/LoginPortalToggle/LoginPortalToggle.test.tsx b/src/components/LoginPortalToggle/LoginPortalToggle.test.tsx index ac971e52ea..327e6cccea 100644 --- a/src/components/LoginPortalToggle/LoginPortalToggle.test.tsx +++ b/src/components/LoginPortalToggle/LoginPortalToggle.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render } from '@testing-library/react'; +import React, { act } from 'react'; +import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/MemberRequestCard/MemberRequestCard.test.tsx b/src/components/MemberRequestCard/MemberRequestCard.test.tsx index 121213e4e7..a38a046ea2 100644 --- a/src/components/MemberRequestCard/MemberRequestCard.test.tsx +++ b/src/components/MemberRequestCard/MemberRequestCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; @@ -16,7 +16,7 @@ const MOCKS = [ { request: { query: ACCEPT_ORGANIZATION_REQUEST_MUTATION, - variable: { id: '123' }, + variables: { id: '123' }, }, result: { data: { @@ -31,7 +31,7 @@ const MOCKS = [ { request: { query: REJECT_ORGANIZATION_REQUEST_MUTATION, - variable: { id: '234' }, + variables: { userid: '234' }, }, result: { data: { @@ -44,7 +44,9 @@ const MOCKS = [ }, }, ]; + const link = new StaticMockLink(MOCKS, true); + async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { @@ -55,7 +57,6 @@ async function wait(ms = 100): Promise { describe('Testing Member Request Card', () => { const props = { - key: '123', id: '1', memberName: 'John Doe', memberLocation: 'India', @@ -89,14 +90,13 @@ describe('Testing Member Request Card', () => { expect(screen.getByText(props.email)).toBeInTheDocument(); }); - it('Should render text elements when props value is not passed', async () => { + it('should render text elements when props value is not passed', async () => { global.confirm = (): boolean => false; render( { window.location.reload(); @@ -136,5 +135,4 @@ function memberRequestCard( ); } -export {}; -export default memberRequestCard; +export default MemberRequestCard; diff --git a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx index 72b1fdd23c..ea86fcf965 100644 --- a/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx +++ b/src/components/OrgActionItemCategories/OrgActionItemCategories.tsx @@ -83,7 +83,7 @@ const OrgActionItemCategories = (): JSX.Element => { setModalIsOpen(false); - toast.success(t('successfulCreation')); + toast.success(t('successfulCreation') as string); } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); @@ -96,7 +96,7 @@ const OrgActionItemCategories = (): JSX.Element => { const handleEdit = async (e: ChangeEvent): Promise => { e.preventDefault(); if (name === currName) { - toast.error(t('sameNameConflict')); // Show error if the name is the same + toast.error(t('sameNameConflict') as string); // Show error if the name is the same } else { try { await updateActionItemCategory({ @@ -111,7 +111,7 @@ const OrgActionItemCategories = (): JSX.Element => { refetch(); // Refetch the list of categories setModalIsOpen(false); // Close the modal - toast.success(t('successfulUpdation')); // Show success toast + toast.success(t('successfulUpdation') as string); // Show success toast } catch (error: unknown) { if (error instanceof Error) { toast.error(error.message); // Show error toast @@ -137,7 +137,9 @@ const OrgActionItemCategories = (): JSX.Element => { refetch(); // Refetch the list of categories toast.success( - disabledStatus ? t('categoryEnabled') : t('categoryDisabled'), + disabledStatus + ? (t('categoryEnabled') as string) + : (t('categoryDisabled') as string), ); // Show success toast } catch (error: unknown) { if (error instanceof Error) { diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx index 282dedb330..7baea946d2 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen, waitFor } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen, waitFor } from '@testing-library/react'; import type { RenderResult } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; diff --git a/src/components/OrgAdminListCard/OrgAdminListCard.tsx b/src/components/OrgAdminListCard/OrgAdminListCard.tsx index 418592819f..f8fc454823 100644 --- a/src/components/OrgAdminListCard/OrgAdminListCard.tsx +++ b/src/components/OrgAdminListCard/OrgAdminListCard.tsx @@ -44,7 +44,7 @@ function orgAdminListCard(props: InterfaceOrgPeopleListCardProps): JSX.Element { }, }); if (data) { - toast.success(t('adminRemoved')); + toast.success(t('adminRemoved') as string); setTimeout(() => { window.location.reload(); }, 2000); diff --git a/src/components/OrgListCard/OrgListCard.test.tsx b/src/components/OrgListCard/OrgListCard.test.tsx index 25d7f01ed1..4072265ea4 100644 --- a/src/components/OrgListCard/OrgListCard.test.tsx +++ b/src/components/OrgListCard/OrgListCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx index 57a6e0265f..7cee31107f 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx index f22abc2c01..d24773c02a 100644 --- a/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx +++ b/src/components/OrgPeopleListCard/OrgPeopleListCard.tsx @@ -56,7 +56,7 @@ function orgPeopleListCard( // If the mutation is successful, show a success message and reload the page /* istanbul ignore next */ if (data) { - toast.success(t('memberRemoved')); + toast.success(t('memberRemoved') as string); setTimeout(() => { window.location.reload(); }, 2000); diff --git a/src/components/OrgPostCard/OrgPostCard.test.tsx b/src/components/OrgPostCard/OrgPostCard.test.tsx index 863ed2822b..2c1f0fd824 100644 --- a/src/components/OrgPostCard/OrgPostCard.test.tsx +++ b/src/components/OrgPostCard/OrgPostCard.test.tsx @@ -112,7 +112,6 @@ describe('Testing Organization Post Card', () => { }); const props = { - key: '123', id: '12', postTitle: 'Event Info', postInfo: 'Time change', @@ -139,7 +138,7 @@ describe('Testing Organization Post Card', () => { const { getByAltText, getByTestId } = render( - + , ); @@ -152,7 +151,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -169,7 +168,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -188,7 +187,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -200,7 +199,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -269,7 +268,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -289,7 +288,6 @@ describe('Testing Organization Post Card', () => { }); test('Testing pin post functionality fail case', async () => { const props2 = { - key: '123', id: '', postTitle: 'Event Info', postInfo: 'Time change', @@ -301,7 +299,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -317,7 +315,7 @@ describe('Testing Organization Post Card', () => { - + , @@ -340,7 +338,6 @@ describe('Testing Organization Post Card', () => { }); test('Testing post delete functionality fail case', async () => { const props2 = { - key: '123', id: '', postTitle: 'Event Info', postInfo: 'Time change', @@ -353,7 +350,7 @@ describe('Testing Organization Post Card', () => { - + , @@ -371,7 +368,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -385,7 +382,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -398,7 +395,6 @@ describe('Testing Organization Post Card', () => { }); test('renders without "Read more" button when postInfo length is less than or equal to 43', () => { const props2 = { - key: '123', id: '12', postTitle: 'Event Info', postInfo: 'Lorem ipsum dolor sit amet', @@ -410,7 +406,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -419,7 +415,7 @@ describe('Testing Organization Post Card', () => { const link2 = new StaticMockLink(MOCKS, true); render( - + , ); userEvent.click(screen.getByAltText('image')); @@ -446,7 +442,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -480,7 +476,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -519,7 +515,7 @@ describe('Testing Organization Post Card', () => { render( - + , ); @@ -539,7 +535,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -558,7 +554,7 @@ describe('Testing Organization Post Card', () => { const { getByTestId } = render( - + , ); @@ -576,7 +572,6 @@ describe('Testing Organization Post Card', () => { }); test('for rendering when no image and no video is available', async () => { const props2 = { - key: '123', id: '', postTitle: 'Event Info', postInfo: 'Time change', @@ -589,7 +584,7 @@ describe('Testing Organization Post Card', () => { const { getByAltText } = render( - + , ); diff --git a/src/components/OrgPostCard/OrgPostCard.tsx b/src/components/OrgPostCard/OrgPostCard.tsx index be71622c7c..b7cc419d12 100644 --- a/src/components/OrgPostCard/OrgPostCard.tsx +++ b/src/components/OrgPostCard/OrgPostCard.tsx @@ -16,7 +16,7 @@ import { errorHandler } from 'utils/errorHandler'; import type { InterfacePostForm } from 'utils/interfaces'; import styles from './OrgPostCard.module.css'; interface InterfaceOrgPostCardProps { - key: string; + postID: string; id: string; postTitle: string; postInfo: string; @@ -25,9 +25,13 @@ interface InterfaceOrgPostCardProps { postVideo: string | null; pinned: boolean; } -export default function orgPostCard( +export default function OrgPostCard( props: InterfaceOrgPostCardProps, ): JSX.Element { + const { + postID, // Destructure the key prop from props + // ...rest // Spread the rest of the props + } = props; const [postformState, setPostFormState] = useState({ posttitle: '', postinfo: '', @@ -68,12 +72,13 @@ export default function orgPostCard( } }; const toggleShowEditModal = (): void => { + const { postTitle, postInfo, postPhoto, postVideo, pinned } = props; setPostFormState({ - posttitle: props.postTitle, - postinfo: props.postInfo, - postphoto: props.postPhoto, - postvideo: props.postVideo, - pinned: props.pinned, + posttitle: postTitle, + postinfo: postInfo, + postphoto: postPhoto, + postvideo: postVideo, + pinned: pinned, }); setPostPhotoUpdated(false); setPostVideoUpdated(false); @@ -128,13 +133,14 @@ export default function orgPostCard( } } function handleEditModal(): void { + const { postPhoto, postVideo } = props; setModalVisible(false); setMenuVisible(false); setShowEditModal(true); setPostFormState({ ...postformState, - postphoto: props.postPhoto, - postvideo: props.postVideo, + postphoto: postPhoto, + postvideo: postVideo, }); } function handleDeleteModal(): void { @@ -165,7 +171,7 @@ export default function orgPostCard( }, }); if (data) { - toast.success(t('postDeleted')); + toast.success(t('postDeleted') as string); toggleShowDeleteModal(); setTimeout(() => { window.location.reload(); @@ -203,7 +209,7 @@ export default function orgPostCard( }, }); if (data) { - toast.success(t('postUpdated')); + toast.success(t('postUpdated') as string); setTimeout(() => { window.location.reload(); }, 2000); @@ -216,7 +222,11 @@ export default function orgPostCard( }; return ( <> -
+
{ ...customFieldData, }, }); - toast.success(t('fieldSuccessMessage')); + toast.success(t('fieldSuccessMessage') as string); setCustomFieldData({ type: '', name: '' }); refetch(); } catch (error) { @@ -89,7 +89,7 @@ const OrgProfileFieldSettings = (): JSX.Element => { }, }); - toast.success(t('fieldRemovalSuccess')); + toast.success(t('fieldRemovalSuccess') as string); refetch(); } catch (error) { toast.error((error as Error).message); diff --git a/src/components/OrgUpdate/OrgUpdate.test.tsx b/src/components/OrgUpdate/OrgUpdate.test.tsx index 9c56a61d78..6304bb3ec9 100644 --- a/src/components/OrgUpdate/OrgUpdate.test.tsx +++ b/src/components/OrgUpdate/OrgUpdate.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; import { StaticMockLink } from 'utils/StaticMockLink'; diff --git a/src/components/OrgUpdate/OrgUpdate.tsx b/src/components/OrgUpdate/OrgUpdate.tsx index f33c758acd..6e0be28a56 100644 --- a/src/components/OrgUpdate/OrgUpdate.tsx +++ b/src/components/OrgUpdate/OrgUpdate.tsx @@ -144,7 +144,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { // istanbul ignore next if (data) { refetch({ id: orgId }); - toast.success(t('successfulUpdated')); + toast.success(t('successfulUpdated') as string); } } catch (error: unknown) { errorHandler(t, error); diff --git a/src/components/OrganizationCard/OrganizationCard.test.tsx b/src/components/OrganizationCard/OrganizationCard.test.tsx index e0095d20b2..e4abf3a1fd 100644 --- a/src/components/OrganizationCard/OrganizationCard.test.tsx +++ b/src/components/OrganizationCard/OrganizationCard.test.tsx @@ -6,7 +6,6 @@ describe('Testing the Organization Card', () => { test('should render props and text elements test for the page component', () => { const props = { id: '123', - key: '456', image: 'https://via.placeholder.com/80', firstName: 'John', lastName: 'Doe', @@ -24,7 +23,6 @@ describe('Testing the Organization Card', () => { test('Should render text elements when props value is not passed', () => { const props = { id: '123', - key: '456', image: '', firstName: 'John', lastName: 'Doe', diff --git a/src/components/OrganizationCard/OrganizationCard.tsx b/src/components/OrganizationCard/OrganizationCard.tsx index 05f8712ec5..ae513eff5d 100644 --- a/src/components/OrganizationCard/OrganizationCard.tsx +++ b/src/components/OrganizationCard/OrganizationCard.tsx @@ -12,47 +12,45 @@ interface InterfaceOrganizationCardProps { /** * Component to display an organization's card with its image and owner details. * - * @param image - URL of the organization's image. - * @param id - Unique identifier for the organization. - * @param name - Name of the organization. - * @param lastName - Last name of the owner's name. - * @param firstName - First name of the owner's name. + * @param props - Properties for the organization card. * @returns JSX element representing the organization card. */ -function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { +function OrganizationCard(props: InterfaceOrganizationCardProps): JSX.Element { const uri = '/superorghome/i=' + props.id; return ( - <> - -
-
- {props.image ? ( - - ) : ( - - )} -
-

{props.name}

-
- Owner: - {props.firstName} - -   - {props.lastName} - -
-
+
+ + ); } -export {}; -export default organizationCard; +export default OrganizationCard; diff --git a/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx b/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx index 2a9f03a9be..dd65c8649e 100644 --- a/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx +++ b/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx @@ -6,12 +6,11 @@ describe('Testing the Organization Cards', () => { test('should render props and text elements test for the page component', () => { const props = { id: '123', - key: '456', image: 'https://via.placeholder.com/80', name: 'Sample', }; - render(); + render(); expect(screen.getByText(props.name)).toBeInTheDocument(); }); @@ -19,12 +18,11 @@ describe('Testing the Organization Cards', () => { test('Should render text elements when props value is not passed', () => { const props = { id: '123', - key: '456', image: '', name: 'Sample', }; - render(); + render(); expect(screen.getByText(props.name)).toBeInTheDocument(); }); diff --git a/src/components/ProfileDropdown/ProfileDropdown.test.tsx b/src/components/ProfileDropdown/ProfileDropdown.test.tsx index 0efef50591..82ce420aea 100644 --- a/src/components/ProfileDropdown/ProfileDropdown.test.tsx +++ b/src/components/ProfileDropdown/ProfileDropdown.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; import ProfileDropdown from './ProfileDropdown'; diff --git a/src/components/RequestsTableItem/RequestsTableItem.test.tsx b/src/components/RequestsTableItem/RequestsTableItem.test.tsx index 866abc7f68..bbd895300b 100644 --- a/src/components/RequestsTableItem/RequestsTableItem.test.tsx +++ b/src/components/RequestsTableItem/RequestsTableItem.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { StaticMockLink } from 'utils/StaticMockLink'; import i18nForTest from 'utils/i18nForTest'; diff --git a/src/components/RequestsTableItem/RequestsTableItem.tsx b/src/components/RequestsTableItem/RequestsTableItem.tsx index 2b647a9ce2..07feb5d289 100644 --- a/src/components/RequestsTableItem/RequestsTableItem.tsx +++ b/src/components/RequestsTableItem/RequestsTableItem.tsx @@ -67,7 +67,7 @@ const RequestsTableItem = (props: Props): JSX.Element => { }); /* istanbul ignore next */ if (data) { - toast.success(t('acceptedSuccessfully')); + toast.success(t('acceptedSuccessfully') as string); resetAndRefetch(); } } catch (error: unknown) { @@ -95,7 +95,7 @@ const RequestsTableItem = (props: Props): JSX.Element => { }); /* istanbul ignore next */ if (data) { - toast.success(t('rejectedSuccessfully')); + toast.success(t('rejectedSuccessfully') as string); resetAndRefetch(); } } catch (error: unknown) { diff --git a/src/components/UserListCard/UserListCard.test.tsx b/src/components/UserListCard/UserListCard.test.tsx index 9f59bb92ce..e2ad552507 100644 --- a/src/components/UserListCard/UserListCard.test.tsx +++ b/src/components/UserListCard/UserListCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; @@ -14,7 +14,7 @@ const MOCKS = [ { request: { query: ADD_ADMIN_MUTATION, - variable: { userid: '784', orgid: '554' }, + variables: { userid: '784', orgid: '554' }, }, result: { data: { @@ -28,6 +28,7 @@ const MOCKS = [ }, ]; const link = new StaticMockLink(MOCKS, true); + async function wait(ms = 100): Promise { await act(() => { return new Promise((resolve) => { @@ -41,7 +42,6 @@ describe('Testing User List Card', () => { test('Should render props and text elements test for the page component', async () => { const props = { - key: 123, id: '456', }; @@ -49,7 +49,7 @@ describe('Testing User List Card', () => { - + , @@ -62,7 +62,6 @@ describe('Testing User List Card', () => { test('Should render text elements when props value is not passed', async () => { const props = { - key: 123, id: '456', }; @@ -70,7 +69,7 @@ describe('Testing User List Card', () => { - + , diff --git a/src/components/UserListCard/UserListCard.tsx b/src/components/UserListCard/UserListCard.tsx index 193569424f..76ad110ea1 100644 --- a/src/components/UserListCard/UserListCard.tsx +++ b/src/components/UserListCard/UserListCard.tsx @@ -47,7 +47,7 @@ function userListCard(props: InterfaceUserListCardProps): JSX.Element { /* istanbul ignore next */ if (data) { - toast.success(t('addedAsAdmin')); + toast.success(t('addedAsAdmin') as string); setTimeout(() => { window.location.reload(); }, 2000); diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx index 4fcbb18070..65f5e40f76 100644 --- a/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx +++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; @@ -20,7 +20,7 @@ const MOCKS = [ { request: { query: UPDATE_USER_PASSWORD_MUTATION, - variable: { + variables: { previousPassword: 'anshgoyal', newPassword: 'anshgoyalansh', confirmNewPassword: 'anshgoyalansh', @@ -49,15 +49,10 @@ async function wait(ms = 5): Promise { } describe('Testing User Password Update', () => { - const props = { - key: '123', - id: '1', - }; - const formData = { previousPassword: 'Palisadoes', newPassword: 'ThePalisadoesFoundation', - wrongPassword: 'This is wrong passoword', + wrongPassword: 'This is wrong password', confirmNewPassword: 'ThePalisadoesFoundation', }; @@ -67,7 +62,7 @@ describe('Testing User Password Update', () => { render( - + , ); @@ -102,7 +97,7 @@ describe('Testing User Password Update', () => { render( - + , ); @@ -117,7 +112,7 @@ describe('Testing User Password Update', () => { render( - + , ); diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx index e1f8c64f0b..1ea75811c1 100644 --- a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx +++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx @@ -45,12 +45,12 @@ const UserUpdate: React.FC< !formState.newPassword || !formState.confirmNewPassword ) { - toast.error(t('passCantBeEmpty')); + toast.error(t('passCantBeEmpty') as string); return; } if (formState.newPassword !== formState.confirmNewPassword) { - toast.error(t('passNoMatch')); + toast.error(t('passNoMatch') as string); return; } @@ -64,7 +64,9 @@ const UserUpdate: React.FC< }); /* istanbul ignore next */ if (data) { - toast.success(tCommon('updatedSuccessfully', { item: 'Password' })); + toast.success( + tCommon('updatedSuccessfully', { item: 'Password' }) as string, + ); setTimeout(() => { window.location.reload(); }, 2000); diff --git a/src/components/UserPortal/CommentCard/CommentCard.test.tsx b/src/components/UserPortal/CommentCard/CommentCard.test.tsx index 35b81167fc..f02e5a606a 100644 --- a/src/components/UserPortal/CommentCard/CommentCard.test.tsx +++ b/src/components/UserPortal/CommentCard/CommentCard.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; diff --git a/src/components/UserPortal/CommentCard/CommentCard.tsx b/src/components/UserPortal/CommentCard/CommentCard.tsx index 026c2f1af3..9e8c46d241 100644 --- a/src/components/UserPortal/CommentCard/CommentCard.tsx +++ b/src/components/UserPortal/CommentCard/CommentCard.tsx @@ -92,7 +92,7 @@ function commentCard(props: InterfaceCommentCardProps): JSX.Element { } } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error); + toast.error(error as string); } } else { try { @@ -109,7 +109,7 @@ function commentCard(props: InterfaceCommentCardProps): JSX.Element { } } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error); + toast.error(error as string); } } }; diff --git a/src/components/UserPortal/ContactCard/ContactCard.test.tsx b/src/components/UserPortal/ContactCard/ContactCard.test.tsx index 7f55196bb0..03136387a7 100644 --- a/src/components/UserPortal/ContactCard/ContactCard.test.tsx +++ b/src/components/UserPortal/ContactCard/ContactCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/DonationCard/DonationCard.test.tsx b/src/components/UserPortal/DonationCard/DonationCard.test.tsx index 4e49ed8b26..cddf62dd6c 100644 --- a/src/components/UserPortal/DonationCard/DonationCard.test.tsx +++ b/src/components/UserPortal/DonationCard/DonationCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render } from '@testing-library/react'; +import React, { act } from 'react'; +import { render } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/EventCard/EventCard.tsx b/src/components/UserPortal/EventCard/EventCard.tsx index 3b9d328154..e93138ce42 100644 --- a/src/components/UserPortal/EventCard/EventCard.tsx +++ b/src/components/UserPortal/EventCard/EventCard.tsx @@ -103,7 +103,7 @@ function eventCard(props: InterfaceEventCardProps): JSX.Element { } } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error); + toast.error(error as string); } } }; diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx index dba4286290..5546166b9a 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx index b88e17ae95..e1c2c23beb 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx @@ -110,23 +110,23 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element { organizationId: props.id, }, }); - toast.success(t('MembershipRequestSent')); + toast.success(t('MembershipRequestSent') as string); } else { await joinPublicOrganization({ variables: { organizationId: props.id, }, }); - toast.success(t('orgJoined')); + toast.success(t('orgJoined') as string); } refetch(); } catch (error: unknown) { /* istanbul ignore next */ if (error instanceof Error) { if (error.message === 'User is already a member') { - toast.error(t('AlreadyJoined')); + toast.error(t('AlreadyJoined') as string); } else { - toast.error(t('errorOccured')); + toast.error(t('errorOccured') as string); } } } diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx index 027234b641..038ff626df 100644 --- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx +++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import 'jest-localstorage-mock'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter, Router } from 'react-router-dom'; diff --git a/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx b/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx index c5fbcf335e..c08240462a 100644 --- a/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx +++ b/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx b/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx index 5cadfa923b..fd5d6c7f93 100644 --- a/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx +++ b/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render } from '@testing-library/react'; +import React, { act } from 'react'; +import { render } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/PostCard/PostCard.test.tsx b/src/components/UserPortal/PostCard/PostCard.test.tsx index 64f6670223..f7d9217308 100644 --- a/src/components/UserPortal/PostCard/PostCard.test.tsx +++ b/src/components/UserPortal/PostCard/PostCard.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; diff --git a/src/components/UserPortal/PostCard/PostCard.tsx b/src/components/UserPortal/PostCard/PostCard.tsx index 3eed167f65..f8fcdaebca 100644 --- a/src/components/UserPortal/PostCard/PostCard.tsx +++ b/src/components/UserPortal/PostCard/PostCard.tsx @@ -128,7 +128,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element { } } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error); + toast.error(error as string); } } else { try { @@ -144,7 +144,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element { } } catch (error: unknown) { /* istanbul ignore next */ - toast.error(error); + toast.error(error as string); } } }; @@ -245,7 +245,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element { props.fetchPosts(); // Refresh the posts toggleEditPost(); - toast.success(tCommon('updatedSuccessfully', { item: 'Post' })); + toast.success(tCommon('updatedSuccessfully', { item: 'Post' }) as string); } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); diff --git a/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx b/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx index b5d753551c..6ec8ec5de7 100644 --- a/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx +++ b/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, waitFor } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, waitFor } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/Register/Register.test.tsx b/src/components/UserPortal/Register/Register.test.tsx index cdcfb9ebc0..f9929a0588 100644 --- a/src/components/UserPortal/Register/Register.test.tsx +++ b/src/components/UserPortal/Register/Register.test.tsx @@ -1,6 +1,6 @@ import type { SetStateAction } from 'react'; -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import userEvent from '@testing-library/user-event'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/components/UserPortal/Register/Register.tsx b/src/components/UserPortal/Register/Register.tsx index 952acf7987..11a810c955 100644 --- a/src/components/UserPortal/Register/Register.tsx +++ b/src/components/UserPortal/Register/Register.tsx @@ -57,11 +57,11 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { registerVariables.lastName ) ) { - toast.error(t('invalidDetailsMessage')); // Error if fields are missing + toast.error(t('invalidDetailsMessage') as string); // Error if fields are missing } else if ( registerVariables.password !== registerVariables.confirmPassword ) { - toast.error(t('passwordNotMatch')); // Error if passwords do not match + toast.error(t('passwordNotMatch') as string); // Error if passwords do not match } else { try { await registerMutation({ @@ -73,7 +73,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element { }, }); - toast.success(t('afterRegister')); // Success message + toast.success(t('afterRegister') as string); // Success message // Reset form fields /* istanbul ignore next */ diff --git a/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx b/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx index 5a2e815af4..5c436705cd 100644 --- a/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx +++ b/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import type { RenderResult } from '@testing-library/react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import userEvent from '@testing-library/user-event'; import { CREATE_POST_MUTATION } from 'GraphQl/Mutations/mutations'; diff --git a/src/components/UserPortal/StartPostModal/StartPostModal.tsx b/src/components/UserPortal/StartPostModal/StartPostModal.tsx index 060963865a..d48b8425fa 100644 --- a/src/components/UserPortal/StartPostModal/StartPostModal.tsx +++ b/src/components/UserPortal/StartPostModal/StartPostModal.tsx @@ -93,7 +93,7 @@ const startPostModal = ({ /* istanbul ignore next */ if (data) { toast.dismiss(); - toast.success(t('postNowVisibleInFeed')); + toast.success(t('postNowVisibleInFeed') as string); fetchPosts(); handleHide(); } diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx index 59e3585aa0..8c3447f25a 100644 --- a/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx +++ b/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx index 2984604951..7218bc745c 100644 --- a/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx +++ b/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import type { RenderResult } from '@testing-library/react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; @@ -19,14 +19,17 @@ import useLocalStorage from 'utils/useLocalstorage'; const { setItem } = useLocalStorage(); const resizeWindow = (width: number): void => { - window.innerWidth = width; - fireEvent(window, new Event('resize')); + act(() => { + window.innerWidth = width; + fireEvent(window, new Event('resize')); + }); }; const props = { hideDrawer: true, setHideDrawer: jest.fn(), }; + const MOCKS = [ { request: { @@ -366,38 +369,48 @@ describe('Testing UserSidebar Component [User Portal]', () => { }); test('Component should be rendered properly', async () => { - renderUserSidebar('properId', link); - await wait(); + await act(async () => { + renderUserSidebar('properId', link); + await wait(); + }); }); test('Component should be rendered properly when userImage is present', async () => { - renderUserSidebar('imagePresent', link); - await wait(); + await act(async () => { + renderUserSidebar('imagePresent', link); + await wait(); + }); }); test('Component should be rendered properly when organizationImage is present', async () => { - renderUserSidebar('imagePresent', link); - await wait(); + await act(async () => { + renderUserSidebar('imagePresent', link); + await wait(); + }); }); test('Component should be rendered properly when joinedOrganizations list is empty', async () => { - renderUserSidebar('orgEmpty', link); - await wait(); + await act(async () => { + renderUserSidebar('orgEmpty', link); + await wait(); + }); }); - test('Testing Drawer when the screen size is less than or equal to 820px', () => { - resizeWindow(800); - render( - - - - - - - - - , - ); + test('Testing Drawer when the screen size is less than or equal to 820px', async () => { + await act(async () => { + resizeWindow(800); + render( + + + + + + + + + , + ); + }); expect(screen.getByText('My Organizations')).toBeInTheDocument(); expect(screen.getByText('Settings')).toBeInTheDocument(); expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); @@ -405,13 +418,21 @@ describe('Testing UserSidebar Component [User Portal]', () => { const orgsBtn = screen.getAllByTestId(/orgsBtn/i); - orgsBtn[0].click(); - expect( - orgsBtn[0].className.includes('text-white btn btn-success'), - ).toBeTruthy(); - settingsBtn.click(); - expect( - settingsBtn.className.includes('text-white btn btn-success'), - ).toBeTruthy(); + act(() => { + orgsBtn[0].click(); + }); + await waitFor(() => + expect( + orgsBtn[0].className.includes('text-white btn btn-success'), + ).toBeTruthy(), + ); + act(() => { + settingsBtn.click(); + }); + await waitFor(() => + expect( + settingsBtn.className.includes('text-white btn btn-success'), + ).toBeTruthy(), + ); }); }); diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx index d9d70478b3..c187dabb55 100644 --- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx +++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { act } from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; @@ -12,7 +12,6 @@ import { Provider } from 'react-redux'; import { MockedProvider } from '@apollo/react-testing'; import { store } from 'state/store'; import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries'; -import { act } from 'react-dom/test-utils'; import { StaticMockLink } from 'utils/StaticMockLink'; import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations'; import useLocalStorage from 'utils/useLocalstorage'; diff --git a/src/components/UsersTableItem/UserTableItem.test.tsx b/src/components/UsersTableItem/UserTableItem.test.tsx index bfa0a31c86..e87b41f7f2 100644 --- a/src/components/UsersTableItem/UserTableItem.test.tsx +++ b/src/components/UsersTableItem/UserTableItem.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import { toast } from 'react-toastify'; import { StaticMockLink } from 'utils/StaticMockLink'; diff --git a/src/components/UsersTableItem/UsersTableItem.tsx b/src/components/UsersTableItem/UsersTableItem.tsx index 9d6ec65187..9e94b8a9f5 100644 --- a/src/components/UsersTableItem/UsersTableItem.tsx +++ b/src/components/UsersTableItem/UsersTableItem.tsx @@ -56,7 +56,9 @@ const UsersTableItem = (props: Props): JSX.Element => { }, }); if (data) { - toast.success(tCommon('removedSuccessfully', { item: 'User' })); + toast.success( + tCommon('removedSuccessfully', { item: 'User' }) as string, + ); resetAndRefetch(); } } catch (error: unknown) { @@ -77,7 +79,7 @@ const UsersTableItem = (props: Props): JSX.Element => { }, }); if (data) { - toast.success(t('roleUpdated')); + toast.success(t('roleUpdated') as string); resetAndRefetch(); } } catch (error: unknown) { diff --git a/src/components/Venues/VenueModal.test.tsx b/src/components/Venues/VenueModal.test.tsx index 652816adaf..b299c8ff20 100644 --- a/src/components/Venues/VenueModal.test.tsx +++ b/src/components/Venues/VenueModal.test.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import type { RenderResult } from '@testing-library/react'; -import { act, render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import 'jest-location-mock'; diff --git a/src/components/Venues/VenueModal.tsx b/src/components/Venues/VenueModal.tsx index fd672d4ea2..476964b910 100644 --- a/src/components/Venues/VenueModal.tsx +++ b/src/components/Venues/VenueModal.tsx @@ -77,13 +77,13 @@ const VenueModal = ({ */ const handleSubmit = useCallback(async () => { if (formState.name.trim().length === 0) { - toast.error(t('venueTitleError')); + toast.error(t('venueTitleError') as string); return; } const capacityNum = parseInt(formState.capacity); if (isNaN(capacityNum) || capacityNum <= 0) { - toast.error(t('venueCapacityError')); + toast.error(t('venueCapacityError') as string); return; } @@ -100,7 +100,9 @@ const VenueModal = ({ }); /* istanbul ignore next */ if (data) { - toast.success(edit ? t('venueUpdated') : t('venueAdded')); + toast.success( + edit ? (t('venueUpdated') as string) : (t('venueAdded') as string), + ); refetchVenues(); onHide(); setFormState({ diff --git a/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx b/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx index ae792966fe..e1abb52a1e 100644 --- a/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx +++ b/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx @@ -1,15 +1,16 @@ +import React from 'react'; import { MockedProvider } from '@apollo/react-testing'; import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import { I18nextProvider } from 'react-i18next'; -import React from 'react'; - import { store } from 'state/store'; import DummyPlugin from './DummyPlugin'; import i18nForTest from 'utils/i18nForTest'; import { StaticMockLink } from 'utils/StaticMockLink'; + const link = new StaticMockLink([], true); + describe('Testing dummy plugin', () => { test('should render props and text elements test for the page component', () => { const { getByText } = render( @@ -21,7 +22,7 @@ describe('Testing dummy plugin', () => { - + , ); expect(getByText(/Welcome to the Dummy Plugin!/i)).toBeInTheDocument(); diff --git a/src/components/plugins/DummyPlugin/DummyPlugin.tsx b/src/components/plugins/DummyPlugin/DummyPlugin.tsx index d3c8ed8d41..5b837ea076 100644 --- a/src/components/plugins/DummyPlugin/DummyPlugin.tsx +++ b/src/components/plugins/DummyPlugin/DummyPlugin.tsx @@ -9,7 +9,7 @@ import AddOn from 'components/AddOn/AddOn'; * * @returns JSX.Element - Renders the `AddOn` component containing a welcome message. */ -function dummyPlugin(): JSX.Element { +function DummyPlugin(): JSX.Element { return (
Welcome to the Dummy Plugin!
@@ -17,8 +17,4 @@ function dummyPlugin(): JSX.Element { ); } -dummyPlugin.defaultProps = {}; - -dummyPlugin.propTypes = {}; - -export default dummyPlugin; +export default DummyPlugin; diff --git a/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx b/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx index bcec97367c..c2cfe03a1e 100644 --- a/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx +++ b/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx @@ -5,14 +5,14 @@ import { BrowserRouter } from 'react-router-dom'; import { store } from 'state/store'; import DummyPlugin2 from './DummyPlugin2'; -describe('Testing dummy plugin 2', () => { - test('should render props and text elements test for the page component', () => { +describe('Testing DummyPlugin2', () => { + test('should render DummyPlugin2 component', () => { render( - + , ); }); }); diff --git a/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx b/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx index 9d7e5e4498..dca6d63ee3 100644 --- a/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx +++ b/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx @@ -7,12 +7,8 @@ import React from 'react'; * This component currently does not have any additional functionality * or properties. */ -function dummyPlugin2(): JSX.Element { +function DummyPlugin2(): JSX.Element { return
; } -dummyPlugin2.defaultProps = {}; - -dummyPlugin2.propTypes = {}; - -export default dummyPlugin2; +export default DummyPlugin2; diff --git a/src/index.tsx b/src/index.tsx index 44cb0578b6..7a1bbeba59 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,5 @@ import React, { Suspense } from 'react'; -import ReactDOM from 'react-dom'; +import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import type { NormalizedCacheObject } from '@apollo/client'; import { @@ -131,7 +131,10 @@ const client: ApolloClient = new ApolloClient({ }); const fallbackLoader =
; -ReactDOM.render( +const container = document.getElementById('root'); +const root = createRoot(container!); // Note the use of '!' is to assert the container is not null + +root.render( @@ -146,5 +149,4 @@ ReactDOM.render( , - document.getElementById('root'), ); diff --git a/src/screens/BlockUser/BlockUser.test.tsx b/src/screens/BlockUser/BlockUser.test.tsx index bb490fbe3f..c851470d9b 100644 --- a/src/screens/BlockUser/BlockUser.test.tsx +++ b/src/screens/BlockUser/BlockUser.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { BLOCK_USER_MUTATION, diff --git a/src/screens/BlockUser/BlockUser.tsx b/src/screens/BlockUser/BlockUser.tsx index f32ffe6091..1f36257bb1 100644 --- a/src/screens/BlockUser/BlockUser.tsx +++ b/src/screens/BlockUser/BlockUser.tsx @@ -1,5 +1,5 @@ import { useMutation, useQuery } from '@apollo/client'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useCallback } from 'react'; import { Dropdown, Form, Table } from 'react-bootstrap'; import Button from 'react-bootstrap/Button'; import { toast } from 'react-toastify'; @@ -83,90 +83,99 @@ const Requests = (): JSX.Element => { return; } - if (showBlockedMembers == false) { - setMembersData(memberData?.organizationsMemberConnection.edges); + if (!showBlockedMembers) { + setMembersData(memberData?.organizationsMemberConnection.edges || []); } else { const blockUsers = memberData?.organizationsMemberConnection.edges.filter( (user: InterfaceMember) => user.organizationsBlockedBy.some((org) => org._id === currentUrl), ); - setMembersData(blockUsers); + setMembersData(blockUsers || []); } - }, [memberData, showBlockedMembers]); + }, [memberData, showBlockedMembers, currentUrl]); // Handler for blocking a user - const handleBlockUser = async (userId: string): Promise => { - try { - const { data } = await blockUser({ - variables: { - userId, - orgId: currentUrl, - }, - }); - /* istanbul ignore next */ - if (data) { - toast.success(t('blockedSuccessfully')); - memberRefetch(); + const handleBlockUser = useCallback( + async (userId: string): Promise => { + try { + const { data } = await blockUser({ + variables: { + userId, + orgId: currentUrl, + }, + }); + /* istanbul ignore next */ + if (data) { + toast.success(t('blockedSuccessfully') as string); + memberRefetch(); + } + } catch (error: unknown) { + /* istanbul ignore next */ + errorHandler(t, error); } - } catch (error: unknown) { - /* istanbul ignore next */ - errorHandler(t, error); - } - }; + }, + [blockUser, currentUrl, memberRefetch, t], + ); // Handler for unblocking a user - const handleUnBlockUser = async (userId: string): Promise => { - try { - const { data } = await unBlockUser({ - variables: { - userId, - orgId: currentUrl, - }, - }); - /* istanbul ignore next */ - if (data) { - toast.success(t('Un-BlockedSuccessfully')); - memberRefetch(); + const handleUnBlockUser = useCallback( + async (userId: string): Promise => { + try { + const { data } = await unBlockUser({ + variables: { + userId, + orgId: currentUrl, + }, + }); + /* istanbul ignore next */ + if (data) { + toast.success(t('Un-BlockedSuccessfully') as string); + memberRefetch(); + } + } catch (error: unknown) { + /* istanbul ignore next */ + errorHandler(t, error); } - } catch (error: unknown) { - /* istanbul ignore next */ - errorHandler(t, error); - } - }; + }, + [unBlockUser, currentUrl, memberRefetch, t], + ); // Display error if member query fails - /* istanbul ignore next */ - if (memberError) { - toast.error(memberError.message); - } + useEffect(() => { + if (memberError) { + toast.error(memberError.message); + } + }, [memberError]); // Search handler - const handleSearch = (value: string): void => { - setSearchByName(value); - memberRefetch({ - orgId: currentUrl, - firstName_contains: searchByFirstName ? value : '', - lastName_contains: searchByFirstName ? '' : value, - }); - }; + const handleSearch = useCallback( + (value: string): void => { + setSearchByName(value); + memberRefetch({ + orgId: currentUrl, + firstName_contains: searchByFirstName ? value : '', + lastName_contains: searchByFirstName ? '' : value, + }); + }, + [searchByFirstName, memberRefetch, currentUrl], + ); // Search by Enter key - const handleSearchByEnter = ( - e: React.KeyboardEvent, - ): void => { - if (e.key === 'Enter') { - const { value } = e.currentTarget; - handleSearch(value); - } - }; + const handleSearchByEnter = useCallback( + (e: React.KeyboardEvent): void => { + if (e.key === 'Enter') { + const { value } = e.currentTarget; + handleSearch(value); + } + }, + [handleSearch], + ); // Search button click handler - const handleSearchByBtnClick = (): void => { - const inputValue = - (document.getElementById('searchBlockedUsers') as HTMLInputElement) - ?.value || ''; + const handleSearchByBtnClick = useCallback((): void => { + const inputValue = searchByName; handleSearch(inputValue); - }; + }, [handleSearch, searchByName]); // Header titles for the table const headerTitles: string[] = [ @@ -195,6 +204,8 @@ const Requests = (): JSX.Element => { data-testid="searchByName" autoComplete="off" required + value={searchByName} + onChange={(e) => setSearchByName(e.target.value)} onKeyUp={handleSearchByEnter} />
{/* Table */} - {loadingMembers == false && + {loadingMembers === false && membersData.length === 0 && searchByName.length > 0 ? (
@@ -269,7 +280,7 @@ const Requests = (): JSX.Element => { {tCommon('noResultsFoundFor')} "{searchByName}"
- ) : loadingMembers == false && membersData.length === 0 ? ( + ) : loadingMembers === false && membersData.length === 0 ? (

{t('noSpammerFound')}

diff --git a/src/screens/CommunityProfile/CommunityProfile.test.tsx b/src/screens/CommunityProfile/CommunityProfile.test.tsx index 033c48464f..d7e056caa4 100644 --- a/src/screens/CommunityProfile/CommunityProfile.test.tsx +++ b/src/screens/CommunityProfile/CommunityProfile.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; import 'jest-location-mock'; @@ -213,53 +213,53 @@ describe('Testing Community Profile Screen', () => { , ); - await wait(); + }); + await wait(); - const communityName = screen.getByPlaceholderText(/Community Name/i); - const websiteLink = screen.getByPlaceholderText(/Website Link/i); - const logo = screen.getByTestId(/fileInput/i); - const facebook = screen.getByTestId(/facebook/i); - const instagram = screen.getByTestId(/instagram/i); - const X = screen.getByTestId(/X/i); - const linkedIn = screen.getByTestId(/linkedIn/i); - const github = screen.getByTestId(/github/i); - const youtube = screen.getByTestId(/youtube/i); - const reddit = screen.getByTestId(/reddit/i); - const slack = screen.getByTestId(/slack/i); - const saveChangesBtn = screen.getByTestId(/saveChangesBtn/i); - const resetChangeBtn = screen.getByTestId(/resetChangesBtn/i); + const communityName = screen.getByPlaceholderText(/Community Name/i); + const websiteLink = screen.getByPlaceholderText(/Website Link/i); + const logo = screen.getByTestId(/fileInput/i); + const facebook = screen.getByTestId(/facebook/i); + const instagram = screen.getByTestId(/instagram/i); + const X = screen.getByTestId(/X/i); + const linkedIn = screen.getByTestId(/linkedIn/i); + const github = screen.getByTestId(/github/i); + const youtube = screen.getByTestId(/youtube/i); + const reddit = screen.getByTestId(/reddit/i); + const slack = screen.getByTestId(/slack/i); + const saveChangesBtn = screen.getByTestId(/saveChangesBtn/i); + const resetChangeBtn = screen.getByTestId(/resetChangesBtn/i); - userEvent.type(communityName, profileVariables.name); - userEvent.type(websiteLink, profileVariables.websiteLink); - userEvent.type(facebook, profileVariables.socialUrl); - userEvent.type(instagram, profileVariables.socialUrl); - userEvent.type(X, profileVariables.socialUrl); - userEvent.type(linkedIn, profileVariables.socialUrl); - userEvent.type(github, profileVariables.socialUrl); - userEvent.type(youtube, profileVariables.socialUrl); - userEvent.type(reddit, profileVariables.socialUrl); - userEvent.type(slack, profileVariables.socialUrl); - userEvent.upload(logo, profileVariables.logo); - await wait(); + userEvent.type(communityName, profileVariables.name); + userEvent.type(websiteLink, profileVariables.websiteLink); + userEvent.type(facebook, profileVariables.socialUrl); + userEvent.type(instagram, profileVariables.socialUrl); + userEvent.type(X, profileVariables.socialUrl); + userEvent.type(linkedIn, profileVariables.socialUrl); + userEvent.type(github, profileVariables.socialUrl); + userEvent.type(youtube, profileVariables.socialUrl); + userEvent.type(reddit, profileVariables.socialUrl); + userEvent.type(slack, profileVariables.socialUrl); + userEvent.upload(logo, profileVariables.logo); + await wait(); - expect(communityName).toHaveValue(profileVariables.name); - expect(websiteLink).toHaveValue(profileVariables.websiteLink); - // expect(logo).toBeTruthy(); - expect(facebook).toHaveValue(profileVariables.socialUrl); - expect(instagram).toHaveValue(profileVariables.socialUrl); - expect(X).toHaveValue(profileVariables.socialUrl); - expect(linkedIn).toHaveValue(profileVariables.socialUrl); - expect(github).toHaveValue(profileVariables.socialUrl); - expect(youtube).toHaveValue(profileVariables.socialUrl); - expect(reddit).toHaveValue(profileVariables.socialUrl); - expect(slack).toHaveValue(profileVariables.socialUrl); - expect(saveChangesBtn).not.toBeDisabled(); - expect(resetChangeBtn).not.toBeDisabled(); - await wait(); + expect(communityName).toHaveValue(profileVariables.name); + expect(websiteLink).toHaveValue(profileVariables.websiteLink); + // expect(logo).toBeTruthy(); + expect(facebook).toHaveValue(profileVariables.socialUrl); + expect(instagram).toHaveValue(profileVariables.socialUrl); + expect(X).toHaveValue(profileVariables.socialUrl); + expect(linkedIn).toHaveValue(profileVariables.socialUrl); + expect(github).toHaveValue(profileVariables.socialUrl); + expect(youtube).toHaveValue(profileVariables.socialUrl); + expect(reddit).toHaveValue(profileVariables.socialUrl); + expect(slack).toHaveValue(profileVariables.socialUrl); + expect(saveChangesBtn).not.toBeDisabled(); + expect(resetChangeBtn).not.toBeDisabled(); + await wait(); - userEvent.click(saveChangesBtn); - await wait(); - }); + userEvent.click(saveChangesBtn); + await wait(); }); test('If the queried data has some fields null then the input field should be empty', async () => { diff --git a/src/screens/CommunityProfile/CommunityProfile.tsx b/src/screens/CommunityProfile/CommunityProfile.tsx index 2f2d956b55..02f8b8aca4 100644 --- a/src/screens/CommunityProfile/CommunityProfile.tsx +++ b/src/screens/CommunityProfile/CommunityProfile.tsx @@ -146,7 +146,7 @@ const CommunityProfile = (): JSX.Element => { }, }, }); - toast.success(t('profileChangedMsg')); + toast.success(t('profileChangedMsg') as string); } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error as Error); @@ -179,7 +179,7 @@ const CommunityProfile = (): JSX.Element => { resetPreLoginImageryId: preLoginData?._id, }, }); - toast.success(t(`resetData`)); + toast.success(t(`resetData`) as string); } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error as Error); diff --git a/src/screens/EventManagement/EventManagement.tsx b/src/screens/EventManagement/EventManagement.tsx index adcc536a08..74dfc806ce 100644 --- a/src/screens/EventManagement/EventManagement.tsx +++ b/src/screens/EventManagement/EventManagement.tsx @@ -139,14 +139,13 @@ const EventManagement = (): JSX.Element => { const props = { variant, className, - key: value, size: 'sm' as 'sm' | 'lg', onClick: () => handleClick(value), 'data-testid': `${value}Btn`, }; return ( - diff --git a/src/screens/ForgotPassword/ForgotPassword.test.tsx b/src/screens/ForgotPassword/ForgotPassword.test.tsx index eb62cb0178..b20dfbf767 100644 --- a/src/screens/ForgotPassword/ForgotPassword.test.tsx +++ b/src/screens/ForgotPassword/ForgotPassword.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; import 'jest-location-mock'; diff --git a/src/screens/ForgotPassword/ForgotPassword.tsx b/src/screens/ForgotPassword/ForgotPassword.tsx index 06761879a5..a2e638fd59 100644 --- a/src/screens/ForgotPassword/ForgotPassword.tsx +++ b/src/screens/ForgotPassword/ForgotPassword.tsx @@ -92,17 +92,17 @@ const ForgotPassword = (): JSX.Element => { if (data) { setItem('otpToken', data.otp.otpToken); - toast.success(t('OTPsent')); + toast.success(t('OTPsent') as string); setShowEnterEmail(false); } } catch (error: unknown) { if (error instanceof Error) { if (error.message === 'User not found') { - toast.warn(tErrors('emailNotRegistered')); + toast.warn(tErrors('emailNotRegistered') as string); } else if (error.message === 'Failed to fetch') { - toast.error(tErrors('talawaApiUnavailable')); + toast.error(tErrors('talawaApiUnavailable') as string); } else { - toast.error(tErrors('errorSendingMail')); + toast.error(tErrors('errorSendingMail') as string); } } } @@ -120,7 +120,7 @@ const ForgotPassword = (): JSX.Element => { const { userOtp, newPassword, confirmNewPassword } = forgotPassFormData; if (newPassword !== confirmNewPassword) { - toast.error(t('passwordMismatches')); + toast.error(t('passwordMismatches') as string); return; } @@ -141,7 +141,7 @@ const ForgotPassword = (): JSX.Element => { /* istanbul ignore next */ if (data) { - toast.success(t('passwordChanges')); + toast.success(t('passwordChanges') as string); setShowEnterEmail(true); setForgotPassFormData({ userOtp: '', diff --git a/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx b/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx index 2ecf6c7c23..288baa16ef 100644 --- a/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx +++ b/src/screens/FundCampaignPledge/PledgeDeleteModal.tsx @@ -61,7 +61,7 @@ const PledgeDeleteModal: React.FC = ({ }); refetchPledge(); hide(); - toast.success(t('pledgeDeleted')); + toast.success(t('pledgeDeleted') as string); } catch (error: unknown) { toast.error((error as Error).message); } diff --git a/src/screens/FundCampaignPledge/PledgeModal.tsx b/src/screens/FundCampaignPledge/PledgeModal.tsx index ab126101de..782a051277 100644 --- a/src/screens/FundCampaignPledge/PledgeModal.tsx +++ b/src/screens/FundCampaignPledge/PledgeModal.tsx @@ -157,7 +157,7 @@ const PledgeModal: React.FC = ({ ...updatedFields, }, }); - toast.success(t('pledgeUpdated')); + toast.success(t('pledgeUpdated') as string); refetchPledge(); hide(); } catch (error: unknown) { @@ -183,7 +183,7 @@ const PledgeModal: React.FC = ({ }, }); - toast.success(t('pledgeCreated')); + toast.success(t('pledgeCreated') as string); refetchPledge(); setFormState({ pledgeUsers: [], diff --git a/src/screens/LoginPage/LoginPage.test.tsx b/src/screens/LoginPage/LoginPage.test.tsx index 1eeb683654..3733a454dd 100644 --- a/src/screens/LoginPage/LoginPage.test.tsx +++ b/src/screens/LoginPage/LoginPage.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render, screen, fireEvent, within } from '@testing-library/react'; +import { render, screen, fireEvent, within } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import userEvent from '@testing-library/user-event'; diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx index d69f4f88d5..56b9012ee8 100644 --- a/src/screens/LoginPage/LoginPage.tsx +++ b/src/screens/LoginPage/LoginPage.tsx @@ -175,7 +175,7 @@ const loginPage = (): JSX.Element => { return data.recaptcha; } catch (error) { /* istanbul ignore next */ - toast.error(t('captchaError')); + toast.error(t('captchaError') as string); } }; @@ -198,7 +198,7 @@ const loginPage = (): JSX.Element => { const isVerified = await verifyRecaptcha(recaptchaToken); /* istanbul ignore next */ if (!isVerified) { - toast.error(t('Please_check_the_captcha')); + toast.error(t('Please_check_the_captcha') as string); return; } const isValidatedString = (value: string): boolean => @@ -239,7 +239,9 @@ const loginPage = (): JSX.Element => { /* istanbul ignore next */ if (signUpData) { toast.success( - t(role === 'admin' ? 'successfullyRegistered' : 'afterRegister'), + t( + role === 'admin' ? 'successfullyRegistered' : 'afterRegister', + ) as string, ); setShowTab('LOGIN'); setSignFormState({ @@ -256,20 +258,20 @@ const loginPage = (): JSX.Element => { errorHandler(t, error); } } else { - toast.warn(t('passwordMismatches')); + toast.warn(t('passwordMismatches') as string); } } else { if (!isValidatedString(signfirstName)) { - toast.warn(t('firstName_invalid')); + toast.warn(t('firstName_invalid') as string); } if (!isValidatedString(signlastName)) { - toast.warn(t('lastName_invalid')); + toast.warn(t('lastName_invalid') as string); } if (!validatePassword(signPassword)) { - toast.warn(t('password_invalid')); + toast.warn(t('password_invalid') as string); } if (signEmail.length < 8) { - toast.warn(t('email_invalid')); + toast.warn(t('email_invalid') as string); } } }; @@ -279,7 +281,7 @@ const loginPage = (): JSX.Element => { const isVerified = await verifyRecaptcha(recaptchaToken); /* istanbul ignore next */ if (!isVerified) { - toast.error(t('Please_check_the_captcha')); + toast.error(t('Please_check_the_captcha') as string); return; } @@ -300,7 +302,7 @@ const loginPage = (): JSX.Element => { appUserProfile.isSuperAdmin || appUserProfile.adminFor.length !== 0; if (role === 'admin' && !isAdmin) { - toast.warn(tErrors('notAuthorised')); + toast.warn(tErrors('notAuthorised') as string); return; } const loggedInUserId = user._id; @@ -324,7 +326,7 @@ const loginPage = (): JSX.Element => { navigate(role === 'admin' ? '/orglist' : '/user/organizations'); } else { - toast.warn(tErrors('notFound')); + toast.warn(tErrors('notFound') as string); } } catch (error) { /* istanbul ignore next */ diff --git a/src/screens/ManageTag/ManageTag.tsx b/src/screens/ManageTag/ManageTag.tsx index 5262724892..86a44fb169 100644 --- a/src/screens/ManageTag/ManageTag.tsx +++ b/src/screens/ManageTag/ManageTag.tsx @@ -113,7 +113,7 @@ function ManageTag(): JSX.Element { userTagAssignedMembersRefetch(); toggleUnassignTagModal(); - toast.success(t('successfullyUnassigned')); + toast.success(t('successfullyUnassigned') as string); } catch (error: unknown) { /* istanbul ignore next */ if (error instanceof Error) { diff --git a/src/screens/MemberDetail/MemberDetail.test.tsx b/src/screens/MemberDetail/MemberDetail.test.tsx index e094354552..7b3707754c 100644 --- a/src/screens/MemberDetail/MemberDetail.test.tsx +++ b/src/screens/MemberDetail/MemberDetail.test.tsx @@ -442,7 +442,6 @@ describe('MemberDetail', () => { test('should display warnings for blank form submission', async () => { jest.spyOn(toast, 'warning'); const props = { - key: '123', id: '1', toggleStateValue: jest.fn(), }; @@ -452,7 +451,7 @@ describe('MemberDetail', () => { - + @@ -467,6 +466,7 @@ describe('MemberDetail', () => { expect(toast.warning).toHaveBeenCalledWith('Last Name cannot be blank!'); expect(toast.warning).toHaveBeenCalledWith('Email cannot be blank!'); }); + test('display admin', async () => { const props = { id: 'rishav-jha-mech', diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index ef623146d4..6d92ccbb4a 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -194,7 +194,7 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { setItem('Email', email); setItem('UserImage', image); } - toast.success(tCommon('successfullyUpdated')); + toast.success(tCommon('successfullyUpdated') as string); } } catch (error: unknown) { if (error instanceof Error) { diff --git a/src/screens/OrgContribution/OrgContribution.test.tsx b/src/screens/OrgContribution/OrgContribution.test.tsx index d2abc134df..f9f63c6807 100644 --- a/src/screens/OrgContribution/OrgContribution.test.tsx +++ b/src/screens/OrgContribution/OrgContribution.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { act, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import 'jest-location-mock'; diff --git a/src/screens/OrgList/OrgList.test.tsx b/src/screens/OrgList/OrgList.test.tsx index e7e0f7d4be..5b889ff07d 100644 --- a/src/screens/OrgList/OrgList.test.tsx +++ b/src/screens/OrgList/OrgList.test.tsx @@ -515,22 +515,21 @@ describe('Organisations Page testing as Admin', () => { ); await wait(); + }); + const sortDropdown = await waitFor(() => screen.getByTestId('sort')); + expect(sortDropdown).toBeInTheDocument(); - const searchInput = screen.getByTestId('sort'); - expect(searchInput).toBeInTheDocument(); - - const inputText = screen.getByTestId('sortOrgs'); + const sortToggle = screen.getByTestId('sortOrgs'); - fireEvent.click(inputText); - const toggleText = screen.getByTestId('latest'); + fireEvent.click(sortToggle); + const latestOption = await waitFor(() => screen.getByTestId('latest')); - fireEvent.click(toggleText); + fireEvent.click(latestOption); - expect(searchInput).toBeInTheDocument(); - fireEvent.click(inputText); - const toggleTite = screen.getByTestId('oldest'); - fireEvent.click(toggleTite); - expect(searchInput).toBeInTheDocument(); - }); + expect(sortDropdown).toBeInTheDocument(); + fireEvent.click(sortToggle); + const oldestOption = await waitFor(() => screen.getByTestId('oldest')); + fireEvent.click(oldestOption); + expect(sortDropdown).toBeInTheDocument(); }); }); diff --git a/src/screens/OrgList/OrgList.tsx b/src/screens/OrgList/OrgList.tsx index 5c91678217..7023bfa9b1 100644 --- a/src/screens/OrgList/OrgList.tsx +++ b/src/screens/OrgList/OrgList.tsx @@ -169,11 +169,11 @@ function orgList(): JSX.Element { const triggerCreateSampleOrg = (): void => { createSampleOrganization() .then(() => { - toast.success(t('sampleOrgSuccess')); + toast.success(t('sampleOrgSuccess') as string); window.location.reload(); }) .catch(() => { - toast.error(t('sampleOrgDuplicate')); + toast.error(t('sampleOrgDuplicate') as string); }); }; diff --git a/src/screens/OrgPost/OrgPost.test.tsx b/src/screens/OrgPost/OrgPost.test.tsx index 465da98642..9829589350 100644 --- a/src/screens/OrgPost/OrgPost.test.tsx +++ b/src/screens/OrgPost/OrgPost.test.tsx @@ -1,11 +1,11 @@ import { MockedProvider } from '@apollo/react-testing'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-location-mock'; import { I18nextProvider } from 'react-i18next'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; -import React from 'react'; +import React, { act } from 'react'; import { CREATE_POST_MUTATION } from 'GraphQl/Mutations/mutations'; import { ORGANIZATION_POST_LIST } from 'GraphQl/Queries/Queries'; import { ToastContainer } from 'react-toastify'; @@ -286,25 +286,34 @@ describe('Organisation Post Page', () => { , ); + }); + await wait(); - await wait(); - - const searchInput = screen.getByTestId('searchByName'); - expect(searchInput).toHaveAttribute('placeholder', 'Search By Title'); + const searchInput = screen.getByTestId('searchByName'); + expect(searchInput).toHaveAttribute('placeholder', 'Search By Title'); - const inputText = screen.getByTestId('searchBy'); + const inputText = screen.getByTestId('searchBy'); + await act(async () => { fireEvent.click(inputText); - const toggleText = screen.getByTestId('Text'); + }); + const toggleText = screen.getByTestId('Text'); + + await act(async () => { fireEvent.click(toggleText); + }); - expect(searchInput).toHaveAttribute('placeholder', 'Search By Text'); + expect(searchInput).toHaveAttribute('placeholder', 'Search By Text'); + await act(async () => { fireEvent.click(inputText); - const toggleTite = screen.getByTestId('searchTitle'); + }); + const toggleTite = screen.getByTestId('searchTitle'); + await act(async () => { fireEvent.click(toggleTite); - expect(searchInput).toHaveAttribute('placeholder', 'Search By Title'); }); + + expect(searchInput).toHaveAttribute('placeholder', 'Search By Title'); }); test('Testing search latest and oldest toggle', async () => { await act(async () => { @@ -320,25 +329,34 @@ describe('Organisation Post Page', () => { , ); + }); + await wait(); - await wait(); - - const searchInput = screen.getByTestId('sort'); - expect(searchInput).toBeInTheDocument(); + const searchInput = screen.getByTestId('sort'); + expect(searchInput).toBeInTheDocument(); - const inputText = screen.getByTestId('sortpost'); + const inputText = screen.getByTestId('sortpost'); + await act(async () => { fireEvent.click(inputText); - const toggleText = screen.getByTestId('latest'); + }); + + const toggleText = screen.getByTestId('latest'); + await act(async () => { fireEvent.click(toggleText); + }); - expect(searchInput).toBeInTheDocument(); + expect(searchInput).toBeInTheDocument(); + await act(async () => { fireEvent.click(inputText); - const toggleTite = screen.getByTestId('oldest'); + }); + + const toggleTite = screen.getByTestId('oldest'); + await act(async () => { fireEvent.click(toggleTite); - expect(searchInput).toBeInTheDocument(); }); + expect(searchInput).toBeInTheDocument(); }); test('After creating a post, the data should be refetched', async () => { const refetchMock = jest.fn(); @@ -575,34 +593,43 @@ describe('Organisation Post Page', () => { , ); + }); + await wait(); - await wait(); - + await act(async () => { userEvent.click(screen.getByTestId('createPostModalBtn')); + }); - const postTitleInput = screen.getByTestId('modalTitle'); + const postTitleInput = screen.getByTestId('modalTitle'); + await act(async () => { fireEvent.change(postTitleInput, { target: { value: 'Test Post' } }); + }); - const postInfoTextarea = screen.getByTestId('modalinfo'); + const postInfoTextarea = screen.getByTestId('modalinfo'); + await act(async () => { fireEvent.change(postInfoTextarea, { target: { value: 'Test post information' }, }); + }); - const videoFile = new File(['video content'], 'video.mp4', { - type: 'video/mp4', - }); + const videoFile = new File(['video content'], 'video.mp4', { + type: 'video/mp4', + }); + await act(async () => { userEvent.upload(screen.getByTestId('addMediaField'), videoFile); + }); - // Check if the video is displayed - const videoPreview = await screen.findByTestId('videoPreview'); - expect(videoPreview).toBeInTheDocument(); + // Check if the video is displayed + const videoPreview = await screen.findByTestId('videoPreview'); + expect(videoPreview).toBeInTheDocument(); - // Check if the close button for the video works - const closeVideoPreviewButton = screen.getByTestId('mediaCloseButton'); + // Check if the close button for the video works + const closeVideoPreviewButton = screen.getByTestId('mediaCloseButton'); + await act(async () => { fireEvent.click(closeVideoPreviewButton); - expect(videoPreview).not.toBeInTheDocument(); }); + expect(videoPreview).not.toBeInTheDocument(); }); test('Sorting posts by pinned status', async () => { // Mocked data representing posts with different pinned statuses diff --git a/src/screens/OrgPost/OrgPost.tsx b/src/screens/OrgPost/OrgPost.tsx index e1a0559f11..1931f6c76a 100644 --- a/src/screens/OrgPost/OrgPost.tsx +++ b/src/screens/OrgPost/OrgPost.tsx @@ -170,7 +170,7 @@ function orgPost(): JSX.Element { /* istanbul ignore next */ if (data) { - toast.success(t('postCreatedSuccess')); + toast.success(t('postCreatedSuccess') as string); refetch(); setPostFormState({ posttitle: '', @@ -309,7 +309,7 @@ function orgPost(): JSX.Element {
diff --git a/src/screens/UserPortal/Campaigns/PledgeModal.tsx b/src/screens/UserPortal/Campaigns/PledgeModal.tsx index 6ab2832c2f..d9076f52c8 100644 --- a/src/screens/UserPortal/Campaigns/PledgeModal.tsx +++ b/src/screens/UserPortal/Campaigns/PledgeModal.tsx @@ -166,7 +166,7 @@ const PledgeModal: React.FC = ({ ...updatedFields, }, }); - toast.success(t('pledgeUpdated')); + toast.success(t('pledgeUpdated') as string); refetchPledge(); hide(); } catch (error: unknown) { @@ -198,7 +198,7 @@ const PledgeModal: React.FC = ({ }, }); - toast.success(t('pledgeCreated')); + toast.success(t('pledgeCreated') as string); refetchPledge(); setFormState({ pledgeUsers: [], diff --git a/src/screens/UserPortal/Chat/Chat.test.tsx b/src/screens/UserPortal/Chat/Chat.test.tsx index 66e6115ce7..4a0dfbcf4e 100644 --- a/src/screens/UserPortal/Chat/Chat.test.tsx +++ b/src/screens/UserPortal/Chat/Chat.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider, useTranslation } from 'react-i18next'; @@ -2259,15 +2259,26 @@ describe('Testing Chat Screen [User Portal]', () => { , ); + screen.debug(); + await waitFor(() => { + const closeMenuBtn = screen.queryByTestId('closeMenu'); + expect(closeMenuBtn).toBeInTheDocument(); + if (closeMenuBtn) { + closeMenuBtn.click(); + } else { + throw new Error('Close menu button not found'); + } + }); - await wait(); - - const closeMenubtn = screen.getByTestId('closeMenu'); - expect(closeMenubtn).toBeInTheDocument(); - closeMenubtn.click(); - const openMenuBtn = screen.getByTestId('openMenu'); - expect(openMenuBtn).toBeInTheDocument(); - openMenuBtn.click(); + await waitFor(() => { + const openMenuBtn = screen.queryByTestId('openMenu'); + expect(openMenuBtn).toBeInTheDocument(); + if (openMenuBtn) { + openMenuBtn.click(); + } else { + throw new Error('Open menu button not found'); + } + }); }); test('Testing sidebar when the screen size is less than or equal to 820px', async () => { @@ -2293,12 +2304,16 @@ describe('Testing Chat Screen [User Portal]', () => { , ); - await wait(); - expect(screen.getByText('My Organizations')).toBeInTheDocument(); - expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); - - const chatBtn = screen.getByTestId('chatBtn'); - - chatBtn.click(); + screen.debug(); + await waitFor(() => { + expect(screen.getByText('My Organizations')).toBeInTheDocument(); + expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); + }); + await waitFor(() => { + const chatBtn = screen.getByTestId('chatBtn'); + act(() => { + chatBtn.click(); + }); + }); }); }); diff --git a/src/screens/UserPortal/Donate/Donate.test.tsx b/src/screens/UserPortal/Donate/Donate.test.tsx index 63083bd297..c4d435415e 100644 --- a/src/screens/UserPortal/Donate/Donate.test.tsx +++ b/src/screens/UserPortal/Donate/Donate.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/screens/UserPortal/Donate/Donate.tsx b/src/screens/UserPortal/Donate/Donate.tsx index 84ad62a06a..c6e6d918d5 100644 --- a/src/screens/UserPortal/Donate/Donate.tsx +++ b/src/screens/UserPortal/Donate/Donate.tsx @@ -162,7 +162,7 @@ export default function donate(): JSX.Element { }, }); refetch(); - toast.success(t(`success`)); + toast.success(t(`success`) as string); } catch (error: unknown) { /* istanbul ignore next */ errorHandler(t, error); diff --git a/src/screens/UserPortal/Events/Events.test.tsx b/src/screens/UserPortal/Events/Events.test.tsx index 6de04ee172..1e74c9fb95 100644 --- a/src/screens/UserPortal/Events/Events.test.tsx +++ b/src/screens/UserPortal/Events/Events.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; diff --git a/src/screens/UserPortal/Events/Events.tsx b/src/screens/UserPortal/Events/Events.tsx index f39aae3cdd..072e8237be 100644 --- a/src/screens/UserPortal/Events/Events.tsx +++ b/src/screens/UserPortal/Events/Events.tsx @@ -122,7 +122,7 @@ export default function events(): JSX.Element { /* istanbul ignore next */ if (createEventData) { - toast.success(t('eventCreated')); + toast.success(t('eventCreated') as string); refetch(); setEventTitle(''); setEventDescription(''); diff --git a/src/screens/UserPortal/Organizations/Organizations.test.tsx b/src/screens/UserPortal/Organizations/Organizations.test.tsx index 87d0997409..163a755926 100644 --- a/src/screens/UserPortal/Organizations/Organizations.test.tsx +++ b/src/screens/UserPortal/Organizations/Organizations.test.tsx @@ -1,5 +1,5 @@ import { MockedProvider } from '@apollo/react-testing'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import userEvent from '@testing-library/user-event'; @@ -15,7 +15,7 @@ import { StaticMockLink } from 'utils/StaticMockLink'; import i18nForTest from 'utils/i18nForTest'; import useLocalStorage from 'utils/useLocalstorage'; import Organizations from './Organizations'; -import React from 'react'; +import React, { act } from 'react'; const { getItem } = useLocalStorage(); const MOCKS = [ @@ -440,7 +440,7 @@ describe('Testing Organizations Screen [User Portal]', () => { expect(joinNowButtons.length).toBeGreaterThan(0); }); - test('Mode is changed to created organizations', async () => { + test('Mode is changed to created organisations', async () => { render( @@ -476,14 +476,22 @@ describe('Testing Organizations Screen [User Portal]', () => { , ); - await wait(); - - const closeMenubtn = screen.getByTestId('closeMenu'); - expect(closeMenubtn).toBeInTheDocument(); - closeMenubtn.click(); - const openMenuBtn = screen.getByTestId('openMenu'); - expect(openMenuBtn).toBeInTheDocument(); - openMenuBtn.click(); + await waitFor(() => { + const closeMenuBtn = screen.getByTestId('closeMenu'); + expect(closeMenuBtn).toBeInTheDocument(); + }); + await act(async () => { + const closeMenuBtn = screen.getByTestId('closeMenu'); + closeMenuBtn.click(); + }); + await waitFor(() => { + const openMenuBtn = screen.getByTestId('openMenu'); + expect(openMenuBtn).toBeInTheDocument(); + }); + await act(async () => { + const openMenuBtn = screen.getByTestId('openMenu'); + openMenuBtn.click(); + }); }); test('Testing sidebar when the screen size is less than or equal to 820px', async () => { @@ -500,12 +508,15 @@ describe('Testing Organizations Screen [User Portal]', () => { , ); - await wait(); - expect(screen.getByText('My Organizations')).toBeInTheDocument(); - expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByText('My Organizations')).toBeInTheDocument(); + expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); + }); - const settingsBtn = screen.getByTestId('settingsBtn'); + await act(async () => { + const settingsBtn = screen.getByTestId('settingsBtn'); - settingsBtn.click(); + settingsBtn.click(); + }); }); }); diff --git a/src/screens/UserPortal/People/People.test.tsx b/src/screens/UserPortal/People/People.test.tsx index a233c20015..c978a0a5a3 100644 --- a/src/screens/UserPortal/People/People.test.tsx +++ b/src/screens/UserPortal/People/People.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; import { diff --git a/src/screens/UserPortal/Pledges/Pledge.test.tsx b/src/screens/UserPortal/Pledges/Pledge.test.tsx index c9ba28ab1b..ecdd25a1d3 100644 --- a/src/screens/UserPortal/Pledges/Pledge.test.tsx +++ b/src/screens/UserPortal/Pledges/Pledge.test.tsx @@ -296,9 +296,11 @@ describe('Testing User Pledge Screen', () => { expect(screen.getByTestId('searchPledges')).toBeInTheDocument(); }); - expect(screen.getByText('Harve Lance')).toBeInTheDocument(); - expect(screen.queryByText('Jeramy Gracia')).toBeNull(); - expect(screen.queryByText('Praise Norris')).toBeNull(); + await waitFor(() => { + expect(screen.getByText('Harve Lance')).toBeInTheDocument(); + expect(screen.queryByText('Jeramy Gracia')).toBeNull(); + expect(screen.queryByText('Praise Norris')).toBeNull(); + }); const moreContainer = await screen.findAllByTestId('moreContainer'); userEvent.click(moreContainer[0]); diff --git a/src/screens/UserPortal/Posts/Posts.test.tsx b/src/screens/UserPortal/Posts/Posts.test.tsx index da499403ea..aa5f03fdcf 100644 --- a/src/screens/UserPortal/Posts/Posts.test.tsx +++ b/src/screens/UserPortal/Posts/Posts.test.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import type { RenderResult } from '@testing-library/react'; -import { act, render, screen, waitFor, within } from '@testing-library/react'; +import { render, screen, waitFor, within } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import userEvent from '@testing-library/user-event'; import { @@ -15,6 +15,7 @@ import { StaticMockLink } from 'utils/StaticMockLink'; import i18nForTest from 'utils/i18nForTest'; import Home from './Posts'; import useLocalStorage from 'utils/useLocalstorage'; +import { DELETE_POST_MUTATION } from 'GraphQl/Mutations/mutations'; const { setItem } = useLocalStorage(); @@ -217,6 +218,17 @@ const MOCKS = [ }, }, }, + { + request: { + query: DELETE_POST_MUTATION, + variables: { id: '6411e54835d7ba2344a78e29' }, + }, + result: { + data: { + removePost: { _id: '6411e54835d7ba2344a78e29' }, + }, + }, + }, ]; const link = new StaticMockLink(MOCKS, true); @@ -350,10 +362,11 @@ describe('Testing Home Screen: User Portal', () => { test('Checking if refetch works after deleting this post', async () => { setItem('userId', '640d98d9eb6a743d75341067'); renderHomeScreen(); - await wait(); - - userEvent.click(screen.getAllByTestId('dropdown')[1]); - userEvent.click(screen.getByTestId('deletePost')); + expect(screen.queryAllByTestId('dropdown')).not.toBeNull(); + const dropdowns = await screen.findAllByTestId('dropdown'); + userEvent.click(dropdowns[1]); + const deleteButton = await screen.findByTestId('deletePost'); + userEvent.click(deleteButton); }); }); @@ -380,11 +393,7 @@ describe('HomeScreen with invalid orgId', () => { , ); - - // Wait for the navigation to occur - await waitFor(() => { - const homeEl = screen.getByTestId('homeEl'); - expect(homeEl).toBeInTheDocument(); - }); + const homeEl = await screen.findByTestId('homeEl'); + expect(homeEl).toBeInTheDocument(); }); }); diff --git a/src/screens/UserPortal/Settings/Settings.test.tsx b/src/screens/UserPortal/Settings/Settings.test.tsx index eccf59aaab..34aa3711bd 100644 --- a/src/screens/UserPortal/Settings/Settings.test.tsx +++ b/src/screens/UserPortal/Settings/Settings.test.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { act, fireEvent, render, screen } from '@testing-library/react'; +import React, { act } from 'react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; import { UPDATE_USER_MUTATION } from 'GraphQl/Mutations/mutations'; @@ -144,7 +144,7 @@ const resizeWindow = (width: number): void => { }; async function wait(ms = 100): Promise { - await act(() => { + await act(async () => { return new Promise((resolve) => { setTimeout(resolve, ms); }); @@ -152,32 +152,37 @@ async function wait(ms = 100): Promise { } describe('Testing Settings Screen [User Portal]', () => { - Object.defineProperty(window, 'matchMedia', { - writable: true, - value: jest.fn().mockImplementation((query) => ({ - matches: false, - media: query, - onchange: null, - addListener: jest.fn(), // Deprecated - removeListener: jest.fn(), // Deprecated - addEventListener: jest.fn(), - removeEventListener: jest.fn(), - dispatchEvent: jest.fn(), - })), + // Mock implementation of matchMedia + beforeAll(() => { + Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // Deprecated + removeListener: jest.fn(), // Deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), + }); }); test('Screen should be rendered properly', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); @@ -185,17 +190,19 @@ describe('Testing Settings Screen [User Portal]', () => { }); test('input works properly', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); @@ -240,17 +247,19 @@ describe('Testing Settings Screen [User Portal]', () => { }); test('resetChangesBtn works properly', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); @@ -270,17 +279,19 @@ describe('Testing Settings Screen [User Portal]', () => { }); test('resetChangesBtn works properly when the details are empty', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); @@ -300,210 +311,64 @@ describe('Testing Settings Screen [User Portal]', () => { }); test('sidebar', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); const closeMenubtn = screen.getByTestId('closeMenu'); expect(closeMenubtn).toBeInTheDocument(); - closeMenubtn.click(); + act(() => closeMenubtn.click()); const openMenuBtn = screen.getByTestId('openMenu'); expect(openMenuBtn).toBeInTheDocument(); - openMenuBtn.click(); + act(() => openMenuBtn.click()); }); test('Testing sidebar when the screen size is less than or equal to 820px', async () => { resizeWindow(800); - render( - - - - - - - - - , - ); - await wait(); - expect(screen.getByText('My Organizations')).toBeInTheDocument(); - expect(screen.getByText('Talawa User Portal')).toBeInTheDocument(); - - const settingsBtn = screen.getByTestId('settingsBtn'); - - settingsBtn.click(); - }); - - test('updateUserDetails Mutation is triggered on button click', async () => { - render( - - - - - - - - - , - ); - - await wait(); - - userEvent.type(screen.getByTestId('inputFirstName'), 'Noble'); - await wait(); - - userEvent.type(screen.getByTestId('inputLastName'), 'Mittal'); - await wait(); - - userEvent.selectOptions(screen.getByTestId('inputGender'), 'OTHER'); - await wait(); - - userEvent.type(screen.getByTestId('inputPhoneNumber'), '+174567890'); - await wait(); - - fireEvent.change(screen.getByLabelText('Birth Date'), { - target: { value: '2024-03-01' }, + await act(async () => { + render( + + + + + + + + + , + ); }); - await wait(); - userEvent.selectOptions(screen.getByTestId('inputGrade'), 'Graduate'); await wait(); - userEvent.selectOptions(screen.getByTestId('inputEmpStatus'), 'Unemployed'); - await wait(); + screen.debug(); - userEvent.selectOptions(screen.getByTestId('inputMaritalStatus'), 'Single'); - await wait(); + const openMenuBtn = screen.queryByTestId('openMenu'); + console.log('Open Menu Button:', openMenuBtn); + expect(openMenuBtn).toBeInTheDocument(); - userEvent.type(screen.getByTestId('inputAddress'), 'random'); - await wait(); + if (openMenuBtn) { + act(() => openMenuBtn.click()); + } - userEvent.type(screen.getByTestId('inputState'), 'random'); - await wait(); + const closeMenuBtn = screen.queryByTestId('closeMenu'); + console.log('Close Menu Button:', closeMenuBtn); + expect(closeMenuBtn).toBeInTheDocument(); - userEvent.click(screen.getByTestId('updateUserBtn')); - await wait(); + if (closeMenuBtn) { + act(() => closeMenuBtn.click()); + } }); - - test('Marital Status dropdown value verification', async () => { - render( - - - - - - - - - , - ); - - await wait(); - - // SINGLE - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[0].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Single option - screen.getByRole('option', { name: mockMaritalStatusEnum[0].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[0].value, - ); - - // ENGAGED - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[1].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Engaged option - screen.getByRole('option', { name: mockMaritalStatusEnum[1].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[1].value, - ); - - // MARRIED - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[2].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Married option - screen.getByRole('option', { name: mockMaritalStatusEnum[2].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[2].value, - ); - - // DIVORCED - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[3].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Divorced option - screen.getByRole('option', { name: mockMaritalStatusEnum[3].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[3].value, - ); - - // WIDOWED - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[4].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Widowed option - screen.getByRole('option', { name: mockMaritalStatusEnum[4].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[4].value, - ); - - // SEPARATED - expect( - screen.queryByRole('option', { name: mockMaritalStatusEnum[5].label }), - ).toBeInTheDocument(); - - userEvent.selectOptions( - // Find the select element - screen.getByTestId('inputMaritalStatus'), - // Find and select the Separated option - screen.getByRole('option', { name: mockMaritalStatusEnum[5].label }), - ); - - expect(screen.getByTestId('inputMaritalStatus')).toHaveValue( - mockMaritalStatusEnum[5].value, - ); - }, 60000); }); diff --git a/src/screens/UserPortal/Settings/Settings.tsx b/src/screens/UserPortal/Settings/Settings.tsx index 31767d8bfb..8b80f8ea1d 100644 --- a/src/screens/UserPortal/Settings/Settings.tsx +++ b/src/screens/UserPortal/Settings/Settings.tsx @@ -99,7 +99,9 @@ export default function settings(): JSX.Element { }); /* istanbul ignore next */ if (data) { - toast.success(tCommon('updatedSuccessfully', { item: 'Profile' })); + toast.success( + tCommon('updatedSuccessfully', { item: 'Profile' }) as string, + ); setTimeout(() => { window.location.reload(); }, 500); diff --git a/src/screens/Users/Users.test.tsx b/src/screens/Users/Users.test.tsx index f130ed1df9..65558e6ea7 100644 --- a/src/screens/Users/Users.test.tsx +++ b/src/screens/Users/Users.test.tsx @@ -428,22 +428,21 @@ describe('Testing Users screen', () => { , ); + }); + await wait(); - await wait(); - - const searchBtn = screen.getByTestId('searchButton'); - - const searchInput = screen.getByTestId(/searchByName/i); + const searchBtn = screen.getByTestId('searchButton'); + const searchInput = screen.getByTestId(/searchByName/i); + await act(async () => { // Clear the search input userEvent.clear(searchInput); - // Search for a name that doesn't exist userEvent.type(screen.getByTestId(/searchByName/i), 'NonexistentName'); userEvent.click(searchBtn); - - expect(screen.queryByText(/No User Found/i)).toBeInTheDocument(); }); + + expect(screen.queryByText(/No User Found/i)).toBeInTheDocument(); }); test('Testing User data is not present', async () => { @@ -518,40 +517,63 @@ describe('Testing Users screen', () => { , ); + }); + await wait(); - await wait(); - - const searchInput = screen.getByTestId('filter'); - expect(searchInput).toBeInTheDocument(); + const searchInput = screen.getByTestId('filter'); + expect(searchInput).toBeInTheDocument(); - const inputText = screen.getByTestId('filterUsers'); + const inputText = screen.getByTestId('filterUsers'); + await act(async () => { fireEvent.click(inputText); - const toggleText = screen.getByTestId('admin'); + }); + + const toggleText = screen.getByTestId('admin'); + + await act(async () => { fireEvent.click(toggleText); + }); - expect(searchInput).toBeInTheDocument(); + expect(searchInput).toBeInTheDocument(); + await act(async () => { fireEvent.click(inputText); - let toggleTite = screen.getByTestId('superAdmin'); + }); + + let toggleTite = screen.getByTestId('superAdmin'); + + await act(async () => { fireEvent.click(toggleTite); + }); - expect(searchInput).toBeInTheDocument(); + expect(searchInput).toBeInTheDocument(); + await act(async () => { fireEvent.click(inputText); - toggleTite = screen.getByTestId('user'); + }); + + toggleTite = screen.getByTestId('user'); + + await act(async () => { fireEvent.click(toggleTite); + }); - expect(searchInput).toBeInTheDocument(); + expect(searchInput).toBeInTheDocument(); + await act(async () => { fireEvent.click(inputText); - toggleTite = screen.getByTestId('cancel'); - fireEvent.click(toggleTite); + }); - await wait(); + toggleTite = screen.getByTestId('cancel'); - expect(searchInput).toBeInTheDocument(); + await act(async () => { + fireEvent.click(toggleTite); }); + + await wait(); + + expect(searchInput).toBeInTheDocument(); }); test('check for rerendering', async () => { @@ -620,37 +642,63 @@ describe('Testing Users screen', () => { , ); + }); + await wait(); - await wait(); + const filterButton = screen.getByTestId('filterUsers'); - const filterButton = screen.getByTestId('filterUsers'); + await act(async () => { fireEvent.click(filterButton); + }); - const filterAdmin = screen.getByTestId('admin'); + const filterAdmin = screen.getByTestId('admin'); + + await act(async () => { fireEvent.click(filterAdmin); - await wait(); - expect(screen.getByText('Jane Doe')).toBeInTheDocument(); + }); + await wait(); + expect(screen.getByText('Jane Doe')).toBeInTheDocument(); + + await act(async () => { fireEvent.click(filterButton); - const filterSuperAdmin = screen.getByTestId('superAdmin'); + }); + + const filterSuperAdmin = screen.getByTestId('superAdmin'); + + await act(async () => { fireEvent.click(filterSuperAdmin); - await wait(); - expect(screen.getByText('John Doe')).toBeInTheDocument(); + }); + + await wait(); + expect(screen.getByText('John Doe')).toBeInTheDocument(); + await act(async () => { fireEvent.click(filterButton); - const filterUser = screen.getByTestId('user'); + }); + + const filterUser = screen.getByTestId('user'); + await act(async () => { fireEvent.click(filterUser); - await wait(); - expect(screen.getByText('Jack Smith')).toBeInTheDocument(); + }); + await wait(); + expect(screen.getByText('Jack Smith')).toBeInTheDocument(); + + await act(async () => { fireEvent.click(filterButton); - const filterCancel = screen.getByTestId('cancel'); + }); + + const filterCancel = screen.getByTestId('cancel'); + + await act(async () => { fireEvent.click(filterCancel); - await wait(); - expect(screen.getByText('John Doe')).toBeInTheDocument(); - expect(screen.getByText('Jane Doe')).toBeInTheDocument(); - expect(screen.getByText('Jack Smith')).toBeInTheDocument(); }); + + await wait(); + expect(screen.getByText('John Doe')).toBeInTheDocument(); + expect(screen.getByText('Jane Doe')).toBeInTheDocument(); + expect(screen.getByText('Jack Smith')).toBeInTheDocument(); }); test('Users should be sorted and filtered correctly', async () => { @@ -667,47 +715,63 @@ describe('Testing Users screen', () => { , ); + }); + await wait(); - await wait(); - - // Check if the sorting and filtering logic was applied correctly - const rows = screen.getAllByRole('row'); + // Check if the sorting and filtering logic was applied correctly + const rows = screen.getAllByRole('row'); - const firstRow = rows[1]; - const secondRow = rows[2]; + const firstRow = rows[1]; + const secondRow = rows[2]; - expect(firstRow).toHaveTextContent('John Doe'); - expect(secondRow).toHaveTextContent('Jane Doe'); + expect(firstRow).toHaveTextContent('John Doe'); + expect(secondRow).toHaveTextContent('Jane Doe'); - await wait(); + await wait(); - const inputText = screen.getByTestId('sortUsers'); + const inputText = screen.getByTestId('sortUsers'); + await act(async () => { fireEvent.click(inputText); - const toggleText = screen.getByTestId('oldest'); - fireEvent.click(toggleText); + }); + + const toggleText = screen.getByTestId('oldest'); + await act(async () => { + fireEvent.click(toggleText); fireEvent.click(inputText); - const toggleTite = screen.getByTestId('newest'); + }); + + const toggleTite = screen.getByTestId('newest'); + + await act(async () => { fireEvent.click(toggleTite); + }); - // Verify the users are sorted by oldest - await wait(); + // Verify the users are sorted by oldest + await wait(); - const displayedUsers = screen.getAllByRole('row'); - expect(displayedUsers[1]).toHaveTextContent('John Doe'); // assuming User1 is the oldest - expect(displayedUsers[displayedUsers.length - 1]).toHaveTextContent( - 'Jack Smith', - ); // assuming UserN is the newest + const displayedUsers = screen.getAllByRole('row'); + expect(displayedUsers[1]).toHaveTextContent('John Doe'); // assuming User1 is the oldest + expect(displayedUsers[displayedUsers.length - 1]).toHaveTextContent( + 'Jack Smith', + ); // assuming UserN is the newest - await wait(); + await wait(); + await act(async () => { fireEvent.click(inputText); - const toggleOld = screen.getByTestId('oldest'); - fireEvent.click(toggleOld); + }); + + const toggleOld = screen.getByTestId('oldest'); + await act(async () => { + fireEvent.click(toggleOld); fireEvent.click(inputText); - const toggleNewest = screen.getByTestId('newest'); + }); + + const toggleNewest = screen.getByTestId('newest'); + await act(async () => { fireEvent.click(toggleNewest); }); }); diff --git a/src/screens/Users/Users.tsx b/src/screens/Users/Users.tsx index 0e958e7bab..72acba5b5c 100644 --- a/src/screens/Users/Users.tsx +++ b/src/screens/Users/Users.tsx @@ -137,7 +137,7 @@ const Users = (): JSX.Element => { } if (dataOrgs.organizationsConnection.length === 0) { - toast.warning(t('noOrgError')); + toast.warning(t('noOrgError') as string); } }, [dataOrgs]); diff --git a/src/utils/errorHandler.tsx b/src/utils/errorHandler.tsx index d65bb5f746..b7a22210a8 100644 --- a/src/utils/errorHandler.tsx +++ b/src/utils/errorHandler.tsx @@ -12,13 +12,13 @@ export const errorHandler = (a: unknown, error: unknown): void => { if (error instanceof Error) { switch (error.message) { case 'Failed to fetch': - toast.error(tErrors('talawaApiUnavailable')); + toast.error(tErrors('talawaApiUnavailable') as string); break; // Add more cases as needed default: toast.error(error.message); } } else { - toast.error(tErrors('unknownError', { msg: error })); + toast.error(tErrors('unknownError', { msg: error }) as string); } };