Skip to content

Commit

Permalink
fix: E2E test for new assets page (#1044)
Browse files Browse the repository at this point in the history
* fix: E2E test

* fix: E2E test (2)

* fix: remove --debug from 'playwright' command
  • Loading branch information
impelcrypto committed Nov 23, 2023
1 parent 7cb3a7b commit 9f2da4f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ polkadot
astar-collator

# Chopstick binaries
db.sqlite
db.sqlite*
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"heroku-postbuild": "yarn install && yarn build",
"heroku-deploy": "git push heroku main",
"playwright:codegen": "npx playwright codegen http://localhost:8080",
"playwright": "BASE_URL='http://localhost:8080' ENDPOINT='ws://127.0.0.1:9944' npx playwright test --project=chromium --debug",
"playwright": "BASE_URL='http://localhost:8080' ENDPOINT='ws://127.0.0.1:9944' npx playwright test --project=chromium",
"playwright:ci": "node ./tests/chopsticks/start-chopsticks.js"
},
"dependencies": {
Expand Down
5 changes: 4 additions & 1 deletion src/components/assets/NativeAssetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@
</q-tooltip>
</div>
<template v-else>
<router-link :to="buildTransferPageLink(nativeTokenSymbol)">
<router-link
:to="buildTransferPageLink(nativeTokenSymbol)"
data-testid="transfer-link-button"
>
<button class="btn btn--icon">
<astar-icon-transfer />
</button>
Expand Down
3 changes: 1 addition & 2 deletions tests/assets-transactions-evm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ test.describe('account panel', () => {
context: BrowserContext;
}) => {
// transfer test (from native to evm) :: need to testing
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
const faucetAmount = BigInt(200);
await page.getByPlaceholder('Destination Address').fill(ALICE_EVM_ADDRESS);
await page.getByPlaceholder('0.0').fill(faucetAmount.toString());
Expand Down
19 changes: 5 additions & 14 deletions tests/test_specs/assets-transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ test.describe('account panel', () => {
// Test case: AS001
test('should transfer tokens from Alice to Bob', async ({ page, context }) => {
const transferAmount = BigInt(1000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();

page.getByTestId('transfer-link-button').click();
await page.getByPlaceholder('Destination Address').fill(BOB_ADDRESS);
await page.getByPlaceholder('0.0').fill(transferAmount.toString());
await page.getByRole('button', { name: 'Confirm' }).click();
Expand All @@ -70,9 +68,7 @@ test.describe('account panel', () => {
await selectMultisigAccount(page, context, false);
// Memo: PolkaSafe SDK will check the balance of the Multisig account on mainnet before sending the transaction (the SDK through an error if the balance is not enough)
const transferAmount = BigInt(1);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();

page.getByTestId('transfer-link-button').click();
await page.getByPlaceholder('Destination Address').fill(BOB_ADDRESS);
await page.getByPlaceholder('0.0').fill(transferAmount.toString());
await page.getByRole('button', { name: 'Confirm' }).click();
Expand All @@ -84,9 +80,7 @@ test.describe('account panel', () => {
await selectMultisigAccount(page, context, true);
// Memo: PolkaSafe SDK will check the balance of the Multisig account on mainnet before sending the transaction (the SDK through an error if the balance is not enough)
const transferAmount = BigInt(1);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();

page.getByTestId('transfer-link-button').click();
await page.getByPlaceholder('Destination Address').fill(BOB_ADDRESS);
await page.getByPlaceholder('0.0').fill(transferAmount.toString());
await page.getByRole('button', { name: 'Confirm' }).click();
Expand All @@ -101,9 +95,7 @@ test.describe('account panel', () => {
page: Page;
}) => {
const baseTransferAmount = BigInt(1000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();

page.getByTestId('transfer-link-button').click();
const aliceBalanceBeforeTransaction = await getBalance(ALICE_ADDRESS);
await page.getByPlaceholder('Destination Address').fill(BOB_ADDRESS);

Expand Down Expand Up @@ -132,8 +124,7 @@ test.describe('account panel', () => {
page: Page;
context: BrowserContext;
}) => {
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
const faucetAmount = BigInt(200);
await page.getByPlaceholder('Destination Address').fill(ALICE_EVM_ADDRESS);
await page.getByPlaceholder('0.0').fill(faucetAmount.toString());
Expand Down
14 changes: 6 additions & 8 deletions tests/test_specs/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ test.describe('account panel', () => {
await expect(page.locator('.noti-content')).toBeVisible();
});

// test('account expander works', async ({ page }) => {
// await page.locator('.icon--expand').first().click();
// const transferButton = page.locator('#asset-expand').getByRole('button', { name: 'Transfer' });
// await expect(transferButton).toBeVisible();

// await page.locator('.icon--expand').first().click();
// await expect(transferButton).not.toBeVisible();
// });
test('account expander works', async ({ page }) => {
const transferButton = page.getByTestId('transfer-link-button');
await expect(transferButton).toBeVisible();
await page.locator('.icon--expand').first().click();
await expect(page.getByText('Vesting')).toBeVisible();
});
});
24 changes: 8 additions & 16 deletions tests/test_specs/reserve-transfer-asset-xcm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ test.beforeEach(async ({ page, context }) => {
test.describe('Test case: XCM006', () => {
test('should transfer Alice ASTR tokens from Astar to Acala', async ({ page, context }) => {
const transferAmount = BigInt(1000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();
await page.getByRole('main').getByRole('button').first().click();
await page.locator('#amount').fill(transferAmount.toString());
Expand All @@ -64,8 +63,7 @@ test.describe('Test case: XCM006', () => {
test.describe('Test case: XCM003', () => {
test('should transfer Alice ASTR tokens from Acala to Astar', async ({ page, context }) => {
const transferAmount = BigInt(900);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();

// memo wait for from/to values to switch on UI, because if switch happens after amount is entered, the amount would be cleared
Expand All @@ -92,8 +90,7 @@ test.describe('Test case: XCM004', () => {
test('should transfer Alice ACA tokens from Astar to Acala', async ({ page, context }) => {
const assetId = '18446744073709551616';
const transferAmount = BigInt(1000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();

await page.getByRole('main').getByRole('button').first().click();
Expand Down Expand Up @@ -124,8 +121,7 @@ test.describe('Test case: XCM001', () => {
test('should transfer Alice ACA tokens from Acala to Astar', async ({ page, context }) => {
const assetId = '18446744073709551616';
const transferAmount = BigInt(900);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();

await page
Expand Down Expand Up @@ -155,8 +151,7 @@ test.describe('Test case: XCM001-1', () => {
test('should transfer Alice DOT tokens from Polkadot to Astar', async ({ page, context }) => {
const assetId = '340282366920938463463374607431768211455';
const transferAmount = BigInt(100);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();

await page.locator('div:nth-child(3) > .wrapper--select-chain').click();
Expand Down Expand Up @@ -186,8 +181,7 @@ test.describe('Test case: XCM004-1', () => {
test('should transfer Alice DOT tokens from Astar to Polkadot', async ({ page, context }) => {
const assetId = '340282366920938463463374607431768211455';
const transferAmount = BigInt(100);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();
await page.getByRole('main').getByRole('button').first().click();

Expand Down Expand Up @@ -218,8 +212,7 @@ test.describe('Test case: XCM001-2', () => {
test('should transfer Alice USDT tokens from Statemint to Astar', async ({ page, context }) => {
const assetId = '4294969280';
const transferAmount = BigInt(10000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();

await page.locator('div:nth-child(3) > .wrapper--select-chain').click();
Expand Down Expand Up @@ -249,8 +242,7 @@ test.describe('Test case: XCM004-2', () => {
test('should transfer Alice USDT tokens from Astar to Statemint', async ({ page, context }) => {
const assetId = '4294969280';
const transferAmount = BigInt(10000);
await page.locator('.icon--expand').first().click();
await page.locator('#asset-expand').getByRole('button', { name: 'Transfer' }).click();
page.getByTestId('transfer-link-button').click();
await page.getByText('Cross-chain Transfer').click();
await page.getByRole('main').getByRole('button').first().click();

Expand Down

0 comments on commit 9f2da4f

Please sign in to comment.