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

fix: optimize helper methods for signature e2e #28810

Merged
merged 8 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion test/e2e/tests/confirmations/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ export async function mockSignatureApproved(
await createMockSegmentEvent(mockServer, 'Account Details Opened'),
...anonEvents,
await createMockSegmentEvent(mockServer, 'Signature Approved'),
];
}

export async function mockSignatureApprovedWithDecoding(
mockServer: Mockttp,
withAnonEvents = false,
) {
return [
...(await mockSignatureApproved(mockServer, withAnonEvents)),
await createMockSignatureDecodingEvent(mockServer),
];
}
Expand All @@ -125,11 +134,20 @@ export async function mockSignatureRejected(
return [
await createMockSegmentEvent(mockServer, 'Signature Requested'),
await createMockSegmentEvent(mockServer, 'Signature Rejected'),
await createMockSignatureDecodingEvent(mockServer),
...anonEvents,
];
}

export async function mockSignatureRejectedWithDecoding(
mockServer: Mockttp,
withAnonEvents = false,
) {
return [
...(await mockSignatureRejected(mockServer, withAnonEvents)),
await createMockSignatureDecodingEvent(mockServer),
];
}

export async function mockPermitDecoding(mockServer: Mockttp) {
return [await createMockSignatureDecodingEvent(mockServer)];
}
8 changes: 4 additions & 4 deletions test/e2e/tests/confirmations/signatures/nft-permit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { WINDOW_TITLES } from '../../../helpers';
import { Ganache } from '../../../seeder/ganache';
import { Driver } from '../../../webdriver/driver';
import {
mockSignatureApproved,
mockSignatureRejected,
mockSignatureApprovedWithDecoding,
mockSignatureRejectedWithDecoding,
scrollAndConfirmAndAssertConfirm,
withTransactionEnvelopeTypeFixtures,
} from '../helpers';
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) {

await assertVerifiedResults(driver, publicAddress);
},
mockSignatureApproved,
mockSignatureApprovedWithDecoding,
);
});

Expand Down Expand Up @@ -119,7 +119,7 @@ describe('Confirmation Signature - NFT Permit @no-mmi', function (this: Suite) {
decodingResponse: 'CHANGE',
});
},
mockSignatureRejected,
mockSignatureRejectedWithDecoding,
);
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/tests/confirmations/signatures/permit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Ganache } from '../../../seeder/ganache';
import { Driver } from '../../../webdriver/driver';
import {
mockPermitDecoding,
mockSignatureApproved,
mockSignatureRejected,
mockSignatureApprovedWithDecoding,
mockSignatureRejectedWithDecoding,
scrollAndConfirmAndAssertConfirm,
withTransactionEnvelopeTypeFixtures,
} from '../helpers';
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) {

await assertVerifiedResults(driver, publicAddress);
},
mockSignatureApproved,
mockSignatureApprovedWithDecoding,
);
});

Expand Down Expand Up @@ -111,7 +111,7 @@ describe('Confirmation Signature - Permit @no-mmi', function (this: Suite) {
decodingResponse: 'CHANGE',
});
},
mockSignatureRejected,
mockSignatureRejectedWithDecoding,
);
});

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/tests/confirmations/signatures/signature-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ function compareDecodingAPIResponse(
expectedProperties: Record<string, unknown>,
eventName: string,
) {
if (
!expectedProperties.decoding_response &&
!actualProperties.decoding_response
) {
return;
}
if (
eventName === 'Signature Rejected' ||
eventName === 'Signature Approved'
Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/confirmations/signatures/siwe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
} from './signature-helpers';

describe('Confirmation Signature - SIWE @no-mmi', function (this: Suite) {
this.timeout(200000); // This test is very long, so we need an unusually high timeout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fix by @seaona to fix develop branch CI #28801

it('initiates and confirms', async function () {
await withTransactionEnvelopeTypeFixtures(
this.test?.fullTitle(),
Expand Down
Loading