Skip to content

Commit

Permalink
fix:test:e2e: add alert metrics to maliciouis-signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
digiwand committed Sep 9, 2024
1 parent 57c125c commit 9d4c243
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this
'sign_in_with_ethereum',
],
location: 'confirmation',
expectedProps: {
alert_action_clicked: [],
alert_key_clicked: [],
alert_resolved: [],
alert_resolved_count: 0,
alert_triggered: ['requestFrom'],
alert_triggered_count: 1,
alert_visualized: [],
alert_visualized_count: 0,
},
});
},
mockSignatureRejected,
Expand Down Expand Up @@ -105,6 +115,16 @@ describe('Malicious Confirmation Signature - Bad Domain @no-mmi', function (this
'sign_in_with_ethereum',
],
location: 'alert_friction_modal',
expectedProps: {
alert_action_clicked: [],
alert_key_clicked: [],
alert_resolved: [],
alert_resolved_count: 0,
alert_triggered: ['requestFrom'],
alert_triggered_count: 1,
alert_visualized: ['requestFrom'],
alert_visualized_count: 1,
},
});
},
mockSignatureRejected,
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/tests/confirmations/signatures/signature-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type AssertSignatureMetricsOptions = {
primaryType?: string;
uiCustomizations?: string[];
location?: string;
expectedProps?: Record<string, unknown>;
};

type SignatureEventProperty = {
Expand All @@ -43,6 +44,13 @@ type SignatureEventProperty = {
location?: string;
};

/**
* Generates expected signature metric properties
*
* @param signatureType
* @param primaryType
* @param uiCustomizations
*/
function getSignatureEventProperty(
signatureType: string,
primaryType: string,
Expand Down Expand Up @@ -113,6 +121,7 @@ export async function assertSignatureRejectedMetrics({
primaryType = '',
uiCustomizations = ['redesigned_confirmation'],
location,
expectedProps = {},
}: AssertSignatureMetricsOptions) {
const events = await getEventPayloads(driver, mockedEndpoints);
const signatureEventProperty = getSignatureEventProperty(
Expand All @@ -128,6 +137,7 @@ export async function assertSignatureRejectedMetrics({
{
...signatureEventProperty,
location,
...expectedProps,
},
'Signature Rejected event properties do not match',
);
Expand Down

0 comments on commit 9d4c243

Please sign in to comment.