Skip to content

Commit f35e29d

Browse files
authored
feat(STX-169): test transaction-controller init for automatic gas fee config (#36153)
<!-- 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** feat(STX-169): test transaction-controller init for automatic gas fee config. Following #35423 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/36153?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: ## **Related issues** Fixes: ## **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** - [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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Add parameterized tests verifying automatic gas fee updates are disabled for swap/bridge (and approvals) and enabled for contract interactions in TransactionController init. > > - **Tests (TransactionController init)**: > - Add parameterized checks for `isAutomaticGasFeeUpdateEnabled` in `app/scripts/controller-init/confirmations/transaction-controller-init.test.ts`: > - `swap`, `swapApproval`, `bridge`, `bridgeApproval` → `false` > - `contractInteraction` → `true` > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 01b18eb. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c402448 commit f35e29d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

app/scripts/controller-init/confirmations/transaction-controller-init.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Messenger } from '@metamask/base-controller';
22
import { NetworkController } from '@metamask/network-controller';
3+
// Mocha type definitions are conflicting with Jest
4+
import { it as jestIt } from '@jest/globals';
35
import {
6+
TransactionMeta,
7+
TransactionType,
48
TransactionController,
59
TransactionControllerMessenger,
610
TransactionControllerOptions,
11+
TransactionStatus,
712
} from '@metamask/transaction-controller';
813
import {
914
getTransactionControllerInitMessenger,
@@ -188,4 +193,33 @@ describe('Transaction Controller Init', () => {
188193

189194
expect(pendingTransactions?.isResubmitEnabled?.()).toBe(false);
190195
});
196+
197+
jestIt.each([
198+
['swap', TransactionType.swap, false],
199+
['swapApproval', TransactionType.swapApproval, false],
200+
['bridge', TransactionType.bridge, false],
201+
['bridgeApproval', TransactionType.bridgeApproval, false],
202+
['contractInteraction', TransactionType.contractInteraction, true],
203+
])(
204+
'disables automatic gas fee updates for %s transactions',
205+
(_label, type, gasFeeUpdateEnabled) => {
206+
const isAutomaticGasFeeUpdateEnabled = testConstructorOption(
207+
'isAutomaticGasFeeUpdateEnabled',
208+
);
209+
210+
const tx: TransactionMeta = {
211+
id: '1',
212+
type,
213+
chainId: CHAIN_ID_MOCK,
214+
networkClientId: 'test-network',
215+
status: TransactionStatus.unapproved,
216+
time: Date.now(),
217+
txParams: {
218+
from: '0x0000000000000000000000000000000000000000',
219+
},
220+
};
221+
222+
expect(isAutomaticGasFeeUpdateEnabled?.(tx)).toBe(gasFeeUpdateEnabled);
223+
},
224+
);
191225
});

0 commit comments

Comments
 (0)