-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 anti-pattern getText
+ assert
#28041
base: develop
Are you sure you want to change the base?
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
await driver.findElement({ | ||
xpath: | ||
"//div[@data-testid='useSafeChainsListValidation']//label[contains(@class, 'toggle-button') and contains(@class, 'toggle-button--on')]", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to use an xpath here since there's a long list of toggles, without a way of differentiating to which feature belong to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!!
Builds ready [4cfcca0]
Page Load Metrics (2080 ± 140 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could update this one in incremental-security.spec.js.
const outerSegment = await driver.findElement(
'.qr-code__address-segments',
);
const publicAddress = await outerSegment.getText();
@@ -13,7 +12,7 @@ const FixtureBuilder = require('../../fixture-builder'); | |||
describe('Sign in with ethereum', function () { | |||
it('user should be able to confirm sign in with ethereum', async function () { | |||
const expectedSigninMessageTitle = | |||
'This site is requesting to sign in with Account 1'; | |||
'This site is requesting to sign in with'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!!
); | ||
await driver.waitForSelector({ | ||
css: '#signTypedDataV4VerifyResult', | ||
text: KNOWN_PUBLIC_KEY_ADDRESSES[0].address.toLocaleLowerCase(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: could we have this in variable and then pass the variable. Its ok if you dont make the change too.
let address = KNOWN_PUBLIC_KEY_ADDRESSES[0].address.toLocaleLowerCase()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I've updated it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is needed here, it's clear enough the origin implementation.
But since you already made the change, we can keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await driver.waitForSelector({ | ||
tag: 'dd', | ||
text: currencySYMBOL, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a more specific data-testid for this element or make be some other approach?
The reason I mention this is - I changed the text for currencySYMBOL from ETH to ET, the test would not fail leading to false negatives.
I also checked for any other unique identifiers but there aren't any so we need to add one in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update on my previous comment - I think changing the data-testid would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch! I've added test ids in the app level 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could update this one in incremental-security.spec.js.
const outerSegment = await driver.findElement(
'.qr-code__address-segments',
);
const publicAddress = await outerSegment.getText();
@@ -109,12 +109,10 @@ describe('Incremental Security', function () { | |||
await driver.switchToWindow(extension); | |||
|
|||
// should have the correct amount of eth | |||
let currencyDisplay = await driver.waitForSelector({ | |||
await driver.waitForSelector({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to come up with a different approach because this does not fail if the text is changed for waitForSelector
, and it does fail with the previous assertion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @hjetpoluru 👋 I've seen the test fail if the text is changed from 1
to another value 🤔 Do you see something different?
fail-selector.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @seaona, thanks for addressing the other issue. I tried changing the value to 0
, and it did not fail. I will try again later today but if you can check earlier that would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @hjetpoluru let me check it and will report back 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my surprise this did not fail if the text was changed here
const backupReminder = await driver.findElements({
xpath:
"//div[contains(@class, 'home-notification__text') and contains(text(), 'Back up your Secret Recovery Phrase to keep your wallet and funds secure')]",
});
assert.equal(backupReminder.length, 1);
Builds ready [5c99c5c]
Page Load Metrics (1962 ± 108 ms)
Bundle size diffs
|
Description
Continuing the work of removing the e2e anti-pattern of finding the element and then asserting its text.
There are more occurrences, but this work is split in several PRs, for an easy review and a faster ci.
Once all occurrences have been fixed, we'll be able to merge @HowardBraham 's PR for adding a lint rule which prevents introducing it again.
Related issues
Fixes: (but doesn't yet closes) #19870
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist