Skip to content
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 .github/workflows/build-from-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
-H "Authorization: Token ${{ secrets.QOVERY_API_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"image_name": "${{ steps.image_lowercase.outputs.lowercase }}-${{ env.CLEAN_NETWORK }}",
"image_name": "intersectmbo/${{ matrix.name }}-${{ env.CLEAN_NETWORK }}",
"tag": "${{ env.COMMIT_TAG }}"
}'

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ changes.

### Changed
- Adjust top menu (navbar) layout when wallet is not connected [Issue-3682](https://github.com/IntersectMBO/govtool/issues/3682)
- Unification of sections 'Receiving Address' and 'Amount' in Treasury Withdrawal Governance Action [Issue-3828](https://github.com/IntersectMBO/govtool/issues/3828)

### Removed

Expand Down
24 changes: 13 additions & 11 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,19 @@ SELECT
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
off_chain_vote_data.json as json_content,
COALESCE(
json_agg(
json_build_object(
'name', off_chain_vote_author.name,
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
'publicKey', off_chain_vote_author.public_key,
'signature', off_chain_vote_author.signature
)
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
'[]'
) authors
(
SELECT jsonb_agg(
jsonb_build_object(
'name', author_elem->>'name',
'publicKey', author_elem->'witness'->>'publicKey',
'signature', author_elem->'witness'->>'signature',
'witnessAlgorithm', author_elem->'witness'->>'witnessAlgorithm'
)
)
FROM jsonb_array_elements(off_chain_vote_data.json->'authors') AS author_elem
),
'[]'::jsonb
) AS authors
FROM
gov_action_proposal
JOIN ActiveProposals ON gov_action_proposal.id = ActiveProposals.id
Expand All @@ -326,7 +329,6 @@ FROM
LEFT JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
lEFT JOIN off_chain_vote_author ON off_chain_vote_author.off_chain_vote_data_id = off_chain_vote_data.id
LEFT JOIN off_chain_vote_gov_action_data ON off_chain_vote_gov_action_data.off_chain_vote_data_id = off_chain_vote_data.id
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Box } from "@mui/material";
import { useTranslation } from "react-i18next";

import { Typography, CopyButton } from "@atoms";
import { correctVoteAdaFormat } from "@utils";

import { useScreenDimension } from "@/hooks";
import { GovernanceActionCardElement } from "./GovernanceActionCardElement";

type Props = {
receivingAddress: string;
Expand All @@ -16,87 +13,22 @@ export const GovernanceActionCardTreasuryWithdrawalElement = ({
amount,
}: Props) => {
const { t } = useTranslation();
const { isMobile } = useScreenDimension();

return (
<Box
sx={{
display: "flex",
mb: "4px",
flexDirection: "column",
}}
>
<Box sx={{ display: "flex", flexDirection: isMobile ? "column" : "row" }}>
<Typography
data-testid="receiving-address-label"
sx={{
width: "160px",
fontSize: 14,
fontWeight: 600,
lineHeight: "20px",
color: "neutralGray",
}}
>
{t("govActions.receivingAddress")}
</Typography>
<Box
sx={{
display: "flex",
alignItems: "center",
overflow: "hidden",
flexDirection: "row",
}}
>
<Typography
data-testid="receiving-address"
sx={{
ml: isMobile ? 0 : 8,
color: "primaryBlue",
fontSize: 16,
fontWeight: 400,
lineHeight: "20px",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
{receivingAddress}
</Typography>
<Box ml={1}>
<CopyButton text={receivingAddress} variant="blueThin" />
</Box>
</Box>
</Box>
<Box
sx={{
display: "flex",
flexDirection: isMobile ? "column" : "row",
mt: "6px",
}}
>
<Typography
sx={{
width: "160px",
fontSize: 14,
fontWeight: 600,
lineHeight: "20px",
color: "neutralGray",
}}
data-testid="amount-label"
>
{t("govActions.amount")}
</Typography>
<Typography
data-testid="amount"
sx={{
ml: isMobile ? 0 : 8,
fontSize: 16,
fontWeight: 400,
lineHeight: "20px",
}}
>
₳ {correctVoteAdaFormat(amount) ?? 0}
</Typography>
</Box>
</Box>
<>
<GovernanceActionCardElement
label={t("govActions.receivingAddress")}
text={receivingAddress}
textVariant="oneLine"
dataTestId="receiving-address-label"
isCopyButton
/>
<GovernanceActionCardElement
label={t("govActions.amount")}
text={`₳ ${correctVoteAdaFormat(amount) ?? 0}`}
textVariant="oneLine"
dataTestId="amount"
/>
</>
);
};
1 change: 1 addition & 0 deletions tests/govtool-frontend/playwright/lib/constants/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const proposal06AuthFile = ".auth/proposal06.json";
export const proposal07AuthFile = ".auth/proposal07.json";
export const proposal08AuthFile = ".auth/proposal08.json";
export const proposal09AuthFile = ".auth/proposal09.json";
export const proposal10AuthFile = ".auth/proposal10.json";

export const proposalSubmissionAuthFile = ".auth/proposalSubmission.json";

Expand Down
4 changes: 2 additions & 2 deletions tests/govtool-frontend/playwright/lib/constants/docsUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const ABSTAIN_VOTE_DOC_URL = `${environments.docsUrl}/using-govtool/deleg
export const SIGNAL_NO_CONFIDENCE_VOTE_DOC_URL = `${environments.docsUrl}/using-govtool/delegating/signal-no-confidence-on-every-vote`;
export const FAQS_DOC_URL = `${environments.docsUrl}/faqs`;
export const GUIDES_DOC_URL = `${environments.docsUrl}/using-govtool`;
export const PRIVACY_POLICY = `https://docs.intersectmbo.org/legal/policies-and-conditions/privacy-policy`;
export const TERMS_AND_CONDITIONS = `https://docs.intersectmbo.org/legal/policies-and-conditions/terms-of-use`;
export const PRIVACY_POLICY = `https://docs.intersectmbo.org/legal/policies-and-conditions/intersect-members-policies/privacy-policy`;
export const TERMS_AND_CONDITIONS = `https://docs.intersectmbo.org/legal/policies-and-conditions/intersect-internal-policies/terms-of-use`;
export const HELP_DOC_URL = `${environments.docsUrl}/support`;
export const BOOTSTRAP_DOC_URL = `${environments.docsUrl}/faqs/bootstrapping-phase`;
11 changes: 6 additions & 5 deletions tests/govtool-frontend/playwright/lib/constants/staticWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export const proposal06Wallet: StaticWallet = staticWallets[15];
export const proposal07Wallet: StaticWallet = staticWallets[16];
export const proposal08Wallet: StaticWallet = staticWallets[17];
export const proposal09Wallet: StaticWallet = staticWallets[18];
export const proposal10Wallet: StaticWallet = staticWallets[19];

export const budgetProposal01Wallet: StaticWallet = staticWallets[19];
export const budgetProposal02Wallet: StaticWallet = staticWallets[20];
export const budgetProposal03Wallet: StaticWallet = staticWallets[21];
export const budgetProposal04Wallet: StaticWallet = staticWallets[22];
export const budgetProposal05Wallet: StaticWallet = staticWallets[23];
export const budgetProposal01Wallet: StaticWallet = staticWallets[20];
export const budgetProposal02Wallet: StaticWallet = staticWallets[21];
export const budgetProposal03Wallet: StaticWallet = staticWallets[22];
export const budgetProposal04Wallet: StaticWallet = staticWallets[23];
export const budgetProposal05Wallet: StaticWallet = staticWallets[24];

export const adaHolderWallets = [
adaHolder01Wallet,
Expand Down
7 changes: 7 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
proposal07Wallet,
proposal08Wallet,
proposal09Wallet,
proposal10Wallet,
} from "@constants/staticWallets";
import {
proposal05AuthFile,
proposal07AuthFile,
proposal08AuthFile,
proposal09AuthFile,
proposal10AuthFile,
} from "@constants/auth";

interface CreateUserProps {
Expand Down Expand Up @@ -122,5 +124,10 @@ export const getDraftProposalWalletAndState = (proposalType: string) => {
storageState: proposal09AuthFile,
wallet: proposal09Wallet,
};
case ProposalType.hardFork:
return {
storageState: proposal10AuthFile,
wallet: proposal10Wallet,
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const formErrors = {
constitutionalUrl: "prop-constitution-url-text-error",
guardrailsScriptUrl: "prop-guardrails-script-url-input-error",
link: "link-0-url-input-error",
majorError: "major-error",
minorError: "minor-error",
};

export default class ProposalSubmissionPage {
Expand Down Expand Up @@ -61,6 +63,7 @@ export default class ProposalSubmissionPage {
readonly motionOfNoConfidenceBtn = this.page.getByTestId(
"motion of no confidence-button"
);
readonly hardForkBtn = this.page.getByTestId("hard fork-button");
readonly editSubmissionButton = this.page.getByTestId(
"edit-submission-button"
);
Expand Down Expand Up @@ -101,6 +104,12 @@ export default class ProposalSubmissionPage {
readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button");
readonly linkTextInput = this.page.getByTestId("link-0-text-input");
readonly linkUrlInput = this.page.getByTestId("link-0-url-input");
readonly previousGAHashInput = this.page.getByTestId(
"previous-ga-hash-input"
);
readonly previousGAIdInput = this.page.getByTestId("previous-ga-id-input");
readonly majorInput = this.page.getByTestId("major-input");
readonly minorInput = this.page.getByTestId("minor-input");

// content
readonly governanceActionTypeContent = this.page.getByTestId(
Expand All @@ -125,6 +134,8 @@ export default class ProposalSubmissionPage {
);
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
readonly linkUrlContent = this.page.getByTestId("link-0-url-content");
readonly majorVersionContent = this.page.getByTestId("major-version-content");
readonly minorVersionContent = this.page.getByTestId("minor-version-content");

constructor(private readonly page: Page) {}

Expand Down Expand Up @@ -172,9 +183,14 @@ export default class ProposalSubmissionPage {
if (governanceProposal.proposal_links != null) {
await this.fillProposalLinks(governanceProposal.proposal_links);
}

if (governanceProposal.gov_action_type_id == 4) {
await this.fillHardForkFields(governanceProposal);
}
}

async fillupForm(governanceProposal: ProposalCreateRequest) {
console.log(governanceProposal.gov_action_type_id);
await this.governanceActionType.click();

if (governanceProposal.gov_action_type_id === 0) {
Expand All @@ -186,8 +202,10 @@ export default class ProposalSubmissionPage {
if (governanceProposal.has_guardrails) {
await this.guardrailsScriptCheckbox.click();
}
} else {
} else if (governanceProposal.gov_action_type_id === 3) {
await this.motionOfNoConfidenceBtn.click();
} else {
await this.hardForkBtn.click();
}

await this.fillupFormWithTypeSelected(governanceProposal);
Expand Down Expand Up @@ -238,6 +256,11 @@ export default class ProposalSubmissionPage {
}
}

async fillHardForkFields(hardForkProposal: ProposalCreateRequest) {
await this.minorInput.fill(hardForkProposal.prop_min_version.toString());
await this.majorInput.fill(hardForkProposal.prop_major_version.toString());
}

async getAllDrafts() {
await expect(
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
Expand Down Expand Up @@ -345,6 +368,27 @@ export default class ProposalSubmissionPage {
}).toBeHidden();
}

if (governanceProposal.gov_action_type_id === 4) {
const isMajorErrorVisible = await this.page
.getByTestId(formErrors.majorError)
.isVisible();
const isMinorErrorVisible = await this.page
.getByTestId(formErrors.minorError)
.isVisible();

await expect(this.page.getByTestId(formErrors.majorError), {
message: isMajorErrorVisible
? "Major version error should be hidden"
: "Major version error is correctly hidden",
}).toBeHidden();

await expect(this.page.getByTestId(formErrors.minorError), {
message: isMinorErrorVisible
? "Minor version error should be hidden"
: "Minor version error is correctly hidden",
}).toBeHidden();
}

await expect(this.page.getByTestId(formErrors.link), {
message:
isLinkErrorVisible &&
Expand Down Expand Up @@ -457,6 +501,11 @@ export default class ProposalSubmissionPage {
}).toBeVisible();
}

if (governanceProposal.gov_action_type_id === 4) {
await expect(this.page.getByTestId(formErrors.majorError)).toBeVisible();
await expect(this.page.getByTestId(formErrors.minorError)).toBeVisible();
}

await expect(this.continueBtn).toBeDisabled();
}

Expand Down Expand Up @@ -512,6 +561,15 @@ export default class ProposalSubmissionPage {
}
}
}
if (proposalType == ProposalType.hardFork) {
proposal.prop_min_version = faker.number
.float({ min: 0, max: 100 })
.toString();
proposal.prop_major_version = faker.number
.float({ min: 0, max: 100 })
.toString();
}

return proposal;
}

Expand Down Expand Up @@ -546,6 +604,12 @@ export default class ProposalSubmissionPage {
proposal.prop_guardrails_script_url = invalid.url();
proposal.prop_guardrails_script_hash = faker.string.alphanumeric(64);
}

if (proposalType === ProposalType.hardFork) {
proposal.prop_min_version = invalid.amount();
proposal.prop_major_version = invalid.amount();
}

return proposal;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/govtool-frontend/playwright/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export enum ProposalType {
treasury = "Treasury requests",
updatesToTheConstitution = "Updates to the Constitution",
motionOfNoConfedence = "Motion of No Confidence",
hardFork = "Hard fork",
}

export enum BootstrapGovernanceActionType {
Expand Down Expand Up @@ -195,6 +196,8 @@ export type ProposalCreateRequest = {
prop_guardrails_script_hash?: string;
has_guardrails?: boolean;
is_draft: boolean;
prop_min_version?: string;
prop_major_version?: string;
};
export type ProposedGovAction = {
id: number;
Expand Down
Loading