Skip to content

Commit a8379e8

Browse files
authored
test: re-enable bridge metrics e2e tests (#35757)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Re-enables skipped bridge metrics e2e test. The initial version got flaky after unified swaps and deep linking were introduced so we temporarily disabled it until the unified metrics were finalized. To mitigate the flakiness I updated expected event counts to be more flexible, while still verifying that important events are published <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/35757?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-2668 ## **Manual testing steps** 1. N/A ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 137c468 commit a8379e8

File tree

3 files changed

+47
-73
lines changed

3 files changed

+47
-73
lines changed

test/e2e/page-objects/pages/bridge/quote-page.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ class BridgeQuotePage {
9393
// 1. Network selection modal (if destination is pre-populated and different from desired network)
9494
// 2. Token picker with network badge (if destination is empty or on the correct network)
9595

96-
// Wait a moment to see what modal appears
97-
await this.driver.delay(500);
98-
9996
// Check if we're in the network selection modal (has network options visible)
10097
const networkOptionExists = await this.driver.isElementPresent(
10198
`[data-testid="${quote.toChain}"]`,
@@ -121,12 +118,12 @@ class BridgeQuotePage {
121118
tag: 'p',
122119
text: 'Fetching quotes...',
123120
},
124-
{ waitAtLeastGuard: 5000 },
121+
{ waitAtLeastGuard: 1000 },
125122
);
126123
};
127124

128125
waitForQuote = async () => {
129-
await this.driver.waitForSelector(this.submitButton, { timeout: 60000 });
126+
await this.driver.waitForSelector(this.submitButton, { timeout: 30000 });
130127
};
131128

132129
submitQuote = async () => {

test/e2e/tests/bridge/bridge-test-utils.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,7 @@ export enum EventTypes {
625625
SwapBridgePageViewed = 'Unified SwapBridge Page Viewed',
626626
SwapBridgeInputChanged = 'Unified SwapBridge Input Changed',
627627
SwapBridgeQuotesRequested = 'Unified SwapBridge Quotes Requested',
628-
CrossChainQuotesReceived = 'Cross-chain Quotes Received',
629-
ActionSubmitted = 'Action Submitted',
630-
SwapBridgeSubmitted = 'Unified SwapBridge Submitted',
628+
UnifiedSwapBridgeQuotesReceived = 'Unified SwapBridge Quotes Received',
631629
TransactionAddedAnon = 'Transaction Added Anon',
632630
TransactionAdded = 'Transaction Added',
633631
TransactionSubmittedAnon = 'Transaction Submitted Anon',
@@ -638,7 +636,7 @@ export enum EventTypes {
638636
TransactionFinalized = 'Transaction Finalized',
639637
SwapBridgeCompleted = 'Unified SwapBridge Completed',
640638
UnifiedSwapBridgeSubmitted = 'Unified SwapBridge Submitted',
641-
SwapBridgeTokenFlipped = 'Source and Destination Flipped',
639+
SwapBridgeTokenSwitched = 'Unified SwapBridge Source Destination Flipped',
642640
}
643641

644642
export const EXPECTED_EVENT_TYPES = Object.values(EventTypes);
@@ -741,9 +739,7 @@ export const getBridgeFixtures = (
741739
EventTypes.SwapBridgePageViewed,
742740
EventTypes.SwapBridgeInputChanged,
743741
EventTypes.SwapBridgeQuotesRequested,
744-
EventTypes.CrossChainQuotesReceived,
745-
EventTypes.ActionSubmitted,
746-
EventTypes.SwapBridgeSubmitted,
742+
EventTypes.UnifiedSwapBridgeQuotesReceived,
747743
EventTypes.TransactionAddedAnon,
748744
EventTypes.TransactionAdded,
749745
EventTypes.TransactionSubmittedAnon,
@@ -755,7 +751,7 @@ export const getBridgeFixtures = (
755751
EventTypes.SwapBridgeCompleted,
756752
EventTypes.UnifiedSwapBridgeSubmitted,
757753
EventTypes.SwapBridgeInputChanged,
758-
EventTypes.SwapBridgeTokenFlipped,
754+
EventTypes.SwapBridgeTokenSwitched,
759755
],
760756
{ shouldAlwaysMatch: true },
761757
);

test/e2e/tests/metrics/bridge.spec.ts

Lines changed: 41 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ const quote = {
2626

2727
describe('Bridge tests', function (this: Suite) {
2828
this.timeout(160000);
29-
// eslint-disable-next-line mocha/no-skipped-tests
30-
it.skip('Execute multiple bridge transactions', async function () {
29+
it('Execute multiple bridge transactions', async function () {
3130
await withFixtures(
3231
getBridgeFixtures(
3332
this.test?.fullTitle(),
@@ -111,8 +110,12 @@ describe('Bridge tests', function (this: Suite) {
111110
*/
112111

113112
assert(
114-
swapBridgeInputChanged.length === 17,
115-
'Should have at least 17 input change events',
113+
swapBridgeInputChanged.length === 20,
114+
'Should have at least 20 input change events',
115+
);
116+
117+
const swapBridgeInputChangedKeys = new Set(
118+
swapBridgeInputChanged.map((event) => event.properties.input),
116119
);
117120

118121
const inputTypes = [
@@ -122,38 +125,42 @@ describe('Bridge tests', function (this: Suite) {
122125
'token_destination',
123126
'chain_destination',
124127
];
125-
const hasAllInputs = inputTypes.every((inputType) =>
126-
swapBridgeInputChanged.some(
127-
(event) =>
128-
event.event === EventTypes.SwapBridgeInputChanged &&
129-
event.properties.input === inputType,
130-
),
128+
129+
assert.ok(
130+
swapBridgeInputChangedKeys.size === 5,
131+
'Should have 5 input types',
131132
);
132-
assert.ok(hasAllInputs, 'Should have 5 input types');
133+
134+
inputTypes.forEach((inputType) => {
135+
assert.ok(
136+
swapBridgeInputChangedKeys.has(inputType),
137+
`Missing input type: ${inputType}`,
138+
);
139+
});
133140

134141
const swapBridgeQuotesRequested = findEventsByName(
135142
EventTypes.SwapBridgeQuotesRequested,
136143
);
137-
assert.ok(swapBridgeQuotesRequested.length === 3);
138-
assert.ok(
139-
swapBridgeQuotesRequested[0].properties.chain_id_source ===
140-
'eip155:1' &&
141-
swapBridgeQuotesRequested[0].properties.chain_id_destination ===
142-
'eip155:59144' &&
143-
swapBridgeQuotesRequested[0].properties.token_address_source ===
144+
145+
// Quotes can be requested while test is waiting for ui updates, so we expect at least 2 events
146+
assert.ok(swapBridgeQuotesRequested.length >= 2);
147+
const firstQuoteRequest = swapBridgeQuotesRequested.find((event) => {
148+
return (
149+
event.properties.chain_id_source === 'eip155:1' &&
150+
event.properties.chain_id_destination === 'eip155:59144' &&
151+
event.properties.token_address_source ===
144152
'eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f' &&
145-
swapBridgeQuotesRequested[0].properties
146-
.token_address_destination === 'eip155:59144/slip44:60' &&
147-
swapBridgeQuotesRequested[0].properties.swap_type ===
148-
'crosschain' &&
149-
swapBridgeQuotesRequested[0].properties.token_symbol_source ===
150-
'DAI' &&
151-
swapBridgeQuotesRequested[0].properties.token_symbol_destination ===
152-
'ETH',
153-
);
153+
event.properties.token_address_destination ===
154+
'eip155:59144/slip44:60' &&
155+
event.properties.swap_type === 'crosschain' &&
156+
event.properties.token_symbol_source === 'DAI' &&
157+
event.properties.token_symbol_destination === 'ETH'
158+
);
159+
});
160+
assert.ok(firstQuoteRequest, 'First quote request not found');
154161

155162
const crossChainQuotesReceived = findEventsByName(
156-
EventTypes.CrossChainQuotesReceived,
163+
EventTypes.UnifiedSwapBridgeQuotesReceived,
157164
);
158165
// The flow receives 2 quotes, so we expect 2 events
159166
assert.ok(crossChainQuotesReceived.length === 2);
@@ -163,28 +170,10 @@ describe('Bridge tests', function (this: Suite) {
163170
crossChainQuotesReceived[0].properties.chain_id_destination ===
164171
'eip155:59144' &&
165172
crossChainQuotesReceived[0].properties.token_address_source ===
166-
'0x6b175474e89094c44da98b954eedeac495271d0f' &&
173+
'eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f' &&
167174
crossChainQuotesReceived[0].properties.token_address_destination ===
168-
'0x0000000000000000000000000000000000000000' &&
169-
crossChainQuotesReceived[0].properties.swap_type ===
170-
'crosschain-v1' &&
171-
crossChainQuotesReceived[0].properties.token_symbol_source ===
172-
'DAI' &&
173-
crossChainQuotesReceived[0].properties.token_symbol_destination ===
174-
'ETH',
175-
);
176-
177-
const actionSubmitted = findEventsByName(EventTypes.ActionSubmitted);
178-
assert.ok(actionSubmitted.length === 1);
179-
assert.ok(
180-
actionSubmitted[0].properties.action_type === 'crosschain-v1' &&
181-
actionSubmitted[0].properties.category === 'Cross Chain Swaps' &&
182-
actionSubmitted[0].properties.token_address_source ===
183-
'0x6b175474e89094c44da98b954eedeac495271d0f' &&
184-
actionSubmitted[0].properties.token_address_destination ===
185-
'0x0000000000000000000000000000000000000000' &&
186-
actionSubmitted[0].properties.token_symbol_source === 'DAI' &&
187-
actionSubmitted[0].properties.token_symbol_destination === 'ETH',
175+
'eip155:59144/slip44:60' &&
176+
crossChainQuotesReceived[0].properties.swap_type === 'crosschain',
188177
);
189178

190179
const unifiedSwapBridgeSubmitted = findEventsByName(
@@ -194,13 +183,9 @@ describe('Bridge tests', function (this: Suite) {
194183
assert.ok(unifiedSwapBridgeSubmitted.length === 1);
195184
assert.ok(
196185
unifiedSwapBridgeSubmitted[0].properties.action_type ===
197-
'crosschain-v1' &&
186+
'swapbridge-v1' &&
198187
unifiedSwapBridgeSubmitted[0].properties.category ===
199188
'Unified SwapBridge' &&
200-
unifiedSwapBridgeSubmitted[0].properties.token_address_source ===
201-
'eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f' &&
202-
unifiedSwapBridgeSubmitted[0].properties
203-
.token_address_destination === 'eip155:59144/slip44:60' &&
204189
unifiedSwapBridgeSubmitted[0].properties.token_symbol_source ===
205190
'DAI' &&
206191
unifiedSwapBridgeSubmitted[0].properties
@@ -327,21 +312,17 @@ describe('Bridge tests', function (this: Suite) {
327312
assert.ok(swapBridgeCompletedEvents.length === 1);
328313
assert.ok(
329314
swapBridgeCompletedEvents[0].properties.action_type ===
330-
'crosschain-v1' &&
315+
'swapbridge-v1' &&
331316
swapBridgeCompletedEvents[0].properties.category ===
332317
'Unified SwapBridge' &&
333-
swapBridgeCompletedEvents[0].properties.token_address_source ===
334-
'eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f' &&
335-
swapBridgeCompletedEvents[0].properties
336-
.token_address_destination === 'eip155:59144/slip44:60' &&
337318
swapBridgeCompletedEvents[0].properties.token_symbol_source ===
338319
'DAI' &&
339320
swapBridgeCompletedEvents[0].properties.token_symbol_destination ===
340321
'ETH',
341322
);
342323

343324
const swapBridgeTokenFlippedEvents = findEventsByName(
344-
EventTypes.SwapBridgeTokenFlipped,
325+
EventTypes.SwapBridgeTokenSwitched,
345326
);
346327
assert.ok(swapBridgeTokenFlippedEvents.length === 1);
347328
},

0 commit comments

Comments
 (0)