-
Notifications
You must be signed in to change notification settings - Fork 5k
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
E2e test fixtures #16061
E2e test fixtures #16061
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. |
metrics = await driver.collectMetrics(); | ||
}); | ||
await withFixtures( | ||
{ fixtures: new FixtureBuilder().build() }, |
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.
Only the fixture has changed, the rest is just lint formatting
@@ -198,26 +198,6 @@ const getWindowHandles = async (driver, handlesCount) => { | |||
return { extension, dapp, popup }; | |||
}; | |||
|
|||
const connectDappWithExtensionPopup = async (driver) => { |
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 use the FixtureBuilder to add the required state for dapp connections
metrics = parsedLogs.map((pl) => JSON.parse(pl)); | ||
}); | ||
await withFixtures( | ||
{ fixtures: new FixtureBuilder().build() }, |
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.
Only the fixture has changed, the rest is just lint formatting
await driver.delay(1000); | ||
const logs = await driver.checkBrowserForLavamoatLogs(); | ||
await withFixtures( | ||
{ fixtures: new FixtureBuilder().build() }, |
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.
Only the fixture has changed, the rest is just lint formatting
await driver.delay(1000); | ||
const logs = await driver.checkBrowserForLavamoatLogs(); | ||
await withFixtures( | ||
{ fixtures: new FixtureBuilder().build() }, |
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.
Only the fixture has changed, the rest is just lint formatting
@@ -34,8 +31,7 @@ describe('Dapp interactions', function () { | |||
await driver.fill('#password', 'correct horse battery staple'); | |||
await driver.press('#password', driver.Key.ENTER); | |||
|
|||
// Connect to Dapp0 | |||
await connectDappWithExtensionPopup(driver, 0); |
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 do not actually need to connect to the dapp to click the add ethereum chain button
@@ -78,8 +76,7 @@ describe('Dapp interactions', function () { | |||
await driver.fill('#password', 'correct horse battery staple'); | |||
await driver.press('#password', driver.Key.ENTER); | |||
|
|||
// Connect to Dapp0 | |||
await connectDappWithExtensionPopup(driver, 0); |
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 can use the fixture to connect to the dapp
@@ -34,7 +39,7 @@ describe('Editing Confirm Transaction', function () { | |||
'.currency-display-component__text', | |||
); | |||
const transactionAmount = transactionAmounts[0]; | |||
assert.equal(await transactionAmount.getText(), '2.2'); | |||
assert.equal(await transactionAmount.getText(), '1'); |
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.
The value has changed as we are now reusing an existing transaction
@@ -112,7 +122,7 @@ describe('Editing Confirm Transaction', function () { | |||
'.currency-display-component__text', | |||
); | |||
const transactionAmount = transactionAmounts[0]; | |||
assert.equal(await transactionAmount.getText(), '2.2'); | |||
assert.equal(await transactionAmount.getText(), '1'); |
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.
The value has changed as we are now reusing an existing transaction
@@ -194,7 +209,7 @@ describe('Editing Confirm Transaction', function () { | |||
await driver.press('#password', driver.Key.ENTER); | |||
|
|||
// open dapp and connect | |||
await connectDappWithExtensionPopup(driver); |
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 can use the fixture to connect to the dapp
@@ -315,7 +344,6 @@ describe('MetaMask Import UI', function () { | |||
const importJsonFile = path.join( | |||
__dirname, | |||
'..', | |||
'fixtures', |
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.
moved this file out of the fixture folder as its not a fixture
@@ -39,26 +42,9 @@ describe('Test Snap bip-44', function () { | |||
// connect the snap | |||
await driver.clickElement('#connectBip44'); | |||
|
|||
// switch to metamask extension and click connect |
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.
Connect to the snap test dapp in the fixture
@@ -31,26 +34,9 @@ describe('Test Snap Confirm', function () { | |||
await driver.fill('#snapId1', 'npm:@metamask/test-snap-confirm'); | |||
await driver.clickElement('#connectHello'); | |||
|
|||
// switch to metamask extension and click connect | |||
await driver.waitUntilXWindowHandles(2, 5000, 10000); |
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.
Connect to the snap test dapp in the fixture
@@ -32,25 +35,8 @@ describe('Test Snap Error', function () { | |||
await driver.fill('#snapId2', 'npm:@metamask/test-snap-error'); | |||
await driver.clickElement('#connectError'); | |||
|
|||
// switch to metamask extension and click connect |
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.
Connect to the snap test dapp in the fixture
@@ -40,25 +43,9 @@ describe('Test Snap manageState', function () { | |||
// connect the snap | |||
await driver.clickElement('#connectManageState'); | |||
|
|||
// switch to metamask extension and click connect |
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.
Connect to the snap test dapp in the fixture
@@ -40,25 +43,9 @@ describe('Test Snap Notification', function () { | |||
// connect the snap | |||
await driver.clickElement('#connectNotification'); | |||
|
|||
// switch to metamask extension and click connect |
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.
Connect to the snap test dapp in the fixture
Builds ready [be3c4d7]
Page Load Metrics (2506 ± 145 ms)
|
Builds ready [3f7e590]
Page Load Metrics (2357 ± 116 ms)
|
3f7e590
to
3f502af
Compare
let windowHandles = await driver.getAllWindowHandles(); | ||
const extensionPage = windowHandles[0]; | ||
await driver.switchToWindowWithTitle( | ||
'MetaMask Notification', | ||
windowHandles, | ||
); | ||
await driver.clickElement( |
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.
Connect to the snap test dapp in the fixture
@@ -18,7 +19,19 @@ describe('Failing contract interaction ', function () { | |||
await withFixtures( | |||
{ | |||
dapp: true, | |||
fixtures: 'connected-state', | |||
fixtures: new FixtureBuilder() | |||
.withNetworkController({ |
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.
The send failing transaction is a type 2 transaction
hide `Protect your funds` dialog remove browser environment remove default network details hide dismiss seed backup reminder recursively merges fixture data
wait for window
ce88224
95e4572
to
ce88224
Compare
const networkDisplay = await driver.findElement('.network-display'); | ||
const networkDisplay = await driver.findElement( | ||
'[data-testid="network-display"]', | ||
); |
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.
Nothings changed here, this is the same element as the original test, just using a different selector
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.
LGTM!
Builds ready [2327778]
Page Load Metrics (2143 ± 99 ms)
|
Explanation
Fixes: #14340
Previously multiple e2e tests were coupled to a single state.json file.
This PR decouples the state files, and provides an easy to use api to create fixture state, enabling more granular control of each individual tests state.
There are two initial state/fixture objects, default fixture and onboarding fixture.
The onboarding fixture provides the state of a new user pre onboarding
The default fixture provides the state of an existing user post onboarding
More Information
Screenshots/Screencaps
Before
After
Manual Testing Steps
Pre-Merge Checklist
+ If there are functional changes: