Skip to content

Commit e528f5f

Browse files
authored
Merge pull request #3645 from IntersectMBO/fix/report-410-issue
Fix: report 410 issue
2 parents 187bd70 + d4d80d4 commit e528f5f

File tree

8 files changed

+67
-49
lines changed

8 files changed

+67
-49
lines changed

tests/govtool-frontend/playwright/lib/pages/budgetDiscussionSubmissionPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ export default class BudgetDiscussionSubmissionPage {
391391
await this.usaToAdaCnversionRateInput.fill(
392392
costing.usdToAdaConversionRate.toString()
393393
);
394-
await this.costBreakdownInput.fill(costing.costBreakdown);
395394
await this.preferredCurrencyInput.fill(
396395
costing.AmountInPreferredCurrency.toString()
397396
);
397+
await this.costBreakdownInput.fill(costing.costBreakdown);
398398
}
399399

400400
async fillupCostingForm(costing: BudgetCostingProps) {

tests/govtool-frontend/playwright/lib/pages/outcomesPage.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -374,25 +374,30 @@ export default class OutComesPage {
374374
}
375375

376376
async fetchOutcomeIdAndTitleFromNetwork(
377-
governanceActionId: string,
378-
governanceActionTitle: string
379-
) {
377+
governanceActionId?: string,
378+
governanceActionTitle?: string
379+
): Promise<{ governanceActionId: string; governanceActionTitle: string }> {
380380
let updatedGovernanceActionId = governanceActionId;
381381
let updatedGovernanceActionTitle = governanceActionTitle;
382+
382383
await this.page.route(
383384
"**/governance-actions?search=&filters=&sort=**",
384385
async (route) => {
385386
const response = await route.fetch();
386387
const data: outcomeProposal[] = await response.json();
387-
if (!governanceActionId) {
388-
if (data.length > 0) {
389-
const randomIndexForId = Math.floor(Math.random() * data.length);
390-
updatedGovernanceActionId =
391-
data[randomIndexForId].tx_hash +
392-
"#" +
393-
data[randomIndexForId].index;
388+
389+
if (!updatedGovernanceActionId && data.length > 0) {
390+
const randomIndex = Math.floor(Math.random() * data.length);
391+
updatedGovernanceActionId = `${data[randomIndex].tx_hash}#${data[randomIndex].index}`;
392+
}
393+
394+
if (!updatedGovernanceActionTitle) {
395+
const itemWithTitle = data.find((item) => item.title != null);
396+
if (itemWithTitle) {
397+
updatedGovernanceActionTitle = itemWithTitle.title;
394398
}
395399
}
400+
396401
await route.fulfill({
397402
status: 200,
398403
contentType: "application/json",
@@ -410,31 +415,40 @@ export default class OutComesPage {
410415
await route.continue();
411416
return;
412417
}
418+
413419
const data: outcomeMetadata = await response.json();
414-
if (!governanceActionTitle && data.data.title != null) {
420+
if (!updatedGovernanceActionTitle && data.data.title) {
415421
updatedGovernanceActionTitle = data.data.title;
416422
}
423+
417424
await route.fulfill({
418425
status: 200,
419426
contentType: "application/json",
420427
body: JSON.stringify(data),
421428
});
422429
} catch (error) {
430+
// Just return without handling the error
423431
return;
424432
}
425433
}
426434
);
427435

428-
const responsePromise = this.page.waitForResponse(
436+
const actionsResponsePromise = this.page.waitForResponse(
429437
"**/governance-actions?search=&filters=&sort=**"
430438
);
431-
const metadataResponsePromise = this.page.waitForResponse(
432-
"**/governance-actions/metadata?**"
433-
);
439+
434440

435441
await this.goto();
436-
await responsePromise;
437-
await metadataResponsePromise;
442+
await actionsResponsePromise;
443+
444+
const needMetadataForTitle = !updatedGovernanceActionTitle;
445+
const metadataResponsePromise = needMetadataForTitle
446+
? this.page.waitForResponse("**/governance-actions/metadata?**")
447+
: Promise.resolve(null);
448+
if (needMetadataForTitle) {
449+
await metadataResponsePromise;
450+
}
451+
438452
return {
439453
governanceActionId: updatedGovernanceActionId,
440454
governanceActionTitle: updatedGovernanceActionTitle,

tests/govtool-frontend/playwright/lib/walletManager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,15 @@ class WalletManager {
6565

6666
return await LockInterceptor.intercept<StaticWallet>("tempWallets", popCb);
6767
}
68+
69+
async updateWalletGivenName(address: string, givenName: string) {
70+
const wallets: StaticWallet[] = (await getFile("wallets.json")) ?? [];
71+
wallets.map((wallet: StaticWallet) => {
72+
if (wallet.address === address) {
73+
wallet.givenName = givenName;
74+
}
75+
});
76+
await createFile("wallets.json", wallets);
77+
}
6878
}
6979
export default WalletManager.getInstance();

tests/govtool-frontend/playwright/tests/11-proposal-budget/proposalBudget.dRep.pb.spec.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ test.describe("Budget proposal dRep behaviour", () => {
3535

3636
await budgetDiscussionDetailsPage.voteOnPoll(choice);
3737

38-
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
38+
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({
39+
timeout: 60_000,
40+
});
3941
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
4042
await expect(
4143
budgetDiscussionDetailsPage.currentPage.getByTestId(
@@ -59,7 +61,7 @@ test.describe("Budget proposal dRep behaviour", () => {
5961
await budgetDiscussionDetailsPage.voteOnPoll(choice);
6062
await budgetDiscussionDetailsPage.changePollVote();
6163

62-
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible();
64+
await expect(budgetDiscussionDetailsPage.pollYesBtn).not.toBeVisible({timeout: 60_000});
6365
await expect(budgetDiscussionDetailsPage.pollNoBtn).not.toBeVisible();
6466

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

103-
await expect(
104-
dRepCommentedCard.getByText("DRep", { exact: true })
105-
).toBeVisible();
106-
107-
const isDRepGivenNameVisible = await dRepCommentedCard
108-
.getByTestId("given-name")
109-
.isVisible();
110-
111-
expect(
112-
isDRepGivenNameVisible,
113-
!isDRepGivenNameVisible && "Missing given-name testId"
114-
).toBeTruthy();
105+
await expect(dRepCommentedCard.getByTestId("dRep-tag")).toBeVisible();
115106

116-
await expect(dRepCommentedCard.getByTestId("given-name")).toHaveText(
117-
dRep03Wallet.givenName
107+
await expect(dRepCommentedCard.getByTestId("dRep-given-name")).toHaveText(
108+
dRep03Wallet.givenName,
109+
{ timeout: 60_000 }
118110
);
119111

120-
await expect(dRepCommentedCard.getByTestId("drep-id")).toHaveText(
121-
dRep03Wallet.dRepId
122-
);
112+
const dRepIdWithoutDotted = (
113+
await dRepCommentedCard.getByTestId("dRep-id").textContent()
114+
).replace(/\./g, "");
115+
116+
expect(dRep03Wallet.dRepId).toContain(dRepIdWithoutDotted);
123117
});
124118
});

tests/govtool-frontend/playwright/tests/3-drep-registration/dRepRegistration.dRep.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ test.describe("Temporary DReps", () => {
222222
await dRepPage.getByTestId("continue-retirement-button").click();
223223
await expect(
224224
dRepPage.getByTestId("retirement-transaction-submitted-modal")
225-
).toBeVisible({ timeout: 15_000 });
225+
).toBeVisible({ timeout: 60_000 });
226226
dRepPage.getByTestId("confirm-modal-button").click();
227227

228228
await waitForTxConfirmation(dRepPage);

tests/govtool-frontend/playwright/tests/8-proposal-discussion/proposalDiscussion.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ test("8C. Should search the list of proposed governance actions.", async ({
119119
const proposalTitle = await proposalCard
120120
.locator('[data-testid^="proposal-"][data-testid$="-title"]')
121121
.innerText();
122-
expect(proposalTitle).toContain(proposalName);
122+
expect(proposalTitle.trim()).toContain(proposalName.trim());
123123
}
124124
},
125125
{

tests/govtool-frontend/playwright/tests/dRep.setup.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ setup("Register DRep of static wallets", async () => {
4545
const metadataPromises = dRepWallets.map(async (dRepWallet) => {
4646
const metadataResponse = await uploadMetadataAndGetJsonHash();
4747
const givenName = metadataResponse.givenName;
48-
const index = dRepWallets.indexOf(dRepWallet);
49-
dRepWallets[index] = {
50-
...dRepWallet,
51-
givenName,
52-
};
48+
49+
await walletManager.updateWalletGivenName(dRepWallet.address, givenName);
50+
5351
return {
5452
...metadataResponse,
5553
wallet: dRepWallet,

tests/govtool-frontend/playwright/tests/proposal-budget.dRep.setup.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { expect } from "@playwright/test";
1111
import { test as setup } from "@fixtures/walletExtension";
1212

1313
import kuberService from "@services/kuberService";
14+
import walletManager from "lib/walletManager";
1415

1516
setup.beforeEach(async () => {
1617
await setAllureEpic("Setup");
@@ -28,11 +29,12 @@ setup("Register DRep of proposal budget static wallets", async () => {
2829
async (dRepWallet) => {
2930
const metadataResponse = await uploadMetadataAndGetJsonHash();
3031
const givenName = metadataResponse.givenName;
31-
const index = dRepWallets.indexOf(dRepWallet);
32-
dRepWallets[index] = {
33-
...dRepWallet,
34-
givenName,
35-
};
32+
33+
await walletManager.updateWalletGivenName(
34+
dRepWallet.address,
35+
givenName
36+
);
37+
3638
return {
3739
...metadataResponse,
3840
wallet: dRepWallet,

0 commit comments

Comments
 (0)