From 315814641c1893fc7a99627b575f51c09b591754 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Thu, 8 Aug 2024 12:57:14 +0200 Subject: [PATCH] [#1050] Add missing data-testid attributes --- CHANGELOG.md | 1 + .../src/components/molecules/Card.tsx | 3 ++ .../molecules/DashboardActionCard.tsx | 31 +++++++++++-------- .../DashboardCards/DRepDashboardCard.tsx | 3 +- .../DashboardCards/DelegateDashboardCard.tsx | 1 + .../DirectVoterDashboardCard.tsx | 8 +++-- .../ListGovActionsDashboardCard.tsx | 3 +- .../ProposeGovActionDashboardCard.tsx | 3 +- .../EditDRepStorageInformation.tsx | 1 + .../src/components/organisms/HomeCards.tsx | 7 +++-- .../VoteContextStoringInformation.tsx | 2 ++ .../src/stories/DashboardCard.stories.tsx | 3 ++ 12 files changed, 45 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49ca53e2a..95b1f56bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ changes. - Fix displaying incorrect connected to Voltaire GovTool network - Runtime error at /edit_drep when metadata incorrect [Issue 1675](https://github.com/IntersectMBO/govtool/issues/1675) - Restrict access to registration routes when user s already registered and to retirement routes when the use is not registered [Issue 1183](https://github.com/IntersectMBO/govtool/issues/1183) +- Add missing data-testid attributes [Issue 1050](https://github.com/IntersectMBO/govtool/issues/1050) ### Changed diff --git a/govtool/frontend/src/components/molecules/Card.tsx b/govtool/frontend/src/components/molecules/Card.tsx index 35682a287..6e18617b1 100644 --- a/govtool/frontend/src/components/molecules/Card.tsx +++ b/govtool/frontend/src/components/molecules/Card.tsx @@ -9,6 +9,7 @@ type CardProps = PropsWithChildren & { elevation?: number; dataTestId?: string; label?: string; + labelDataTestId?: string; sx?: SxProps; variant?: "default" | "error" | "primary" | "success" | "warning"; onCardClick?: () => void; @@ -44,6 +45,7 @@ export const Card = ({ children, elevation = 3, label, + labelDataTestId = "card-label", sx, onCardClick, }: CardProps) => { @@ -66,6 +68,7 @@ export const Card = ({ > {label && ( = ({ - ...props + buttons, + children, + description, + imageURL, + isLoading = false, + isInProgressOnCard = true, + state = "default", + title, + type, + transactionId, + isSpaceBetweenButtons, }) => { const { t } = useTranslation(); const { cExplorerBaseUrl } = useAppContext(); - const { - buttons, - children, - description, - imageURL, - isLoading = false, - isInProgressOnCard = true, - state = "default", - title, - transactionId, - isSpaceBetweenButtons, - } = props; const { screenWidth } = useScreenDimension(); @@ -50,6 +54,7 @@ export const DashboardActionCard: FC = ({ {...(state === "inProgress" && { border: true, label: t("inProgress"), + labelDataTestId: `${type}-in-progress`, variant: "warning", })} sx={{ diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx index 7948adfd0..dfebf5c05 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DRepDashboardCard.tsx @@ -34,7 +34,7 @@ export const DRepDashboardCard = ({ const learnMoreButton = { children: t("learnMore"), - dataTestId: "register-learn-more-button", + dataTestId: "d-rep-learn-more-button", onClick: () => openInNewTab( "https://docs.sanchogov.tools/how-to-use-the-govtool/using-govtool/dreps", @@ -149,6 +149,7 @@ export const DRepDashboardCard = ({ return ( {voter?.isRegisteredAsDRep && !pendingTransaction?.retireAsDrep && ( diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx index 69902788c..be9cb1071 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx @@ -149,6 +149,7 @@ export const DelegateDashboardCard = ({ ? delegateTx?.transactionHash ?? currentDelegation?.txHash : undefined } + type="delegate" {...cardProps} > {displayedDelegationId && diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DirectVoterDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DirectVoterDashboardCard.tsx index aa980af2d..17a11437a 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DirectVoterDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DirectVoterDashboardCard.tsx @@ -28,7 +28,7 @@ export const DirectVoterDashboardCard = ({ // learn more button const learnMoreButton: LoadingButtonProps = { children: t("learnMore"), - dataTestId: "learn-more-button", + dataTestId: "direct-voter-learn-more-button", onClick: () => openInNewTab( "https://docs.sanchogov.tools/how-to-use-the-govtool/using-govtool/direct-voting", @@ -135,6 +135,10 @@ export const DirectVoterDashboardCard = ({ })(); return ( - + ); }; diff --git a/govtool/frontend/src/components/organisms/DashboardCards/ListGovActionsDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/ListGovActionsDashboardCard.tsx index aab4b88d3..d3590e50c 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/ListGovActionsDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/ListGovActionsDashboardCard.tsx @@ -20,7 +20,7 @@ export const ListGovActionsDashboardCards = () => { }, { children: t("learnMore"), - dataTestId: "learn-more-governance-actions-button", + dataTestId: "list-gov-actions-learn-more-button", onClick: () => openInNewTab( "https://docs.sanchogov.tools/how-to-use-the-govtool/using-govtool/governance-actions", @@ -31,6 +31,7 @@ export const ListGovActionsDashboardCards = () => { description={t("dashboard.cards.govActions.description")} imageURL={IMAGES.govActionListImage} title={t("dashboard.cards.govActions.title")} + type="list-gov-actions" /> ); }; diff --git a/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx index ad25dc66b..3c362653e 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/ProposeGovActionDashboardCard.tsx @@ -51,7 +51,7 @@ export const ProposeGovActionDashboardCard = ({ // common { children: t("learnMore"), - dataTestId: "learn-more-button", + dataTestId: "propose-gov-action-learn-more-button", onClick: () => openInNewTab( "https://docs.sanchogov.tools/how-to-use-the-govtool/using-govtool/governance-actions/propose-a-governance-action", @@ -64,6 +64,7 @@ export const ProposeGovActionDashboardCard = ({ transactionId={createGovActionTx?.transactionHash} state={createGovActionTx ? "inProgress" : "default"} title={t("dashboard.cards.proposeGovernanceAction.title")} + type="propose-gov-action" /> ); }; diff --git a/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepStorageInformation.tsx b/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepStorageInformation.tsx index 1a7486661..38ca2ba4c 100644 --- a/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepStorageInformation.tsx +++ b/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepStorageInformation.tsx @@ -77,6 +77,7 @@ export const EditDRepStorageInformation = ({ } diff --git a/govtool/frontend/src/components/organisms/HomeCards.tsx b/govtool/frontend/src/components/organisms/HomeCards.tsx index 6539c3e54..088f633f3 100644 --- a/govtool/frontend/src/components/organisms/HomeCards.tsx +++ b/govtool/frontend/src/components/organisms/HomeCards.tsx @@ -103,7 +103,7 @@ export const HomeCards = () => { {/* REGISTER AS DREP CARD */} openWalletModal(PATHS.registerAsdRep)} firstButtonLabel={t("home.cards.registerAsDRep.firstButtonLabel")} @@ -117,8 +117,8 @@ export const HomeCards = () => { {/* REGISTER AS DREP CARD END */} {/* REGISTER AS DIRECT VOTER CARD */} openWalletModal(PATHS.registerAsDirectVoter)} firstButtonLabel={t( @@ -147,6 +147,7 @@ export const HomeCards = () => { {/* PROPOSE GOV ACTION CARD */} openWalletModal(PATHS.createGovernanceAction)} firstButtonLabel={t( diff --git a/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx b/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx index d5a583f37..50a051714 100644 --- a/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx +++ b/govtool/frontend/src/components/organisms/VoteContext/VoteContextStoringInformation.tsx @@ -78,6 +78,7 @@ export const VoteContextStoringInformation = ({ } @@ -127,6 +128,7 @@ export const VoteContextStoringInformation = ({ component={