Skip to content

Commit

Permalink
test: Delegated ADA display to DRep
Browse files Browse the repository at this point in the history
  • Loading branch information
NabinKawan committed May 23, 2024
1 parent 259f09f commit b736a59
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const adaHolder01Wallet = staticWallets[3];
export const adaHolder02Wallet = staticWallets[4];
export const adaHolder03Wallet = staticWallets[6];
export const adaHolder04Wallet = staticWallets[7];
export const adaHolder05Wallet = staticWallets[8];

// Does not takes part in transaction
export const user01Wallet: StaticWallet = staticWallets[5];
Expand All @@ -19,6 +20,7 @@ export const adaHolderWallets = [
adaHolder02Wallet,
adaHolder03Wallet,
adaHolder04Wallet,
adaHolder05Wallet,
];

export const userWallets = [user01Wallet];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default class DRepDirectoryPage {
const delegateBtn = this.page.getByTestId(`${dRepId}-delegate-button`);
await expect(delegateBtn).toBeVisible();
await this.page.getByTestId(`${dRepId}-delegate-button`).click();
await this.searchInput.clear();
}

async resetDRepForm() {
Expand Down
2 changes: 1 addition & 1 deletion tests/govtool-frontend/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"allure:serve": "npx allure serve",
"test": "npx playwright test",
"format": "prettier . --write",
"generate-wallets": "ts-node ./generate_wallets.ts 8"
"generate-wallets": "ts-node ./generate_wallets.ts 9"
},
"dependencies": {
"@cardanoapi/cardano-test-wallet": "^1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
adaHolder02Wallet,
adaHolder03Wallet,
adaHolder04Wallet,
adaHolder05Wallet,
dRep01Wallet,
dRep02Wallet,
} from "@constants/staticWallets";
Expand Down Expand Up @@ -58,25 +59,6 @@ test.describe("Delegate to others", () => {
await expect(page.getByText(dRepId)).toBeVisible();
});

test("2W. Should display voting power of DRep", async ({ page, browser }) => {
const dRepPage = await createNewPageWithWallet(browser, {
storageState: ".auth/dRep01.json",
wallet: ShelleyWallet.fromJson(dRep01Wallet),
enableStakeSigning: true,
});

const adaHolder01VotingPower = await kuberService.getBalance(
adaHolder01Wallet.address
);

await expect(
dRepPage.getByText(`Voting power:₳ ${adaHolder01VotingPower}`)
).toBeVisible();
console.log({ adaHolder01VotingPower });

await dRepPage.goto("/");
});

test("2F. Should change delegated dRep", async ({ page }, testInfo) => {
test.setTimeout(testInfo.timeout + 2 * environments.txTimeOut);

Expand Down Expand Up @@ -320,3 +302,35 @@ test.describe("No confidence delegation", () => {
console.log({ balance });
});
});

test.describe("Delegated ADA visibility", () => {
test.use({
storageState: ".auth/adaHolder05.json",
wallet: adaHolder05Wallet,
});

test("2X. Should show my delegated ADA to the DRep", async ({
page,
}, testInfo) => {
test.setTimeout(testInfo.timeout + environments.txTimeOut);

const dRepDirectoryPage = new DRepDirectoryPage(page);
await dRepDirectoryPage.goto();

await dRepDirectoryPage.delegateToDRep(dRep01Wallet.dRepId);

const adaHolderVotingPower = await kuberService.getBalance(
adaHolder05Wallet.address
);
await expect(
page.getByText(`You have delegated ₳ ${adaHolderVotingPower}`)
).toBeVisible();

await page.goto("/");
await expect(
page.getByText(
`Your Voting Power of ₳${adaHolderVotingPower} is Delegated to`
)
).toBeVisible();
});
});
12 changes: 12 additions & 0 deletions tests/govtool-frontend/playwright/tests/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
adaHolder02Wallet,
adaHolder03Wallet,
adaHolder04Wallet,
adaHolder05Wallet,
dRep01Wallet,
user01Wallet,
} from "@constants/staticWallets";
Expand All @@ -18,6 +19,7 @@ const adaHolder01AuthFile = ".auth/adaHolder01.json";
const adaHolder02AuthFile = ".auth/adaHolder02.json";
const adaHolder03AuthFile = ".auth/adaHolder03.json";
const adaHolder04AuthFile = ".auth/adaHolder04.json";
const adaHolder05AuthFile = ".auth/adaHolder05.json";

const user01AuthFile = ".auth/user01.json";

Expand Down Expand Up @@ -85,3 +87,13 @@ setup("Create AdaHolder 04 auth", async ({ page, context }) => {

await context.storageState({ path: adaHolder04AuthFile });
});

setup("Create AdaHolder 05 auth", async ({ page, context }) => {
await importWallet(page, adaHolder05Wallet);

const loginPage = new LoginPage(page);
await loginPage.login();
await loginPage.isLoggedIn();

await context.storageState({ path: adaHolder05AuthFile });
});

0 comments on commit b736a59

Please sign in to comment.