From 98b1c29d25efaa87939a68be1279735982eaa59c Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 <100185149+Megha-Dev-19@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:05:37 +0530 Subject: [PATCH 1/2] added tests --- .../widget/components/DropDown.jsx | 1 + .../widget/pages/settings/Thresholds.jsx | 24 +- .../members/create-threshold-request.spec.js | 197 ++++++++++++++++ playwright-tests/util/rpcmock.js | 222 +++++++++--------- 4 files changed, 329 insertions(+), 115 deletions(-) create mode 100644 playwright-tests/tests/members/create-threshold-request.spec.js diff --git a/instances/treasury-devdao.near/widget/components/DropDown.jsx b/instances/treasury-devdao.near/widget/components/DropDown.jsx index 48fafee6..7ea4b27f 100644 --- a/instances/treasury-devdao.near/widget/components/DropDown.jsx +++ b/instances/treasury-devdao.near/widget/components/DropDown.jsx @@ -49,6 +49,7 @@ return ( type="button" data-bs-toggle="dropdown" aria-expanded="false" + data-testid="dropdown-btn" > {selected.label} diff --git a/instances/treasury-devdao.near/widget/pages/settings/Thresholds.jsx b/instances/treasury-devdao.near/widget/pages/settings/Thresholds.jsx index 521a1553..f4e4a834 100644 --- a/instances/treasury-devdao.near/widget/pages/settings/Thresholds.jsx +++ b/instances/treasury-devdao.near/widget/pages/settings/Thresholds.jsx @@ -10,6 +10,9 @@ const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || { href: () => {}, }; +if (typeof getRoleWiseData !== "function") { + return <>>; +} const [selectedGroup, setSelectedGroup] = useState(null); const [selectedVoteOption, setSelectedVoteOption] = useState(null); const [selectedVoteValue, setSelectedVoteValue] = useState(null); @@ -57,9 +60,9 @@ function getLastProposalId() { } useEffect(() => { - if (typeof getRoleWiseData === "function") { - getRoleWiseData(treasuryDaoID).then((resp) => setRolesData(resp)); - } + getRoleWiseData(treasuryDaoID).then((resp) => { + setRolesData(resp); + }); }, [refreshData]); useEffect(() => { @@ -230,7 +233,7 @@ function updateDaoPolicy() { weight_kind: "RoleWeight", quorum: "0", threshold: isPercentageSelected - ? [selectedVoteValue, 100] + ? [parseInt(selectedVoteValue), 100] : selectedVoteValue, }; return policy; @@ -350,7 +353,7 @@ return ( instance, heading: "Are you sure?", content: ( -