Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add integration test for signing and submitting alert and fix b… #28616

Merged
merged 9 commits into from
Dec 5, 2024
69 changes: 69 additions & 0 deletions test/integration/confirmations/transactions/alerts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,73 @@ describe('Contract Interaction Confirmation Alerts', () => {
await screen.findByTestId('alert-modal-action-showGasFeeModal'),
).toHaveTextContent('Update gas options');
});

it('displays the alert for signing and submitting alerts', async () => {
const account =
mockMetaMaskState.internalAccounts.accounts[
mockMetaMaskState.internalAccounts
.selectedAccount as keyof typeof mockMetaMaskState.internalAccounts.accounts
];

const mockedMetaMaskState =
getMetaMaskStateWithUnapprovedApproveTransaction(account.address);
const unapprovedTransaction = mockedMetaMaskState.transactions[0];
const signedTransaction = getUnapprovedApproveTransaction(
account.address,
randomUUID(),
pendingTransactionTime - 1000,
);
signedTransaction.status = 'signed';

await act(async () => {
await integrationTestRender({
preloadedState: {
...mockedMetaMaskState,
gasEstimateType: 'none',
pendingApprovalCount: 2,
pendingApprovals: {
[pendingTransactionId]: {
id: pendingTransactionId,
origin: 'origin',
time: pendingTransactionTime,
type: ApprovalType.Transaction,
requestData: {
txId: pendingTransactionId,
},
requestState: null,
expectsResult: false,
},
[signedTransaction.id]: {
id: signedTransaction.id,
origin: 'origin',
time: pendingTransactionTime - 1000,
type: ApprovalType.Transaction,
requestData: {
txId: signedTransaction.id,
},
requestState: null,
expectsResult: false,
},
},
transactions: [unapprovedTransaction, signedTransaction],
},
backgroundConnection: backgroundConnectionMocked,
});
});

const alerts = await screen.findAllByTestId('confirm-banner-alert');

expect(
alerts.some((alert) =>
alert.textContent?.includes(
'This transaction will only go through once your previous transaction is complete.',
),
),
).toBe(true);

expect(
await screen.findByTestId('confirm-footer-button'),
).toBeInTheDocument();
expect(await screen.findByTestId('confirm-footer-button')).toBeEnabled();
});
});
Loading