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

[#2062] change CC vote totals labels #2078

Merged
merged 1 commit into from
Sep 26, 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 @@ -20,7 +20,7 @@ changes.

### Changed

-
- Change constitutional committee vote totals to be constitutional for yes and unconstitutional for no [Issue 2062](https://github.com/IntersectMBO/govtool/issues/2062)

### Removed

Expand Down
384 changes: 217 additions & 167 deletions govtool/frontend/junit-report.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions govtool/frontend/src/components/atoms/VotePill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VotePill } from "@atoms";
describe("VotePill", () => {
it('renders the VotePill component with "yes" vote correctly', () => {
const { getByText } = render(<VotePill vote="yes" />);
const voteText = getByText("yes");
const voteText = getByText("Yes");
expect(voteText).toBeInTheDocument();
expect(voteText.parentNode).toHaveStyle({
borderColor: "#C0E4BA",
Expand All @@ -15,7 +15,7 @@ describe("VotePill", () => {

it('renders the VotePill component with "no" vote correctly', () => {
const { getByText } = render(<VotePill vote="no" />);
const voteText = getByText("no");
const voteText = getByText("No");
expect(voteText).toBeInTheDocument();
expect(voteText.parentNode).toHaveStyle({
borderColor: "#EDACAC",
Expand All @@ -25,7 +25,7 @@ describe("VotePill", () => {

it('renders the VotePill component with "abstain" vote correctly', () => {
const { getByText } = render(<VotePill vote="abstain" />);
const voteText = getByText("abstain");
const voteText = getByText("Abstain");
expect(voteText).toBeInTheDocument();
expect(voteText.parentNode).toHaveStyle({
borderColor: "#99ADDE",
Expand Down
18 changes: 16 additions & 2 deletions govtool/frontend/src/components/atoms/VotePill.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTranslation } from "react-i18next";
import { Box, Typography } from "@mui/material";

import { Vote } from "@models";
Expand All @@ -6,12 +7,15 @@ export const VotePill = ({
vote,
width,
maxWidth,
isCC,
}: {
vote: Vote;
width?: number;
maxWidth?: number;
isCC?: boolean;
}) => {
const VOTE = vote.toLowerCase();
const { t } = useTranslation();
const VOTE = vote.toLowerCase() as "yes" | "no" | "abstain";
return (
<Box
py={0.75}
Expand All @@ -36,7 +40,17 @@ export const VotePill = ({
fontWeight={400}
lineHeight="16px"
>
{vote}
{t(
`votes.${
isCC
? VOTE === "yes"
? "constitutional"
: vote === "no"
? "unconstitutional"
: VOTE
: VOTE
}`,
)}
</Typography>
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const VoteActionForm = ({
name="vote"
register={registerInput}
setValue={setValue}
title={t("yes")}
title={t("votes.yes")}
value="yes"
disabled={isInProgress}
/>
Expand All @@ -180,7 +180,7 @@ export const VoteActionForm = ({
name="vote"
register={registerInput}
setValue={setValue}
title={t("no")}
title={t("votes.no")}
value="no"
disabled={isInProgress}
/>
Expand All @@ -190,7 +190,7 @@ export const VoteActionForm = ({
name="vote"
register={registerInput}
setValue={setValue}
title={t("abstain")}
title={t("votes.abstain")}
value="abstain"
disabled={isInProgress}
/>
Expand Down
10 changes: 6 additions & 4 deletions govtool/frontend/src/components/molecules/VotesSubmitted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ export const VotesSubmitted = ({
);
};

type VoterType = "ccCommittee" | "dReps" | "sPos";

type VotesGroupProps = {
type: "ccCommittee" | "dReps" | "sPos";
type: VoterType;
yesVotes: number;
noVotes: number;
abstainVotes: number;
Expand Down Expand Up @@ -127,8 +129,8 @@ const VotesGroup = ({
};

type VoteProps = {
type: "ccCommittee" | "dReps" | "sPos";
vote: "yes" | "no" | "abstain";
type: VoterType;
vote: VoteType;
value: number;
};
const Vote = ({ type, vote, value }: VoteProps) => (
Expand All @@ -140,7 +142,7 @@ const Vote = ({ type, vote, value }: VoteProps) => (
columnGap: 1.5,
}}
>
<VotePill vote={vote} maxWidth={82} />
<VotePill vote={vote} width={115} isCC={type === "ccCommittee"} />
<Typography
data-testid={`submitted-votes-${type}-${vote}`}
sx={{
Expand Down
10 changes: 7 additions & 3 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,14 @@ export const en = {
notVerifiable: "Data Not Verifiable",
incorrectFormat: "Data Formatted Incorrectly",
},
votes: {
abstain: "Abstain",
constitutional: "Constitutional",
no: "No",
unconstitutional: "Unconstitutional",
yes: "Yes",
},
about: "About",
abstain: "Abstain",
addLink: "+ Add link",
back: "Back",
backToDashboard: "Back to dashboard",
Expand Down Expand Up @@ -854,7 +860,6 @@ export const en = {
myDRepId: "My DRep ID:",
nextStep: "Next step",
network: "Network",
no: "No",
ok: "Ok",
optional: "Optional",
register: "Register",
Expand All @@ -872,7 +877,6 @@ export const en = {
thisLink: "this link",
viewDetails: "View details",
votingPower: "Voting power",
yes: "Yes",
yourself: "Yourself",
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export const GovernanceActionDetailsCardComponent: Story = {
await assertTooltip(tooltip1, /Submission Date/i);
await assertTooltip(tooltip2, /Expiry Date/i);

await expect(canvas.getAllByText(/Yes/i)).toHaveLength(3);
await expect(canvas.getAllByText(/Abstain/i)).toHaveLength(3);
await expect(canvas.getAllByText(/No/i)).toHaveLength(3);
await expect(canvas.getAllByText(/yes/i)).toHaveLength(2);
await expect(canvas.getAllByText(/abstain/i)).toHaveLength(3);
await expect(canvas.getAllByText(/no/i)).toHaveLength(2);
},
};

Expand Down
6 changes: 3 additions & 3 deletions govtool/frontend/src/stories/VotePill.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const VotePillYes: Story = {
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(canvas.getByText(/yes/i)).toBeInTheDocument();
await expect(canvas.getByText(/Yes/i)).toBeInTheDocument();
},
};

Expand All @@ -35,7 +35,7 @@ export const VotePillNo: Story = {
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(canvas.getByText(/no/i)).toBeInTheDocument();
await expect(canvas.getByText(/No/i)).toBeInTheDocument();
},
};

Expand All @@ -45,6 +45,6 @@ export const VotePillAbstain: Story = {
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(canvas.getByText(/abstain/i)).toBeInTheDocument();
await expect(canvas.getByText(/Abstain/i)).toBeInTheDocument();
},
};
Loading