Skip to content

Commit

Permalink
[#1050] Add missing data-testid attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dyczka committed Aug 8, 2024
1 parent 7492ac3 commit 25a998f
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 21 deletions.
3 changes: 3 additions & 0 deletions govtool/frontend/src/components/molecules/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type CardProps = PropsWithChildren & {
elevation?: number;
dataTestId?: string;
label?: string;
labelDataTestId?: string;
sx?: SxProps<Theme>;
variant?: "default" | "error" | "primary" | "success" | "warning";
onCardClick?: () => void;
Expand Down Expand Up @@ -44,6 +45,7 @@ export const Card = ({
children,
elevation = 3,
label,
labelDataTestId = "card-label",
sx,
onCardClick,
}: CardProps) => {
Expand All @@ -66,6 +68,7 @@ export const Card = ({
>
{label && (
<Chip
data-testid={labelDataTestId}
color={variant}
label={label}
sx={{
Expand Down
31 changes: 18 additions & 13 deletions govtool/frontend/src/components/molecules/DashboardActionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@ export type DashboardActionCardProps = {
state?: "active" | "inProgress" | "default";
title?: ReactNode;
transactionId?: string | null;
type:
| "delegate"
| "d-rep"
| "direct-voter"
| "list-gov-actions"
| "propose-gov-action";
isSpaceBetweenButtons?: boolean;
};

export const DashboardActionCard: FC<DashboardActionCardProps> = ({
...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();

Expand All @@ -50,6 +54,7 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
{...(state === "inProgress" && {
border: true,
label: t("inProgress"),
labelDataTestId: `${type}-in-progress`,
variant: "warning",
})}
sx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -149,6 +149,7 @@ export const DRepDashboardCard = ({
return (
<DashboardActionCard
imageURL={IMAGES.govActionRegisterImage}
type="d-rep"
{...cardProps}
>
{voter?.isRegisteredAsDRep && !pendingTransaction?.retireAsDrep && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const DelegateDashboardCard = ({
? delegateTx?.transactionHash ?? currentDelegation?.txHash
: undefined
}
type="delegate"
{...cardProps}
>
{displayedDelegationId &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -135,6 +135,10 @@ export const DirectVoterDashboardCard = ({
})();

return (
<DashboardActionCard imageURL={IMAGES.directVoterImage} {...cardProps} />
<DashboardActionCard
imageURL={IMAGES.directVoterImage}
type="direct-voter"
{...cardProps}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -64,6 +64,7 @@ export const ProposeGovActionDashboardCard = ({
transactionId={createGovActionTx?.transactionHash}
state={createGovActionTx ? "inProgress" : "default"}
title={t("dashboard.cards.proposeGovernanceAction.title")}
type="propose-gov-action"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const EditDRepStorageInformation = ({
<BgCard
actionButtonLabel={t("submit")}
backButtonLabel={t("back")}
actionButtonDataTestId="submit-button"
isActionButtonDisabled={isActionButtonDisabled}
onClickActionButton={editDRepInfo}
onClickBackButton={onClickBack}
Expand Down Expand Up @@ -84,6 +85,7 @@ export const EditDRepStorageInformation = ({
<Step
component={
<Button
data-testid="metadata-download-button"
onClick={onClickDownloadJson}
size="extraLarge"
startIcon={<img alt="download" src={ICONS.download} />}
Expand Down
7 changes: 4 additions & 3 deletions govtool/frontend/src/components/organisms/HomeCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const HomeCards = () => {
{/* REGISTER AS DREP CARD */}
<ActionCard
dataTestIdFirstButton="register-connect-wallet-button"
dataTestIdSecondButton="register-learn-more-button"
dataTestIdSecondButton="d-rep-learn-more-button"
description={t("home.cards.registerAsDRep.description")}
firstButtonAction={() => openWalletModal(PATHS.registerAsdRep)}
firstButtonLabel={t("home.cards.registerAsDRep.firstButtonLabel")}
Expand All @@ -117,8 +117,8 @@ export const HomeCards = () => {
{/* REGISTER AS DREP CARD END */}
{/* REGISTER AS DIRECT VOTER CARD */}
<ActionCard
dataTestIdFirstButton="register-as-sole-voter-button"
dataTestIdSecondButton="lear-more-about-sole-voter-button"
dataTestIdFirstButton="register-as-direct-voter-button"
dataTestIdSecondButton="direct-voter-learn-more-button"
description={t("home.cards.registerAsDirectVoter.description")}
firstButtonAction={() => openWalletModal(PATHS.registerAsDirectVoter)}
firstButtonLabel={t(
Expand Down Expand Up @@ -147,6 +147,7 @@ export const HomeCards = () => {
{/* PROPOSE GOV ACTION CARD */}
<ActionCard
dataTestIdFirstButton="propose-a-governance-action-button"
dataTestIdSecondButton="view-proposals-button"
description={t("home.cards.proposeAGovernanceAction.description")}
firstButtonAction={() => openWalletModal(PATHS.createGovernanceAction)}
firstButtonLabel={t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const VoteContextStoringInformation = ({
<Step
component={
<Button
data-testid="metadata-download-button"
onClick={onClickDownloadJson}
size="extraLarge"
startIcon={<img alt="download" src={ICONS.download} />}
Expand Down Expand Up @@ -127,6 +128,7 @@ export const VoteContextStoringInformation = ({
component={
<ControlledField.Input
{...{ control, errors }}
dataTestId="metadata-url-input"
name="storingURL"
layoutStyles={{ mt: 1.5 }}
placeholder={t(
Expand Down

0 comments on commit 25a998f

Please sign in to comment.