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
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ export default class BudgetDiscussionSubmissionPage {
await this.usaToAdaCnversionRateInput.fill(
costing.usdToAdaConversionRate.toString()
);
await this.costBreakdownInput.fill(costing.costBreakdown);
await this.preferredCurrencyInput.fill(
costing.AmountInPreferredCurrency.toString()
);
await this.costBreakdownInput.fill(costing.costBreakdown);
}

async fillupCostingForm(costing: BudgetCostingProps) {
Expand Down
48 changes: 31 additions & 17 deletions tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,25 +374,30 @@ export default class OutComesPage {
}

async fetchOutcomeIdAndTitleFromNetwork(
governanceActionId: string,
governanceActionTitle: string
) {
governanceActionId?: string,
governanceActionTitle?: string
): Promise<{ governanceActionId: string; governanceActionTitle: string }> {
let updatedGovernanceActionId = governanceActionId;
let updatedGovernanceActionTitle = governanceActionTitle;

await this.page.route(
"**/governance-actions?search=&filters=&sort=**",
async (route) => {
const response = await route.fetch();
const data: outcomeProposal[] = await response.json();
if (!governanceActionId) {
if (data.length > 0) {
const randomIndexForId = Math.floor(Math.random() * data.length);
updatedGovernanceActionId =
data[randomIndexForId].tx_hash +
"#" +
data[randomIndexForId].index;

if (!updatedGovernanceActionId && data.length > 0) {
const randomIndex = Math.floor(Math.random() * data.length);
updatedGovernanceActionId = `${data[randomIndex].tx_hash}#${data[randomIndex].index}`;
}

if (!updatedGovernanceActionTitle) {
const itemWithTitle = data.find((item) => item.title != null);
if (itemWithTitle) {
updatedGovernanceActionTitle = itemWithTitle.title;
}
}

await route.fulfill({
status: 200,
contentType: "application/json",
Expand All @@ -410,31 +415,40 @@ export default class OutComesPage {
await route.continue();
return;
}

const data: outcomeMetadata = await response.json();
if (!governanceActionTitle && data.data.title != null) {
if (!updatedGovernanceActionTitle && data.data.title) {
updatedGovernanceActionTitle = data.data.title;
}

await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(data),
});
} catch (error) {
// Just return without handling the error
return;
}
}
);

const responsePromise = this.page.waitForResponse(
const actionsResponsePromise = this.page.waitForResponse(
"**/governance-actions?search=&filters=&sort=**"
);
const metadataResponsePromise = this.page.waitForResponse(
"**/governance-actions/metadata?**"
);


await this.goto();
await responsePromise;
await metadataResponsePromise;
await actionsResponsePromise;

const needMetadataForTitle = !updatedGovernanceActionTitle;
const metadataResponsePromise = needMetadataForTitle
? this.page.waitForResponse("**/governance-actions/metadata?**")
: Promise.resolve(null);
if (needMetadataForTitle) {
await metadataResponsePromise;
}

return {
governanceActionId: updatedGovernanceActionId,
governanceActionTitle: updatedGovernanceActionTitle,
Expand Down
10 changes: 10 additions & 0 deletions tests/govtool-frontend/playwright/lib/walletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,15 @@ class WalletManager {

return await LockInterceptor.intercept<StaticWallet>("tempWallets", popCb);
}

async updateWalletGivenName(address: string, givenName: string) {
const wallets: StaticWallet[] = (await getFile("wallets.json")) ?? [];
wallets.map((wallet: StaticWallet) => {
if (wallet.address === address) {
wallet.givenName = givenName;
}
});
await createFile("wallets.json", wallets);
}
}
export default WalletManager.getInstance();
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ test.describe("Budget proposal dRep behaviour", () => {

await budgetDiscussionDetailsPage.voteOnPoll(choice);

await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({
timeout: 60_000,
});
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
await expect(
budgetDiscussionDetailsPage.currentPage.getByTestId(
Expand All @@ -59,7 +61,7 @@ test.describe("Budget proposal dRep behaviour", () => {
await budgetDiscussionDetailsPage.voteOnPoll(choice);
await budgetDiscussionDetailsPage.changePollVote();

await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({timeout: 60_000});
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();

// vote must be changed
Expand Down Expand Up @@ -100,25 +102,17 @@ test.describe("Budget proposal dRep behaviour", () => {
.locator('[data-testid^="comment-"][data-testid$="-content-card"]')
.first();

await expect(
dRepCommentedCard.getByText("DRep", { exact: true })
).toBeVisible();

const isDRepGivenNameVisible = await dRepCommentedCard
.getByTestId("given-name")
.isVisible();

expect(
isDRepGivenNameVisible,
!isDRepGivenNameVisible && "Missing given-name testId"
).toBeTruthy();
await expect(dRepCommentedCard.getByTestId("dRep-tag")).toBeVisible();

await expect(dRepCommentedCard.getByTestId("given-name")).toHaveText(
dRep03Wallet.givenName
await expect(dRepCommentedCard.getByTestId("dRep-given-name")).toHaveText(
dRep03Wallet.givenName,
{ timeout: 60_000 }
);

await expect(dRepCommentedCard.getByTestId("drep-id")).toHaveText(
dRep03Wallet.dRepId
);
const dRepIdWithoutDotted = (
await dRepCommentedCard.getByTestId("dRep-id").textContent()
).replace(/\./g, "");

expect(dRep03Wallet.dRepId).toContain(dRepIdWithoutDotted);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ test.describe("Temporary DReps", () => {
await dRepPage.getByTestId("continue-retirement-button").click();
await expect(
dRepPage.getByTestId("retirement-transaction-submitted-modal")
).toBeVisible({ timeout: 15_000 });
).toBeVisible({ timeout: 60_000 });
dRepPage.getByTestId("confirm-modal-button").click();

await waitForTxConfirmation(dRepPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test("8C. Should search the list of proposed governance actions.", async ({
const proposalTitle = await proposalCard
.locator('[data-testid^="proposal-"][data-testid$="-title"]')
.innerText();
expect(proposalTitle).toContain(proposalName);
expect(proposalTitle.trim()).toContain(proposalName.trim());
}
},
{
Expand Down
8 changes: 3 additions & 5 deletions tests/govtool-frontend/playwright/tests/dRep.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ setup("Register DRep of static wallets", async () => {
const metadataPromises = dRepWallets.map(async (dRepWallet) => {
const metadataResponse = await uploadMetadataAndGetJsonHash();
const givenName = metadataResponse.givenName;
const index = dRepWallets.indexOf(dRepWallet);
dRepWallets[index] = {
...dRepWallet,
givenName,
};

await walletManager.updateWalletGivenName(dRepWallet.address, givenName);

return {
...metadataResponse,
wallet: dRepWallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { expect } from "@playwright/test";
import { test as setup } from "@fixtures/walletExtension";

import kuberService from "@services/kuberService";
import walletManager from "lib/walletManager";

setup.beforeEach(async () => {
await setAllureEpic("Setup");
Expand All @@ -28,11 +29,12 @@ setup("Register DRep of proposal budget static wallets", async () => {
async (dRepWallet) => {
const metadataResponse = await uploadMetadataAndGetJsonHash();
const givenName = metadataResponse.givenName;
const index = dRepWallets.indexOf(dRepWallet);
dRepWallets[index] = {
...dRepWallet,
givenName,
};

await walletManager.updateWalletGivenName(
dRepWallet.address,
givenName
);

return {
...metadataResponse,
wallet: dRepWallet,
Expand Down