Skip to content

Commit

Permalink
Fix mainnet test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed Nov 25, 2024
1 parent 0e48412 commit 3dc1362
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
5 changes: 3 additions & 2 deletions integration_test/cli/gen-wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs');
function createRange(start, end) {
return Array.from({ length: end - start }, (_, i) => start + i);
}
NETWORK_ID=1

async function genWallet() {
// create workshops first
Expand All @@ -14,8 +15,8 @@ async function genWallet() {
const nthWallet = await wallet.getAccount(index);
let singleAddress = await nthWallet.singleAddressWallet();
walletJson = singleAddress.toJSON();
walletJson.address = singleAddress.addressBech32(0);
walletJson.stakeAddress = singleAddress.rewardAddressBech32(0);
walletJson.address = singleAddress.addressBech32(NETWORK_ID);
walletJson.stakeAddress = singleAddress.rewardAddressBech32(NETWORK_ID);
return walletJson;
};
// make first 3 wallets for manual testing
Expand Down
2 changes: 1 addition & 1 deletion integration_test/lib/constants/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const environments = {
process.env.KUBER_API_URL || 'https://sanchonet.kuber.cardanoapi.io',
apiKey: process.env.KUBER_API_KEY || '',
},
networkId: process.env.NETWORK_ID || 0,
networkId: process.env.NETWORK_ID || '0',
ci: process.env.CI,
};

Expand Down
23 changes: 10 additions & 13 deletions integration_test/lib/fixtures/importWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@ import { CardanoTestWalletJson } from '@cardanoapi/cardano-test-wallet/types';
import { Page } from '@playwright/test';
import { StaticWallet } from '@types';

export async function importWallet(
page: Page,
wallet: StaticWallet | CardanoTestWalletJson
): Promise<void> {
await page.addInitScript((wallet) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
window.cardanoTestWallet= {wallet: wallet}
}, wallet);
}


export async function injectWalletExtension(
page: Page,
wallet: StaticWallet | CardanoTestWalletJson
): Promise<void> {
await page.addInitScript((wallet) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
window.cardanoTestWallet= {wallet: wallet}
if(window.cardanoTestWallet){
//@ts-ignore
window.cardanoTestWallet.wallet=wallet
}else{
//@ts-ignore
window.cardanoTestWallet={wallet}
}

//@ts-ignore

}, wallet);
}

export const importWallet = injectWalletExtension
1 change: 1 addition & 0 deletions integration_test/lib/fixtures/loadExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function loadEternlExtension(
enableStakeSigning,
kuberApiUrl: environments.kuber.apiUrl,
kuberApiKey: environments.kuber.apiKey,
networkId: parseInt(environments.networkId),
};
await page.addInitScript(
({ walletConfig, supportedExtensions }) => {
Expand Down
8 changes: 5 additions & 3 deletions integration_test/lib/pages/homePage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, Locator, Page } from '@playwright/test';
import { faker } from '@faker-js/faker';
import { extractPollIdFromUrl } from '@helpers/string';
import { blake } from 'libcardano';

export default class HomePage {
readonly heading = this.page.getByText(
Expand All @@ -14,7 +15,7 @@ export default class HomePage {
// input
readonly pollNameInput = this.page.locator(
'[data-testid="poll-name-input"] input'
); //BUG incorrect position of testid
);

readonly constitutionLinkInput = this.page.locator('[data-testid="poll-link-input"] input').first()

Expand All @@ -35,8 +36,9 @@ export default class HomePage {
): Promise<number> {
await this.createPollBtn.click();
await this.pollNameInput.fill(pollName);
await this.constitutionLinkInput.fill('https://google.com');
await this.constutionHashInput.fill('aaaa');
await this.constitutionLinkInput.fill(faker.internet.url());
const randomHash = blake.hash32(Buffer.from(faker.animal.bear()))
await this.constutionHashInput.fill(randomHash.toString('hex'));

await this.submitPollBtn.click();

Expand Down

0 comments on commit 3dc1362

Please sign in to comment.