Skip to content

Commit

Permalink
fix: accout balance check test
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdbak committed Feb 13, 2025
1 parent a0611ed commit efab24e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/e2e/playwright/tests/SH_wallet_web.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ test.describe('SH Wallet checks', () => {
const page2Promise = page.waitForEvent('popup');
await page.locator('//div[@class="account-row"]').click();
const page2 = await page2Promise;
const aeScanBalance: string = await page2.locator('//tr[@class="account-details-panel__row"]//div[@class="price-label"]').first()
let aeScanBalance: string = await page2.locator('//tr[@class="account-details-panel__row"]//div[@class="price-label"]').first()
.textContent() as string;
// Convert the balance string from aeScan
// to the same format as it is in the Wallet account details page
Expand All @@ -281,8 +281,9 @@ test.describe('SH Wallet checks', () => {
aeScan = aeScanBalance.substring(0, aeScanBalance.indexOf(' '));
aeScan += '.00';
} else {
const aeScanFloat = aeScanBalance.slice(aeScanBalance.indexOf('.'), 5);
const aeScanToken = parseFloat(aeScanInt.concat(aeScanFloat));
aeScanBalance = aeScanBalance.split(',').join('');
const aeScanFloat = aeScanBalance.slice(0, -3);
const aeScanToken= parseFloat(aeScanFloat);

Check failure on line 286 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

Operator '=' must be spaced

Check failure on line 286 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

Operator '=' must be spaced
aeScan = aeScanToken.toFixed(2);
}
await page.getByTestId('btn-close').nth(1).click();
Expand All @@ -292,8 +293,9 @@ test.describe('SH Wallet checks', () => {
.textContent() as string;
const aeTokenFraction: string = await page.locator('//div[@class="account-details"]//div[@data-cy="balance-info"]//span[@class="asset-fractional"]')
.textContent() as string;
const aeToken = aeTokenInt.concat(aeTokenFraction);
let aeToken = aeTokenInt.concat(aeTokenFraction);
// Compare the aeScan balance with the wallet account balance
aeToken = aeToken.split(',').join('');
expect(aeScan).toBe(aeToken);
});

Expand All @@ -308,7 +310,7 @@ test.describe('SH Wallet checks', () => {
await page.locator('//div[@class="account-row"]').click();
const page2 = await page2Promise;
await page.waitForTimeout(5000);
const aeScanBalance: string = await page2.locator('//tr[@class="account-details-panel__row"]//div[@class="price-label"]').first()
let aeScanBalance: string = await page2.locator('//tr[@class="account-details-panel__row"]//div[@class="price-label"]').first()
.textContent() as string;
// Convert the balance string from aeScan
// to the same format as it is in the Wallet account details page
Expand All @@ -321,19 +323,21 @@ test.describe('SH Wallet checks', () => {
aeScan += '.00';
} else {
// Align the aeScan amount to the shown Wallet amount
const aeScanString = aeScanBalance.slice(0, -3);
const aeScanFloat = parseFloat(aeScanString);
aeScan = aeScanFloat.toFixed(2);
aeScanBalance = aeScanBalance.split(',').join('');
const aeScanFloat = aeScanBalance.slice(0, -3);
const aeScanToken= parseFloat(aeScanFloat);

Check failure on line 328 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

Operator '=' must be spaced

Check failure on line 328 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

Operator '=' must be spaced
aeScan = aeScanToken.toFixed(2);
}
await page.getByTestId('btn-close').nth(1).click();
await page.locator('//div[@class="transaction-token-rows"]').nth(0).isVisible();
// Take the account balance which are two strings and concatenate them
const aeTokenInt: string = await page.locator('//div[@class="account-details"]//div[@data-cy="balance-info"]//span[@class="asset-integer"]')
let aeTokenInt: string = await page.locator('//div[@class="account-details"]//div[@data-cy="balance-info"]//span[@class="asset-integer"]')

Check failure on line 334 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

'aeTokenInt' is never reassigned. Use 'const' instead

Check failure on line 334 in tests/e2e/playwright/tests/SH_wallet_web.spec.ts

View workflow job for this annotation

GitHub Actions / main

'aeTokenInt' is never reassigned. Use 'const' instead
.textContent() as string;
const aeTokenFraction: string = await page.locator('//div[@class="account-details"]//div[@data-cy="balance-info"]//span[@class="asset-fractional"]')
.textContent() as string;
const aeToken = aeTokenInt.concat(aeTokenFraction);
let aeToken = aeTokenInt.concat(aeTokenFraction);
// Compare the aeScan balance with the wallet account balance
aeToken = aeToken.split(',').join('');
expect(aeScan).toBe(aeToken);
});

Expand Down

0 comments on commit efab24e

Please sign in to comment.