Skip to content

Commit

Permalink
test: Add integration test for low gas fees alert (#27015)
Browse files Browse the repository at this point in the history
<!--
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**

Adds an integration test to check that the alert for low gas fees is
displayed

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27015?quickstart=1)

## **Related issues**

Fixes:
[#2973](MetaMask/MetaMask-planning#2973)

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
  • Loading branch information
pnarayanaswamy authored Sep 10, 2024
1 parent 9f8651c commit 92c8a06
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/integration/confirmations/transactions/alerts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,52 @@ describe('Contract Interaction Confirmation', () => {
'This transaction won’t go through until a previous transaction is complete. Learn how to cancel or speed up a transaction.',
);
});

it('displays the alert for gas fees too', async () => {
const account =
mockMetaMaskState.internalAccounts.accounts[
mockMetaMaskState.internalAccounts
.selectedAccount as keyof typeof mockMetaMaskState.internalAccounts.accounts
];

const mockedMetaMaskState =
getMetaMaskStateWithUnapprovedApproveTransaction(account.address);

const transaction = mockedMetaMaskState.transactions[0];
transaction.defaultGasEstimates.estimateType = 'low';
transaction.userFeeLevel = 'low';

await act(async () => {
await integrationTestRender({
preloadedState: {
...mockedMetaMaskState,
transactions: [transaction],
},
backgroundConnection: backgroundConnectionMocked,
});
});

act(() => {
fireEvent.click(screen.getByTestId('inline-alert'));
});

expect(await screen.findByTestId('alert-modal')).toBeInTheDocument();

expect(
await screen.findByTestId('alert-modal__selected-alert'),
).toBeInTheDocument();

expect(
await screen.findByTestId('alert-modal__selected-alert'),
).toHaveTextContent(
'When choosing a low fee, expect slower transactions and longer wait times. For faster transactions, choose Market or Aggressive fee options.',
);

expect(
await screen.findByTestId('alert-modal-action-showGasFeeModal'),
).toBeInTheDocument();
expect(
await screen.findByTestId('alert-modal-action-showGasFeeModal'),
).toHaveTextContent('Update gas options');
});
});

0 comments on commit 92c8a06

Please sign in to comment.