Skip to content

Commit

Permalink
Merge pull request #1571 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
Fix gov-action-loader dependency, adjust NGINX config for authentication, and add missing PDF test IDs
  • Loading branch information
pmbinapps authored Jul 12, 2024
2 parents 0a8ee97 + 04ba789 commit 44a5c22
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 245 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/resync-cardano-node-and-db-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }}
DEV_NGINX_BASIC_AUTH: ${{ secrets.DEV_NGINX_BASIC_AUTH }}
TEST_NGINX_BASIC_AUTH: ${{ secrets.TEST_NGINX_BASIC_AUTH }}
STAGING_NGINX_BASIC_AUTH: ${{ secrets.STAGING_NGINX_BASIC_AUTH }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
TRAEFIK_LE_EMAIL: "[email protected]"
GTM_ID: ${{ secrets.GTM_ID }}
Expand Down
7 changes: 0 additions & 7 deletions gov-action-loader/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
FROM python:3.10 AS builder

WORKDIR /app
# Install cardano-cli

RUN \
wget https://github.com/input-output-hk/cardano-node/releases/download/8.5.0-pre/cardano-node-8.5.0-linux.tar.gz \
&& tar -xvzf cardano-node-8.5.0-linux.tar.gz \
&& mv ./cardano-cli /usr/local/bin/cardano-cli \
&& rm -rf /code/*

COPY ./requirements.txt ./requirements.txt
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt
Expand Down
6 changes: 3 additions & 3 deletions gov-action-loader/backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from app.settings import settings
from app.transaction import (get_base_proposal_for_multiple,
get_default_transaction,
get_proposal_data_from_type, get_txid_from_cli,
get_proposal_data_from_type,
main_wallet, submit_proposal_tx)

app = FastAPI()
Expand Down Expand Up @@ -106,7 +106,7 @@ async def submit_multiple_proposals(
else:
raise HTTPException(
status_code=400,
detail="No of proposals greater than 100 not supported yet.",
detail="No of proposals greater than "+str(maximum_supported_proposals)+" not supported yet.",
)


Expand Down Expand Up @@ -134,7 +134,7 @@ async def submit_single_proposal(
if kuber_response.status_code == 200:
tx = kuber_response.json()
tx["type"] = "Witnessed Tx ConwayEra"
tx_id = get_txid_from_cli(tx)
tx_id = tx['hash']
return tx | {"txId": tx_id}
else:
print(kuber_response.text)
Expand Down
49 changes: 5 additions & 44 deletions gov-action-loader/backend/app/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,38 +160,11 @@ def get_proposal_data_from_type(proposal_type, current_pParams):


def filter_updatable_paramKeys(keys):
updatable_keys = set(
[
"maxBlockSize",
"maxBBSize",
"maxTxSize",
"maxBHSize",
"keyDeposit",
"poolDeposit",
"eMax",
"nOpt",
"a0",
"rho",
"tau",
"minPoolCost",
"coinsPerUTxOByte",
"costModels",
"prices",
"maxTxExUnits",
"maxBlockExUnits",
"maxValSize",
"collateralPercentage",
"maxCollateralInputs",
"poolVotingThresholds",
"dRepVotingThresholds",
"committeeMinSize",
"committeeMaxTermLength",
"govActionLifetime",
"govActionDeposit",
"dRepDeposit",
"dRepActivity",
]
)
updatable_keys = {"maxBlockSize", "maxBBSize", "maxTxSize", "maxBHSize", "keyDeposit", "poolDeposit", "eMax",
"nOpt", "a0", "rho", "tau", "minPoolCost", "coinsPerUTxOByte", "costModels", "prices",
"maxTxExUnits", "maxBlockExUnits", "maxValSize", "collateralPercentage", "maxCollateralInputs",
"poolVotingThresholds", "dRepVotingThresholds", "committeeMinSize", "committeeMaxTermLength",
"govActionLifetime", "govActionDeposit", "dRepDeposit", "dRepActivity"}
return [x for x in keys if x in updatable_keys]


Expand Down Expand Up @@ -230,15 +203,3 @@ async def submit_proposal_tx(wallet, proposal, proposal_numbers, client):
"proposals": proposals,
}
return await submit_tx(tx, client)


def get_txid_from_cli(tx: Dict[str, Any]):
try:
with open("tx.raw", "w") as file:
json.dump(tx, file)
tx_id_command = "cardano-cli transaction txid --tx-file tx.raw"
tx_id_raw = subprocess.check_output(["bash", "-c", tx_id_command])
tx_id = tx_id_raw.decode("utf-8").strip()
return tx_id
finally:
os.remove("tx.raw")
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,41 @@ import { CommentResponse } from "@types";

export default class ProposalDiscussionDetailsPage {
// Buttons
readonly likeBtn = this.page.getByRole("button", {
name: "proposal likes",
});
readonly dislikeBtn = this.page.getByRole("button", {
name: "proposal dislikes",
});
readonly likeBtn = this.page.getByTestId("like-button");
readonly dislikeBtn = this.page.getByTestId("dislike-button");
readonly commentBtn = this.page.getByTestId("comment-button");
readonly addPollBtn = this.page.getByRole("button", { name: "Add Poll" }); // BUG missing test id
readonly replyCommentBtn = this.page.getByTestId("reply-comment-button");
readonly addPollBtn = this.page.getByTestId("add-poll-button");
readonly SubmitBtn = this.page.getByTestId("submit-button");
readonly menuBtn = this.page.getByTestId("menu-button");
readonly editProposalBtn = this.page.getByTestId("edit-proposal");
readonly deleteProposalBtn = this.page.getByTestId("delete-proposal");
readonly reviewVersionsBtn = this.page.getByTestId("review-versions");
readonly closePollBtn = this.page.getByRole("button", { name: "Close Poll" }); // BUG missing test id
readonly sortBtn = this.page
.locator("div")
.filter({ hasText: /^Comments$/ })
.getByRole("button"); // this.page.getByTestId("sort-button");
readonly closePollBtn = this.page.getByTestId("close-poll-button");
readonly sortBtn = this.page.getByTestId("sort-comments");
readonly proposeGovernanceAction = this.page.getByTestId("propose-GA-button");
readonly replyBtn = this.page.getByTestId("reply-button");
readonly pollYesBtn = this.page.getByRole("button", { name: "Yes" }); //BUG missing test id
readonly pollNoBtn = this.page.getByRole("button", { name: "No" }); //BUG missing test id
readonly pollYesBtn = this.page.getByTestId("poll-yes-button");
readonly pollNoBtn = this.page.getByTestId("poll-no-button");
readonly showReplyBtn = this.page.getByTestId("show-more-reply");
readonly closePollYesBtn = this.page.getByTestId("close-the-poll-button");
readonly changeVoteBtn = this.page.getByRole("button", {
name: "Change Vote",
});
readonly changeVoteBtn = this.page.getByTestId("change-vote-button");
readonly verifyIdentityBtn = this.page.getByRole("button", {
name: "Verify your identity",
});
}); // BUG
readonly submitAsGABtn = this.page.getByTestId("submit-as-GA-button");

// Indicators
readonly likesCounts = this.page.getByTestId("likes-count");
readonly dislikesCounts = this.page.getByTestId("dislikse-count");
readonly likeCount = this.likeBtn.getByTestId("like-count");
readonly dislikeCount = this.dislikeBtn.getByTestId("dislike-count");
readonly commentCount = this.page.getByTestId("comment-count");

// Cards
readonly pollVoteCard = this.page.getByTestId("poll-vote-card");
readonly pollResultCard = this.page.getByTestId("poll-result-card");
readonly commentCard =
this.proposeGovernanceAction.getByTestId("comment-card");

//inputs
readonly commentInput = this.page.getByRole("textbox");
readonly commentInput = this.page.getByTestId("comment-input");

constructor(private readonly page: Page) {}

Expand All @@ -68,13 +58,13 @@ export default class ProposalDiscussionDetailsPage {

async addComment(comment: string) {
await this.commentInput.fill(comment);
await this.page.getByTestId("comment-button").click();
await this.commentBtn.click();
}

async replyComment(reply: string) {
await this.page.getByRole("button", { name: "Reply" }).click();
await this.page.getByPlaceholder("Add comment").fill(reply);
await this.page.getByTestId("reply-comment-button").click();
await this.replyBtn.click();
await this.page.getByTestId("reply-input").fill(reply);
await this.replyCommentBtn.click();
}

async sortAndValidate(
Expand All @@ -101,13 +91,13 @@ export default class ProposalDiscussionDetailsPage {
}

async voteOnPoll(vote: string) {
await this.page.getByRole("button", { name: `${vote}` }).click();
await this.page.getByTestId(`poll-${vote.toLowerCase()}-button`).click();
}

async deleteProposal() {
await this.page.waitForTimeout(2_000);

await this.page.locator("#menu-button").click();
await this.page.getByTestId("menu-button").click();
await this.page.getByTestId("delete-proposal").click();
await this.page.getByTestId("delete-proposal-yes-button").click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@ import ProposalDiscussionDetailsPage from "./proposalDiscussionDetailsPage";

export default class ProposalDiscussionPage {
// Buttons
readonly proposalCreateBtn = this.page.getByRole("button", {
name: "Propose a Governance Action",
});
readonly continueBtn = this.page.getByRole("button", { name: "Continue" }); // #BUG test-id missing
readonly filterBtn = this.page.locator("#filters-button"); // this.page.getByTestId("filters-button");
readonly shareBtn = this.page
.locator(".MuiCardHeader-action > .MuiButtonBase-root")
.first(); //this.page.getByTestId("share-button");
readonly sortBtn = this.page.locator("button:nth-child(2)").first(); //this.page.getByTestId("sort-button");
readonly searchInput = this.page.getByPlaceholder("Search..."); // this.page.getByTestId("search-input");
readonly showAllBtn = this.page
.getByRole("button", { name: "Show all" })
.first(); //this.page.getByTestId("show-all-button");
readonly showLessBtn = this.page.getByRole("button", { name: "Show less" });
readonly infoRadio = this.page.getByLabel("Info");
readonly treasuryRadio = this.page.getByLabel("Treasury");
readonly proposalCreateBtn = this.page.getByTestId(
"propose-a-governance-action-button"
);
readonly continueBtn = this.page.getByTestId("continue-button");
readonly filterBtn = this.page.getByTestId("filter-button");
readonly sortBtn = this.page.getByTestId("sort-button");
readonly searchInput = this.page.getByTestId("search-input");
readonly showAllBtn = this.page.getByTestId("show-all-button").first(); //this.page.getByTestId("show-all-button");
readonly verifyIdentityBtn = this.page.getByRole("button", {
name: "Verify your identity",
});
readonly addLinkBtn = this.page.getByRole("button", { name: "Add link" });
}); // BUG
readonly addLinkBtn = this.page.getByTestId("add-link-button");
readonly infoRadio = this.page.getByTestId("Info-radio-wrapper");
readonly treasuryRadio = this.page.getByTestId("Treasury-radio-wrapper");

constructor(private readonly page: Page) {}

Expand All @@ -37,6 +31,7 @@ export default class ProposalDiscussionPage {
}

async closeUsernamePrompt() {
await this.page.waitForTimeout(5_000);
await this.page
.locator("div")
.filter({ hasText: /^Hey, setup your username$/ })
Expand All @@ -54,35 +49,20 @@ export default class ProposalDiscussionPage {

async getAllProposals() {
await this.page.waitForTimeout(4_000); // waits for proposals to render
// BUG Select all elements with data-testid attribute
const elements = await this.page.$$("[data-testid]");

// Regex pattern to match IDs starting with "proposal" and ending with numbers
const pattern = /^proposal-\d+$/;

// Extract the data-testid attributes
const proposalCards: Locator[] = [];
for (const element of elements) {
const dataTestId = await element.getAttribute("data-testid");
if (pattern.test(dataTestId)) {
proposalCards.push(this.page.getByTestId(dataTestId));
}
}

return proposalCards;
// BUG return this.page.locator('[data-testid$="-card"]').all();
return this.page
.locator('[data-testid^="proposal-"][data-testid$="-card"]')
.all();
}

async setUsername(name: string) {
await this.page.getByLabel("Username *").fill(name);
await this.page.getByTestId("username-input").fill(name);

const proceedBtn = this.page.getByRole("button", {
name: "Proceed with this username",
});
const proceedBtn = this.page.getByTestId("proceed-button");
await proceedBtn.click();
await proceedBtn.click();

await this.page.getByRole("button", { name: "Close" }).click();
await this.page.getByTestId("close-button").click();
}

async createProposal(): Promise<number> {
Expand All @@ -109,7 +89,7 @@ export default class ProposalDiscussionPage {
await this.fillForm(proposalRequest);

await this.continueBtn.click();
await this.page.getByRole("button", { name: "Submit" }).click();
await this.page.getByTestId("submit-button").click();

// Wait for redirection to `proposal-discussion-details` page
await this.page.waitForTimeout(2_000);
Expand All @@ -119,32 +99,34 @@ export default class ProposalDiscussionPage {
}

private async fillForm(data: ProposalCreateRequest) {
await this.page.getByLabel("Governance Action Type *").click();
await this.page.getByRole("option", { name: "Info" }).click();
await this.page.getByLabel("Title *").fill(data.prop_name);
await this.page.getByPlaceholder("Summary...").fill(data.prop_abstract);
await this.page.getByLabel("Motivation *").fill(data.prop_motivation);
await this.page.getByLabel("Rationale *").fill(data.prop_rationale);

for (const link of data.proposal_links) {
await this.page.getByTestId("governance-action-type").click();
await this.page.getByTestId("info-button").click();
await this.page.getByTestId("title-input").fill(data.prop_name);
await this.page.getByTestId("abstract-input").fill(data.prop_abstract);
await this.page.getByTestId("motivation-input").fill(data.prop_motivation);
await this.page.getByTestId("rationale-input").fill(data.prop_rationale);

for (let index = 0; index < data.proposal_links.length; index++) {
await this.addLinkBtn.click();

await this.page
.getByPlaceholder("https://website.com")
.fill(link.prop_link);
await this.page.getByPlaceholder("Text").fill(link.prop_link_text);
.getByTestId(`link-${index}-url-input`)
.fill(data.proposal_links[index].prop_link);
await this.page
.getByTestId(`link-${index}-text-input`)
.fill(data.proposal_links[index].prop_link_text);
}
}

async filterProposalByNames(names: string[]) {
for (const name of names) {
await this.page.getByLabel(name).click();
await this.page.getByLabel(name).click(); // test id is not in proper format for all filter type
}
}

async unFilterProposalByNames(names: string[]) {
for (const name of names) {
await this.page.getByLabel(name).click();
await this.page.getByLabel(name).click(); // test id is not in proper format for all filter type
}
}

Expand Down
Loading

0 comments on commit 44a5c22

Please sign in to comment.