Skip to content

Commit

Permalink
fix: Hide contract interaction redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Sep 23, 2024
1 parent b906eea commit 7dcfcaf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const getMetaMaskStateWithMaliciousUnapprovedContractInteraction = (
};
};

describe('Contract Interaction Confirmation', () => {
describe.skip('Contract Interaction Confirmation', () => {
beforeEach(() => {
jest.resetAllMocks();
setupSubmitRequestToBackgroundMocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,6 @@ exports[`Header should match snapshot with transaction confirmation 1`] = `
</button>
</div>
</div>
<div
class="mm-box mm-box--background-color-transparent mm-box--rounded-md"
>
<button
aria-label="Advanced tx details"
class="mm-box mm-button-icon mm-button-icon--size-md mm-box--display-inline-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-icon-default mm-box--background-color-transparent mm-box--rounded-lg"
data-testid="header-advanced-details-button"
>
<span
class="mm-box mm-icon mm-icon--size-md mm-box--display-inline-block mm-box--color-inherit"
style="mask-image: url('./images/icons/customize.svg');"
/>
</button>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,12 @@ describe('usePendingTransactionAlerts', () => {
).toEqual([]);
});

it('returns alert if submitted transaction', () => {
it('returns no alert if submitted transaction because transaction type is not valid', () => {
const alerts = runHook({
currentConfirmation: CONFIRMATION_MOCK,
transactions: [TRANSACTION_META_MOCK],
});

expect(alerts).toEqual([
{
field: RowAlertKey.Speed,
key: 'pendingTransactions',
message:
'This transaction won’t go through until a previous transaction is complete. Learn how to cancel or speed up a transaction.',
reason: 'Pending transaction',
severity: Severity.Warning,
},
]);
expect(alerts).toEqual([]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('useSigningOrSubmittingAlerts', () => {
).toEqual([]);
});

it('returns alerts if transaction on different chain', () => {
it('doesnt return alerts if transaction on different chain because transaction type is not valid', () => {
expect(
runHook({
currentConfirmation: CONFIRMATION_MOCK,
Expand All @@ -89,7 +89,7 @@ describe('useSigningOrSubmittingAlerts', () => {
},
],
}),
).toEqual([EXPECTED_ALERT]);
).toEqual([]);
});

it('returns no alerts if transaction has alternate status', () => {
Expand All @@ -112,25 +112,25 @@ describe('useSigningOrSubmittingAlerts', () => {
).toEqual([]);
});

it('returns alert if signed transaction', () => {
it('doesnt return alert if signed transaction because type is not valid', () => {
const alerts = runHook({
currentConfirmation: CONFIRMATION_MOCK,
transactions: [
{ ...TRANSACTION_META_MOCK, status: TransactionStatus.signed },
],
});

expect(alerts).toEqual([EXPECTED_ALERT]);
expect(alerts).toEqual([]);
});

it('returns alert if approved transaction', () => {
it('doesnt return alert if approved transaction because type is not valid', () => {
const alerts = runHook({
currentConfirmation: CONFIRMATION_MOCK,
transactions: [
{ ...TRANSACTION_META_MOCK, status: TransactionStatus.approved },
],
});

expect(alerts).toEqual([EXPECTED_ALERT]);
expect(alerts).toEqual([]);
});
});
86 changes: 0 additions & 86 deletions ui/pages/confirmations/hooks/useConfirmationAlertMetrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,90 +92,4 @@ describe('useConfirmationAlertMetrics', () => {
expect(result.current.trackInlineAlertClicked).toBeInstanceOf(Function);
expect(result.current.trackAlertActionClicked).toBeInstanceOf(Function);
});

it('calls updateTransactionEventFragment with correct properties on initialization', () => {
renderHookWithProvider(() => useConfirmationAlertMetrics(), STATE_MOCK);

expect(mockUpdateTransactionEventFragment).toHaveBeenCalledWith(
{ properties: EXPECTED_PROPERTIES_BASE },
OWNER_ID_MOCK,
);
});

const testCases = [
{
description: 'updates metrics properties when trackAlertRender is called',
alertKey: AlertsName.GasFeeLow,
action: 'trackAlertRender',
expectedProperties: {
alert_visualized: [ALERT_NAME_METRICS_MOCK],
alert_visualized_count: 1,
},
},
{
description:
'updates metrics properties when trackInlineAlertClicked is called',
alertKey: AlertsName.GasFeeLow,
action: 'trackInlineAlertClicked',
expectedProperties: {
alert_key_clicked: [ALERT_NAME_METRICS_MOCK],
},
},
{
description:
'updates metrics properties when trackAlertActionClicked is called',
alertKey: AlertsName.GasFeeLow,
action: 'trackAlertActionClicked',
expectedProperties: {
alert_action_clicked: [ALERT_NAME_METRICS_MOCK],
},
},
{
description:
'updates metrics properties when receives alertKey as a valid UUID',
alertKey: UUID_ALERT_KEY_MOCK,
action: 'trackAlertRender',
expectedProperties: {
alert_visualized: [ALERTS_NAME_METRICS[AlertsName.Blockaid]],
alert_visualized_count: 1,
},
},
];

// @ts-expect-error This is missing from the Mocha type definitions
it.each(testCases)(
'$description',
({
alertKey,
action,
expectedProperties,
}: {
description: string;
alertKey: string;
action:
| 'trackAlertRender'
| 'trackInlineAlertClicked'
| 'trackAlertActionClicked';
expectedProperties: Record<string, unknown>;
}) => {
const finalExpectedProperties = {
...EXPECTED_PROPERTIES_BASE,
...expectedProperties,
};

const { result } = renderHookWithProvider(
() => useConfirmationAlertMetrics(),
STATE_MOCK,
);

act(() => {
result.current[action](alertKey);
});

expect(mockUpdateTransactionEventFragment).toHaveBeenCalledWith(
{ properties: finalExpectedProperties },
OWNER_ID_MOCK,
);
},
);
});
8 changes: 4 additions & 4 deletions ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('useCurrentConfirmation', () => {
isRedesignedConfirmationsDeveloperEnabled: true,
});

expect(currentConfirmation).toStrictEqual(TRANSACTION_MOCK);
expect(currentConfirmation).toBeUndefined();
});

it('returns message matching ID param', () => {
Expand Down Expand Up @@ -266,10 +266,10 @@ describe('useCurrentConfirmation', () => {
isRedesignedConfirmationsDeveloperEnabled: true,
});

expect(currentConfirmation).toStrictEqual(TRANSACTION_MOCK);
expect(currentConfirmation).toBeUndefined();
});

it('returns if env var and user settings are enabled and transaction has correct type', () => {
it('returns undefined if env var and user settings are enabled and transaction type is not supported', () => {
const currentConfirmation = runHook({
pendingApprovals: [{ ...APPROVAL_MOCK, type: ApprovalType.Transaction }],
transaction: {
Expand All @@ -280,7 +280,7 @@ describe('useCurrentConfirmation', () => {
isRedesignedConfirmationsDeveloperEnabled: true,
});

expect(currentConfirmation).toStrictEqual(TRANSACTION_MOCK);
expect(currentConfirmation).toStrictEqual(undefined);
});

describe('useCurrentConfirmation with env var', () => {
Expand Down

0 comments on commit 7dcfcaf

Please sign in to comment.