Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#1863): add missing DRep Details test IDs #1886

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ changes.

### Added

-
- Add missing test DRep Details test IDs [Issue 1863](https://github.com/IntersectMBO/govtool/issues/1863)

### Fixed

Expand Down
88 changes: 71 additions & 17 deletions govtool/frontend/src/pages/DRepDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,16 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => {
url={url}
/>
)}
<DRepDetailsInfoItem label={t("drepId")}>
<CopyableText value={view} />
<DRepDetailsInfoItem label={t("drepId")} dataTestId="drep-id">
<CopyableText value={view} dataTestId="copy-drep-id-button" />
</DRepDetailsInfoItem>
<DRepDetailsInfoItem label={t("status")}>
<DRepDetailsInfoItem label={t("status")} dataTestId="drep-status">
<StatusPill status={status} />
</DRepDetailsInfoItem>
<DRepDetailsInfoItem label={t("votingPower")}>
<DRepDetailsInfoItem
label={t("votingPower")}
dataTestId="drep-voting-power"
>
<Typography
data-testid="voting-power"
sx={{ display: "flex", flexDirection: "row", mt: 0.5 }}
Expand All @@ -255,11 +258,22 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => {
{correctAdaFormat(votingPower)}
</Typography>
</DRepDetailsInfoItem>
<DRepDetailsInfoItem label={t("forms.dRepData.paymentAddress")}>
{paymentAddress && <CopyableText value={paymentAddress} />}
<DRepDetailsInfoItem
label={t("forms.dRepData.paymentAddress")}
dataTestId="payment-address"
>
{paymentAddress && (
<CopyableText
value={paymentAddress}
dataTestId="copy-payment-address-button"
/>
)}
</DRepDetailsInfoItem>
{references?.length > 0 && !metadataStatus && (
<DRepDetailsInfoItem label={t("moreInformation")}>
<DRepDetailsInfoItem
label={t("moreInformation")}
dataTestId="more-information"
>
<Box
alignItems="flex-start"
display="flex"
Expand Down Expand Up @@ -319,13 +333,22 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => {
</Button>
)}
</Box>
<DRepDetailsDescriptionItem label={t("forms.dRepData.objectives")}>
<DRepDetailsDescriptionItem
label={t("forms.dRepData.objectives")}
dataTestId="objectives"
>
{objectives}
</DRepDetailsDescriptionItem>
<DRepDetailsDescriptionItem label={t("forms.dRepData.motivations")}>
<DRepDetailsDescriptionItem
label={t("forms.dRepData.motivations")}
dataTestId="motivations"
>
{motivations}
</DRepDetailsDescriptionItem>
<DRepDetailsDescriptionItem label={t("forms.dRepData.qualifications")}>
<DRepDetailsDescriptionItem
label={t("forms.dRepData.qualifications")}
dataTestId="qualifications"
>
{qualifications}
</DRepDetailsDescriptionItem>
</Card>
Expand All @@ -341,18 +364,34 @@ const ellipsisStyles = {

type DrepDetailsInfoItemProps = PropsWithChildren & {
label: string;
dataTestId: string;
};

const DRepDetailsInfoItem = ({ children, label }: DrepDetailsInfoItemProps) => {
const dataTestIdInfoItemCategoryPrefix = "info-item";

const DRepDetailsInfoItem = ({
children,
label,
dataTestId,
}: DrepDetailsInfoItemProps) => {
if (!children) return null;
return (
<>
<Box component="dt" sx={{ mb: 0.5, "&:not(:first-of-type)": { mt: 2 } }}>
<Typography color="neutralGray" fontWeight={600} variant="body2">
<Typography
color="neutralGray"
fontWeight={600}
variant="body2"
data-testid={`${dataTestId}-${dataTestIdInfoItemCategoryPrefix}-title`}
>
{label}
</Typography>
</Box>
<Box component="dd" m={0}>
<Box
component="dd"
m={0}
data-testid={`${dataTestId}-${dataTestIdInfoItemCategoryPrefix}-description`}
>
{children}
</Box>
</>
Expand All @@ -362,27 +401,42 @@ const DRepDetailsInfoItem = ({ children, label }: DrepDetailsInfoItemProps) => {
const DRepDetailsDescriptionItem = ({
children,
label,
dataTestId,
}: DrepDetailsInfoItemProps) => {
if (!children) return null;
return (
<>
<Typography variant="title2" sx={{ mb: 1.5, mt: 5.75 }}>
<Typography
variant="title2"
sx={{ mb: 1.5, mt: 5.75 }}
data-testid={`${dataTestId}-title`}
>
{label}
</Typography>
<Typography fontWeight={400} sx={{ maxWidth: 608 }} variant="body1">
<Typography
fontWeight={400}
sx={{ maxWidth: 608 }}
variant="body1"
data-testid={`${dataTestId}-description`}
>
{children}
</Typography>
</>
);
};

const CopyableText = ({ value }: { value: string }) => (
type CopyableTextProps = {
value: string;
dataTestId: string;
};

const CopyableText = ({ value, dataTestId }: CopyableTextProps) => (
<ButtonBase
onClick={(e) => {
navigator.clipboard.writeText(value.toString());
e.stopPropagation();
}}
data-testid="copy-drep-id-button"
data-testid={dataTestId}
sx={{
gap: 1,
maxWidth: "100%",
Expand Down
Loading