Skip to content
Draft
Show file tree
Hide file tree
Changes from 7 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
6 changes: 4 additions & 2 deletions .yarn/patches/@ethereumjs-util-npm-9.1.0-7e85509408.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ diff --git a/dist/cjs/account.js b/dist/cjs/account.js
index 9c7b96d50a1e1e9a08463e0be74f1462576b8b53..04f390b50c11a10b20971bccb46d212978c2ac89 100644
--- a/dist/cjs/account.js
+++ b/dist/cjs/account.js
@@ -476,7 +476,7 @@ const pubToAddress = function (pubKey, sanitize = false) {
@@ -476,7 +476,9 @@ const pubToAddress = function (pubKey, sanitize = false) {
// Only take the lower 160bits of the hash
return (0, keccak_js_1.keccak256)(pubKey).subarray(-20);
};
-exports.pubToAddress = pubToAddress;
+exports.pubToAddress = require('@metamask/native-utils').pubToAddress;
+let _nativeUtils;
Comment thread
christopherferreira9 marked this conversation as resolved.
Outdated
+try { _nativeUtils = require('@metamask/native-utils'); } catch (_) {}
+exports.pubToAddress = (_nativeUtils && _nativeUtils.pubToAddress) || pubToAddress;
exports.publicToAddress = exports.pubToAddress;
/**
* Returns the ethereum public key of a given private key.
9 changes: 5 additions & 4 deletions .yarn/patches/@metamask-key-tree-npm-10.1.1-0bfab435ac.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ diff --git a/dist/curves/ed25519.cjs b/dist/curves/ed25519.cjs
index 3f6b0951c046dbda89f18edb7f17e6d23b839fc5..d2aee95598d942c0219128a77f6f83abdf206b80 100644
--- a/dist/curves/ed25519.cjs
+++ b/dist/curves/ed25519.cjs
@@ -14,6 +14,7 @@ const isValidPrivateKey = (_privateKey) => true;
@@ -14,6 +14,8 @@ const isValidPrivateKey = (_privateKey) => true;
exports.isValidPrivateKey = isValidPrivateKey;
exports.deriveUnhardenedKeys = false;
exports.publicKeyLength = 33;
+const nativeUtils = require('@metamask/native-utils')
+let _nativeUtils;
+try { _nativeUtils = require('@metamask/native-utils'); } catch (_) {}
const getGetPublicKey = () => {
let hasSetWindowSize = false;
const getPublicKey = (privateKey, _compressed) => {
@@ -21,7 +22,7 @@ const getGetPublicKey = () => {
@@ -21,7 +23,7 @@ const getGetPublicKey = () => {
ed25519_1.ed25519.ExtendedPoint.BASE._setWindowSize(4);
hasSetWindowSize = true;
}
- const publicKey = ed25519_1.ed25519.getPublicKey(privateKey);
+ const publicKey = nativeUtils.getPublicKeyEd25519(privateKey);
+ const publicKey = (_nativeUtils && _nativeUtils.getPublicKeyEd25519) ? _nativeUtils.getPublicKeyEd25519(privateKey) : ed25519_1.ed25519.getPublicKey(privateKey);
return (0, utils_1.concatBytes)([new Uint8Array([0]), publicKey]);
};
return getPublicKey;
8 changes: 4 additions & 4 deletions tests/api-mocking/MockServerE2E.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createLogger, LogLevel } from '../framework/logger.ts';
import {
MockApiEndpoint,
MockEventsObject,
PlatformDetector,
Resource,
ServerStatus,
TestSpecificMock,
Expand Down Expand Up @@ -409,10 +410,9 @@ export default class MockServerE2E implements Resource {
};
}

let updatedUrl =
device.getPlatform() === 'android'
? urlEndpoint.replace('localhost', '127.0.0.1')
: urlEndpoint;
let updatedUrl = (await PlatformDetector.isAndroid())
? urlEndpoint.replace('localhost', '127.0.0.1')
: urlEndpoint;

// Translate fallback ports to actual allocated ports (host-side forwarding)
updatedUrl = translateFallbackPortToActual(updatedUrl);
Expand Down
67 changes: 64 additions & 3 deletions tests/flows/general.flow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { createLogger } from '../framework/logger';
import Assertions from '../framework/Assertions';
import { Gestures } from '../framework';
import {
Gestures,
PlaywrightAssertions,
PlaywrightGestures,
PlaywrightMatchers,
} from '../framework';
import Matchers from '../framework/Matchers';
import Utilities, { sleep } from '../framework/Utilities';
import LoginView from '../page-objects/wallet/LoginView';
Expand Down Expand Up @@ -52,8 +57,64 @@ export const dismissDevScreens = async (): Promise<void> => {
await Gestures.tap(fastRefreshButton, {
elemDescription: 'Dev Menu Fast Refresh Button',
});
} catch {
logger.error('Dev screens dismiss error');
} catch (error) {
logger.debug(
`Dev screens were not dismissed (best effort): ${
error instanceof Error ? error.message : String(error)
}`,
);
}
};

/**
* Dismisses development build screens using Playwright.
* Handles 'Development servers' and 'Developer menu' screens.
* These screens are expected to appear when running locally.
*/
export const dismissDevScreensPlaywright = async (): Promise<void> => {
const port = process.env.METRO_PORT_E2E || process.env.WATCHER_PORT || '8081';
const host = process.env.METRO_HOST_E2E || 'localhost';
const serverUrl = `http://${host}:${port}`;

try {
// 1. Check for Development Servers screen
// We tap the server row matching the current metro port
const devServerRow = await PlaywrightMatchers.getElementByText(serverUrl);
await PlaywrightAssertions.expectElementToBeVisible(devServerRow, {
timeout: 2000,
description: 'Dev Server Row should be visible',
});
await PlaywrightGestures.waitAndTap(devServerRow);

// 2. Check for Developer Menu onboarding
const continueButton =
await PlaywrightMatchers.getElementByText('Continue');
await PlaywrightAssertions.expectElementToBeVisible(continueButton, {
timeout: 5000,
description: 'Dev Menu Continue Button should be visible',
});

// Tap Continue to proceed past the onboarding screen.
await PlaywrightGestures.waitAndTap(continueButton);

// 3. Close the Developer Menu
// After tapping Continue, the Developer Menu options list appears.
// The user provided the ID 'fast-refresh' to tap on.
const fastRefreshButton = await PlaywrightMatchers.getElementById(
'fast-refresh',
{ exact: true },
);
await PlaywrightAssertions.expectElementToBeVisible(fastRefreshButton, {
timeout: 5000,
description: 'Dev Menu Fast Refresh Button should be visible',
});
await PlaywrightGestures.waitAndTap(fastRefreshButton);
} catch (error) {
logger.debug(
`Playwright dev screens were not dismissed (best effort): ${
error instanceof Error ? error.message : String(error)
}`,
);
}
};

Expand Down
70 changes: 70 additions & 0 deletions tests/framework/PlaywrightUtilities.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import PlaywrightUtilities from './PlaywrightUtilities';
import type { CurrentDeviceDetails } from './fixture';

describe('PlaywrightUtilities.launchApp', () => {
const executeMock = jest.fn();

const androidDevice: CurrentDeviceDetails = {
platform: 'android',
deviceName: 'Pixel_5',
udid: 'emulator-5554',
packageName: 'io.metamask',
launchableActivity: 'io.metamask.MainActivity',
isBrowserstack: false,
};

beforeEach(() => {
jest.useFakeTimers();
executeMock.mockResolvedValue(undefined);
globalThis.driver = {
execute: executeMock,
} as unknown as WebdriverIO.Browser;
});

afterEach(() => {
delete globalThis.driver;
jest.useRealTimers();
jest.clearAllMocks();
});

it('launches Android apps with Appium mobile startActivity intent parameters', async () => {
const launchPromise = PlaywrightUtilities.launchApp(androidDevice, {
launchArgs: {
fixtureServerPort: '1234',
},
});

await jest.advanceTimersByTimeAsync(1000);
await launchPromise;

expect(executeMock).toHaveBeenCalledWith(
'mobile: startActivity',
expect.objectContaining({
component: 'io.metamask/io.metamask.MainActivity',
action: 'android.intent.action.MAIN',
categories: ['android.intent.category.LAUNCHER'],
stop: true,
wait: true,
extras: expect.arrayContaining([['s', 'fixtureServerPort', '1234']]),
}),
);
expect(executeMock).not.toHaveBeenCalledWith(
'mobile: startActivity',
expect.objectContaining({
appPackage: expect.any(String),
}),
);
expect(executeMock).not.toHaveBeenCalledWith(
'mobile: startActivity',
expect.objectContaining({
appActivity: expect.any(String),
}),
);
expect(executeMock).not.toHaveBeenCalledWith(
'mobile: startActivity',
expect.objectContaining({
optionalIntentArguments: expect.any(String),
}),
);
});
});
Loading
Loading