Skip to content

Conversation

@hjetpoluru
Copy link
Contributor

@hjetpoluru hjetpoluru commented Dec 1, 2025

Description

Add e2e test for the gas less swap

Changelog

CHANGELOG entry: null

Related issues

Fixes:
https://consensyssoftware.atlassian.net/browse/MMQA-1178

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Adds an e2e test for gasless ETH→MUSD swap, with new selectors and page actions to tap Max and verify “Included” network fee, plus mock quote data.

  • E2E Test:
    • Add e2e/specs/swaps/gasless-swap-crosschain.spec.ts to validate gasless ETH→MUSD swap flow:
      • Taps Max, verifies Network fee shows Included, confirms swap, and asserts activity status is confirmed.
  • Page Object/Selectors:
    • e2e/pages/swaps/QuoteView.ts:
      • Add maxLink, includedLabel getters and tapMax() action.
    • e2e/selectors/swaps/QuoteView.selectors.ts:
      • Add text selectors MAX and INCLUDED.
  • Mocks/Fixtures:
    • e2e/specs/swaps/helpers/constants.ts: add GASLESS_SWAP_QUOTES_ETH_MUSD mock response.
    • Test wiring includes quote mock via setupMockRequest.

Written by Cursor Bugbot for commit 957c2dd. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

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.

@metamaskbot metamaskbot added the team-qa QA team label Dec 1, 2025
@github-actions github-actions bot added the size-M label Dec 1, 2025
@hjetpoluru hjetpoluru marked this pull request as ready for review December 4, 2025 22:42
@hjetpoluru hjetpoluru requested a review from a team as a code owner December 4, 2025 22:42
@hjetpoluru hjetpoluru added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Dec 4, 2025
jest.setTimeout(120000);
});

it('should complete swap ETH to MUSD with gas included', async (): Promise<void> => {
Copy link

Choose a reason for hiding this comment

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

Bug: Test name uses prohibited "should" prefix (Bugbot Rules)

The test name 'should complete swap ETH to MUSD with gas included' uses the prohibited "should" prefix. According to the E2E testing guidelines, test names must not use "should" - this is a hard rule with zero exceptions. The test name needs to be action-oriented, such as 'completes swap ETH to MUSD with gas included'.

Fix in Cursor Fix in Web

await WalletView.tapWalletSwapButton();
await device.disableSynchronization();
await Assertions.expectElementToBeVisible(QuoteView.selectAmountLabel, {
description: 'Swap amount selection should be visible',
Copy link

Choose a reason for hiding this comment

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

Bug: Assertion descriptions use prohibited "should" phrasing (Bugbot Rules)

Multiple assertion description parameters use "should" phrasing (lines 78, 87, 92, 97, 104, 112), such as 'Swap amount selection should be visible'. According to the testing guidelines, descriptions need to use action-oriented language without "should", for example 'Swap amount selection is visible' or 'Network fee label visible'.

Additional Locations (2)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

The changes are entirely within the E2E test infrastructure for swap functionality:

  1. New test file: gasless-swap-crosschain.spec.ts is explicitly tagged with SmokeTrade and tests gasless swap functionality (ETH to MUSD with gas included).

  2. Page object additions: New methods added to QuoteView.ts (maxLink, includedLabel, tapMax()) support the new gasless swap test.

  3. Selector additions: New selectors (MAX, INCLUDED) in QuoteView.selectors.ts are used by the new page object methods.

  4. Mock data: New constant GASLESS_SWAP_QUOTES_ETH_MUSD in constants.ts provides mock API response for the gasless swap test.

These changes:

  • Are completely self-contained within E2E test infrastructure
  • Do not modify any production application code
  • The new test explicitly uses the SmokeTrade tag
  • Only affect swap/trade testing functionality

Running SmokeTrade is sufficient as it will execute the new test and verify the swap-related test infrastructure changes work correctly.

View GitHub Actions results

jest.setTimeout(120000);
});

it('should complete swap ETH to MUSD with gas included', async (): Promise<void> => {
Copy link

Choose a reason for hiding this comment

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

Bug: Test name uses prohibited "should" prefix (Bugbot Rules)

The test name 'should complete swap ETH to MUSD with gas included' violates the E2E testing guidelines which explicitly prohibit using the prefix "should" in test names. Per the guidelines, the name could be something like 'completes swap ETH to MUSD with gas included' instead. This was also flagged in the PR discussion by @chrisleewilcox.

Fix in Cursor Fix in Web

metadata: { storage: {} },
},
destTokenAmount: '3011431',
minDestTokenAmount: '3759291202',
Copy link

Choose a reason for hiding this comment

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

Bug: Mock data has inverted token amount values

The mock data GASLESS_SWAP_QUOTES_ETH_MUSD has destTokenAmount: '3011431' which is smaller than minDestTokenAmount: '3759291202'. This is logically backwards—the minimum received amount after slippage cannot be greater than the expected destination amount. All other quote mocks in the codebase correctly have destTokenAmount larger than minDestTokenAmount. This could cause incorrect behavior when testing UI elements that rely on these values.

Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

],
testSpecificMock: async (mockServer) => {
// Mock ETH->MUSD quote (gasless swap)
await setupMockRequest(mockServer, {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see the /getQuote call but I don't see any mock for the calls that are done after the swap is submitted. How does it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-M team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants