Skip to content

Commit

Permalink
chore: handling edge case for grabbing token values when values are l…
Browse files Browse the repository at this point in the history
…arge numbers containing commas
  • Loading branch information
rabi-siddique committed Mar 6, 2024
1 parent 7f1a482 commit a5713d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
17 changes: 15 additions & 2 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,22 @@ const keplr = {
);
const innerTexts = await parentElement.allInnerTexts();
const textArray = innerTexts[0].split('\n');
const tokenValue = Number(textArray[3]);
await playwright.switchToCypressWindow();

let numberString;
for (const element of textArray) {
const elementWithNoCommas = element.replace(/,/g, '');
if (!isNaN(parseFloat(elementWithNoCommas))) {
numberString = elementWithNoCommas;
break;
}
}

if (!numberString) {
throw new Error(`Token value for ${tokenName} not found`);
}

let tokenValue = parseFloat(numberString);
await playwright.switchToCypressWindow();
return tokenValue;
},
};
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ describe('Keplr', () => {
});
cy.addNewTokensFound();
cy.getTokenAmount('ATOM').then(tokenValue => {
expect(tokenValue).to.equal(0);
expect(Number.isFinite(tokenValue)).to.be.true;
});
cy.getTokenAmount('BLD').then(tokenValue => {
expect(tokenValue).to.equal(331);
expect(Number.isFinite(tokenValue)).to.be.true;
});
cy.getTokenAmount('IST').then(tokenValue => {
expect(Number.isFinite(tokenValue)).to.be.true;
});
});
it(`should disconnect the wallet from all the connected DAPPs`, () => {
Expand Down

0 comments on commit a5713d7

Please sign in to comment.