Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky test Navigation Signature - Different signature types initiates multiple signatures and rejects all #27481

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/e2e/tests/confirmations/navigation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { strict as assert } from 'assert';
import { TransactionEnvelopeType } from '@metamask/transaction-controller';
import { Suite } from 'mocha';
import { By } from 'selenium-webdriver';
import {
DAPP_HOST_ADDRESS,
WINDOW_TITLES,
openDapp,
regularDelayMs,
unlockWallet,
WINDOW_TITLES,
} from '../../helpers';
import { Driver } from '../../webdriver/driver';
import { withRedesignConfirmationFixtures } from './helpers';
Expand Down Expand Up @@ -98,7 +98,6 @@ describe('Navigation Signature - Different signature types', function (this: Sui
await unlockWallet(driver);
await openDapp(driver);
await queueSignatures(driver);
await driver.delay(regularDelayMs);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes the test fail when the delay is not enough


await driver.clickElement('[data-testid="confirm-nav__reject-all"]');

Expand Down Expand Up @@ -166,11 +165,13 @@ async function queueSignatures(driver: Driver) {
await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.findElement({ text: 'Reject all' });
await driver.waitForSelector(By.xpath("//div[normalize-space(.)='1 of 2']"));

await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
await driver.clickElement('#signTypedDataV4');
await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.waitForSelector(By.xpath("//div[normalize-space(.)='1 of 3']"));
Copy link
Contributor Author

@seaona seaona Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we wait for the navigation to be loaded. Since the inner value has spaces we need to normalize it

Screenshot from 2024-09-30 09-41-44

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seaona, small nit could it possible to wait for any other stable element in the dialog to load?

Copy link
Contributor Author

@seaona seaona Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @hjetpoluru I've seen that waiting for the navigation to be loaded ensures that the signatures have been queued.
We could wait for the signature content, but that's not directly fixing the issue. What were you thinking on?

[Edit] I think with page objects, we could add a function for checking that the complete signature page is loaded if we want to, though I would leave this out of scope for this fix

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seaona, I was thinking about waiting for the buttons to load. But after reading your reply, it looks like we need to wait for the navigation to be loaded to ensure the signatures are queued. Maybe we could add a data-testId to the page loader? Otherwise, I will approve this PR as it looks good.

Copy link
Contributor Author

@seaona seaona Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in this case, we need to wait for the content of the element, to ensure that it has the expected value (1 of 2 or 1 of 3 etc.), looking just for the element itself with a data test id, could cause a race condition of the element being present, but not fulfilling the condition we need (the number of signatures queued). Let me know if this makes sense 🙇‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh perfect @seaona thanks for your patience and explaining this to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem! Thank you for your detailed review @hjetpoluru 🙇‍♀️

}

async function queueSignaturesAndTransactions(driver: Driver) {
Expand Down