Skip to content

test: Add swap quote selector component view tests#27767

Open
davibroc wants to merge 2 commits into
mainfrom
test/add-swap-quote-selector-cvt
Open

test: Add swap quote selector component view tests#27767
davibroc wants to merge 2 commits into
mainfrom
test/add-swap-quote-selector-cvt

Conversation

@davibroc
Copy link
Copy Markdown
Contributor

@davibroc davibroc commented Mar 20, 2026

Description

Changelog

CHANGELOG entry:

Related issues

Fixes:

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

Low Risk
Low risk: adds new component-view tests and a test renderer helper without changing production logic.

Overview
Adds component-view tests for QuoteSelectorView covering the info text, loading placeholders, and loaded quote-row rendering (provider name, Total Cost label, destination token symbol, and the Lowest cost recommended badge).

Introduces a dedicated renderQuoteSelectorView test helper that builds the Bridge preset state (optionally deterministic fiat + state overrides) and renders the screen via renderComponentViewScreen.

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

@davibroc davibroc requested a review from a team as a code owner March 20, 2026 21:13
@github-actions
Copy link
Copy Markdown
Contributor

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 Mar 20, 2026
@github-actions github-actions Bot added size-M risk-low Low testing needed · Low bug introduction risk labels Mar 20, 2026
@davibroc davibroc force-pushed the test/add-swap-quote-selector-cvt branch from d45652d to 014f254 Compare March 20, 2026 22:24
@davibroc davibroc requested a review from a team as a code owner March 20, 2026 22:24
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 20, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@davibroc davibroc added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 20, 2026
@davibroc davibroc changed the title Test/add swap quote selector cvt test: Add swap quote selector component view tests Mar 20, 2026
Three issues corrected:

- Add `setGlobalDevModeChecks({ inputStabilityCheck: 'never' })` in
  beforeAll to suppress the reselect false-positive thrown by
  selectBridgeAppState (which spreads controller slices into a new object
  on every call and is app code we cannot change).

- Add missing `trade` field to makeEvmQuote factory; calcRelayerFee
  destructures { quote, trade } from the quote response and crashes when
  trade is absent.

- Replace the post-render dispatch spy with a store state assertion.
  useDispatch() captures store.dispatch at mount time, so a spy set up
  after render is never called. Reading selectSelectedQuoteRequestId from
  the store after the press is the correct pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 97%
click to see 🤖 AI reasoning details

E2E Test Selection:
Both changed files are purely new test files with no production code changes:

  1. tests/component-view/renderers/quoteSelectorView.ts - A new renderer helper for the component-view test framework, used to render the Bridge QuoteSelectorView in tests.
  2. app/components/UI/Bridge/components/QuoteSelectorView/QuoteSelectorView.view.test.tsx - New Jest/component-view unit tests for the Bridge QuoteSelectorView component.

Neither file modifies any production app code, E2E test files (Detox), shared components, controllers, navigation, or any other runtime logic. The changes are entirely isolated to the Jest/component-view test layer. No E2E test tags are needed since no app behavior has changed and no Detox test infrastructure was modified. Running E2E tests would provide no additional validation value for these purely additive test file changes.

Performance Test Selection:
No production code was changed — only new Jest/component-view test files were added. There is no performance impact to measure.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@racitores racitores left a comment

Choose a reason for hiding this comment

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

Some comments about cv test rules to follow

Comment on lines +84 to +92
engine: {
backgroundState: {
BridgeController: {
quotes: [quote],
recommendedQuote: quote,
quotesLastFetched: now,
quotesLoadingStatus: 'SUCCEEDED',
quotesRefreshCount: 0,
quoteFetchError: null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is reused on all tests with differences. Maybe can be moved under a preset?

// selectBridgeAppState spreads multiple controller slices into a new object on every call,
// which causes reselect's inputStabilityCheck to throw a false positive in tests.
beforeAll(() => {
setGlobalDevModeChecks({ inputStabilityCheck: 'never' });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this needs to be restored afterAll

});
});

it('shows provider name and total cost label when quotes are available', async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should avoid this type of tests without actions or a few more actions. We should avoid render tests. Give it a though to see if some tests can be modify to be a more user oriented test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW, can we try to include a negative test, like if we have no quotes or something similar that could break the ui?

} as unknown as Record<string, unknown>,
});

expect(await findByText(strings('bridge.lowest_cost'))).toBeOnTheScreen();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

all consts should be moved to the testIds files. Feel fee to expand them in the app if needed for testing

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 risk-low Low testing needed · Low bug introduction risk size-M team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants