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: fix old signature e2e by mocking launch darkly api #13002

Merged
merged 17 commits into from
Jan 15, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const useConfirmationRedesignEnabled = () => {
const isRedesignedEnabled = useMemo(
() =>
(confirmation_redesign as Record<string, string>)?.signatures &&
process.env.REDESIGNED_SIGNATURE_REQUEST === 'true' &&
jpuri marked this conversation as resolved.
Show resolved Hide resolved
// following condition will ensure that user is redirected to old designs is using QR scan aware hardware
!isSyncingQRHardware &&
!isSigningQRObject &&
Expand Down
55 changes: 36 additions & 19 deletions e2e/api-mocking/mock-config/mock-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,37 @@ export const mockEvents = {
securityAlertApiSupportedChains: {
urlEndpoint: 'https://security-alerts.api.cx.metamask.io/supportedChains',
response: [
'0xa4b1',
'0xa86a',
'0x2105',
'0x138d5',
'0x38',
'0xe708',
'0x1',
'0x1b6e6',
'0xcc',
'0xa',
'0x89',
'0x82750',
'0xaa36a7',
'0x144'
],
'0xa4b1',
'0xa86a',
'0x2105',
'0x138d5',
'0x38',
'0xe708',
'0x1',
'0x1b6e6',
'0xcc',
'0xa',
'0x89',
'0x82750',
'0xaa36a7',
'0x144',
],
responseCode: 200,
},

remoteFeatureFlags: {
urlEndpoint:
'https://client-config.api.cx.metamask.io/v1/flags?client=mobile&distribution=main&environment=dev',
response: [
{
mobileMinimumVersions: {
appMinimumBuild: 1243,
appleMinimumOS: 6,
androidMinimumAPIVersion: 21,
},
},
{ confirmation_redesign: { signatures: false } },
],
responseCode: 200,
},
},
Expand All @@ -77,7 +93,8 @@ export const mockEvents = {
},

securityAlertApiValidate: {
urlEndpoint: 'https://security-alerts.api.cx.metamask.io/validate/0xaa36a7',
urlEndpoint:
'https://security-alerts.api.cx.metamask.io/validate/0xaa36a7',
response: {
block: 20733513,
result_type: 'Benign',
Expand All @@ -93,9 +110,9 @@ export const mockEvents = {
{
from: '0x76cf1cdd1fcc252442b50d6e97207228aa4aefc3',
to: '0x50587e46c5b96a3f6f9792922ec647f13e6efae4',
value: '0x0'
}
]
value: '0x0',
},
],
},
responseCode: 201,
},
Expand Down
6 changes: 6 additions & 0 deletions e2e/api-specs/json-rpc-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ConfirmationsRejectRule from './ConfirmationsRejectionRule';
import { createDriverTransport } from './helpers';
import { BrowserViewSelectorsIDs } from '../selectors/Browser/BrowserView.selectors';
import { getGanachePort } from '../fixtures/utils';
import { mockEvents } from '../api-mocking/mock-config/mock-events';

const port = getGanachePort(8545, process.pid);
const chainId = 1337;
Expand Down Expand Up @@ -156,13 +157,18 @@ const main = async () => {
const server = mockServer(port, openrpcDocument);
server.start();

const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder().withGanacheNetwork().build(),
ganacheOptions: defaultGanacheOptions,
disableGanache: true,
restartDevice: true,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
6 changes: 6 additions & 0 deletions e2e/specs/confirmations/signatures/ethereum-sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';
import { mockEvents } from '../../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Ethereum Sign'), () => {
beforeAll(async () => {
Expand All @@ -20,6 +21,10 @@ describe(SmokeConfirmations('Ethereum Sign'), () => {
});

it('Sign in with Ethereum', async () => {
const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

await withFixtures(
{
dapp: true,
Expand All @@ -29,6 +34,7 @@ describe(SmokeConfirmations('Ethereum Sign'), () => {
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
6 changes: 6 additions & 0 deletions e2e/specs/confirmations/signatures/personal-sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import {
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';
import { mockEvents } from '../../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Personal Sign'), () => {
const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

beforeAll(async () => {
jest.setTimeout(2500000);
await TestHelpers.reverseServerPort();
Expand All @@ -29,6 +34,7 @@ describe(SmokeConfirmations('Personal Sign'), () => {
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ describe(SmokeConfirmations('Security Alert API - Signature'), () => {

it('should sign typed message', async () => {
const testSpecificMock = {
GET: [mockEvents.GET.securityAlertApiSupportedChains],
GET: [
mockEvents.GET.securityAlertApiSupportedChains,
mockEvents.GET.remoteFeatureFlags,
],
POST: [
{
...mockEvents.POST.securityAlertApiValidate,
Expand All @@ -83,7 +86,10 @@ describe(SmokeConfirmations('Security Alert API - Signature'), () => {

it('should show security alert for malicious request', async () => {
const testSpecificMock = {
GET: [mockEvents.GET.securityAlertApiSupportedChains],
GET: [
mockEvents.GET.securityAlertApiSupportedChains,
mockEvents.GET.remoteFeatureFlags,
],
POST: [
{
...mockEvents.POST.securityAlertApiValidate,
Expand All @@ -108,6 +114,7 @@ describe(SmokeConfirmations('Security Alert API - Signature'), () => {
const testSpecificMock = {
GET: [
mockEvents.GET.securityAlertApiSupportedChains,
mockEvents.GET.remoteFeatureFlags,
{
urlEndpoint:
'https://static.cx.metamask.io/api/v1/confirmations/ppom/ppom_version.json',
Expand Down
6 changes: 6 additions & 0 deletions e2e/specs/confirmations/signatures/typed-sign-v3.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import {
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';
import { mockEvents } from '../../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Typed Sign V3'), () => {
const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

beforeAll(async () => {
jest.setTimeout(2500000);
await TestHelpers.reverseServerPort();
Expand All @@ -29,6 +34,7 @@ describe(SmokeConfirmations('Typed Sign V3'), () => {
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
6 changes: 6 additions & 0 deletions e2e/specs/confirmations/signatures/typed-sign-v4.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import {
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';
import { mockEvents } from '../../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Typed Sign V4'), () => {
const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

beforeAll(async () => {
jest.setTimeout(2500000);
await TestHelpers.reverseServerPort();
Expand All @@ -29,6 +34,7 @@ describe(SmokeConfirmations('Typed Sign V4'), () => {
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
6 changes: 6 additions & 0 deletions e2e/specs/confirmations/signatures/typed-sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ import {
import { SmokeConfirmations } from '../../../tags';
import TestHelpers from '../../../helpers';
import Assertions from '../../../utils/Assertions';
import { mockEvents } from '../../../api-mocking/mock-config/mock-events';

describe(SmokeConfirmations('Typed Sign'), () => {
const testSpecificMock = {
GET: [mockEvents.GET.remoteFeatureFlags],
};

beforeAll(async () => {
jest.setTimeout(2500000);
await TestHelpers.reverseServerPort();
Expand All @@ -29,6 +34,7 @@ describe(SmokeConfirmations('Typed Sign'), () => {
.build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
testSpecificMock,
},
async () => {
await loginToApp();
Expand Down
2 changes: 0 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ process.env.MM_SECURITY_ALERTS_API_ENABLED = 'true';
process.env.PORTFOLIO_VIEW = 'true';
process.env.SECURITY_ALERTS_API_URL = 'https://example.com';

process.env.REDESIGNED_SIGNATURE_REQUEST = 'true';

process.env.LAUNCH_DARKLY_URL =
'https://client-config.dev-api.cx.metamask.io/v1';

Expand Down
Loading