Skip to content

Commit

Permalink
Open correct tx details when there is a pending tx
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception committed Sep 8, 2023
1 parent 9d6c7f3 commit c2c840e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
26 changes: 11 additions & 15 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,40 +1261,36 @@ const metamask = {
.locator(mainPageElements.tabs.activityButton)
.click();

let visibleTxsCount = await playwright
let visibleTxs = await playwright
.metamaskWindow()
.locator(
`${mainPageElements.activityTab.completedTransactionsList} > div`,
)
.count();
.filter({ hasNotText: 'History' })

This comment has been minimized.

Copy link
@drptbl

drptbl Sep 8, 2023

Collaborator

@duckception We're trying to avoid using text-based selectors to be able to support multiple languages of metamask. You won't find them anywhere in the code because of it.

This comment has been minimized.

Copy link
@duckception

duckception Sep 9, 2023

Author Contributor

My bad, this should've been obvious. Already fixed. Thanks! ❤️

.filter({ hasNotText: 'View more' })
.all();

while (txIndex >= visibleTxsCount) {
while (txIndex >= visibleTxs.length) {
try {
await playwright.metamaskWindow().getByText('View more').click();
} catch (error) {
log('[openTransactionDetails] Clicking "View more" failed!');
throw new Error(
`Transaction with index ${txIndex} is not found. There are only ${visibleTxsCount} transactions.`,
`Transaction with index ${txIndex} is not found. There are only ${visibleTxs.length} transactions.`,
);
}

visibleTxsCount = await playwright
visibleTxs = await playwright
.metamaskWindow()
.locator(
`${mainPageElements.activityTab.completedTransactionsList} > div`,
)
.count();
.filter({ hasNotText: 'History' })
.filter({ hasNotText: 'View more' })
.all();
}

await playwright
.metamaskWindow()
.locator(mainPageElements.activityTab.completedTransaction(txIndex))
.waitFor({ state: 'visible', timeout: 10000 });

await playwright
.metamaskWindow()
.locator(mainPageElements.activityTab.completedTransaction(txIndex))
.click();
await visibleTxs[txIndex].click();

await playwright
.metamaskWindow()
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/specs/metamask-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ describe('Metamask', () => {
.invoke('text')
.then(text => cy.log('Token hash: ' + text));
});
it(`openMetamaskTransactionDetails should open correct transaction details popup when there is a pending tx`, () => {
// Cannot be tested further with Cypress 😔
cy.openMetamaskTransactionDetails(0);
cy.closeMetamaskTransactionDetailsPopup().then(
closed => expect(closed).to.be.true,
);
});
it(`rejectMetamaskAddToken should cancel importing a token`, () => {
cy.get('#watchAsset').click();
cy.rejectMetamaskAddToken().then(rejected => {
Expand Down

0 comments on commit c2c840e

Please sign in to comment.