Skip to content
Merged
48 changes: 48 additions & 0 deletions src/cli/mm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,54 @@ describe('parseLaunchArgs', () => {
);
});

it('parses --platform value', () => {
expect(parseLaunchArgs(['--platform', 'ios'])).toStrictEqual({
platform: 'ios',
});
});

it('parses --device-id value', () => {
expect(
parseLaunchArgs(['--device-id', '4A3B2C1D-E5F6-7890-ABCD-EF1234567890']),
).toStrictEqual({
deviceId: '4A3B2C1D-E5F6-7890-ABCD-EF1234567890',
});
});

it('parses --platform and --device-id together', () => {
expect(
parseLaunchArgs([
'--platform',
'android',
'--device-id',
'emulator-5554',
]),
).toStrictEqual({
platform: 'android',
deviceId: 'emulator-5554',
});
});

it('exits for --platform without value', () => {
expect(() => parseLaunchArgs(['--platform'])).toThrowError('process.exit');
expect(stderrSpy).toHaveBeenCalledWith(
'Error: --platform requires a value (browser|ios|android)\n',
);
});

it('exits for --platform with flag as value', () => {
expect(() => parseLaunchArgs(['--platform', '--force'])).toThrowError(
'process.exit',
);
});

it('exits for --device-id without value', () => {
expect(() => parseLaunchArgs(['--device-id'])).toThrowError('process.exit');
expect(stderrSpy).toHaveBeenCalledWith(
'Error: --device-id requires a value\n',
);
});

it('writes warning for unknown flags', () => {
parseLaunchArgs(['--unknown']);
expect(stderrSpy).toHaveBeenCalledWith(
Expand Down
20 changes: 19 additions & 1 deletion src/cli/mm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,8 @@ export function parseLaunchArgs(args: string[]): Record<string, unknown> {
'--goal',
'--force',
'--flow-tags',
'--platform',
'--device-id',
]);

for (let i = 0; i < args.length; i++) {
Expand Down Expand Up @@ -1341,6 +1343,22 @@ export function parseLaunchArgs(args: string[]): Record<string, unknown> {
process.exit(1);
}
result.flowTags = args[i].split(',').map((tag) => tag.trim());
} else if (arg === '--platform') {
i += 1;
if (!args[i] || args[i].startsWith('--')) {
process.stderr.write(
'Error: --platform requires a value (browser|ios|android)\n',
);
process.exit(1);
}
result.platform = args[i];
} else if (arg === '--device-id') {
i += 1;
if (!args[i] || args[i].startsWith('--')) {
process.stderr.write('Error: --device-id requires a value\n');
process.exit(1);
}
result.deviceId = args[i];
} else if (arg.startsWith('--') && !knownFlags.has(arg)) {
process.stderr.write(`Warning: unknown launch flag '${arg}'\n`);
}
Expand All @@ -1365,7 +1383,7 @@ Environment Variables:
Falls back to the current git worktree root.

Lifecycle:
mm launch [--context e2e|prod] [--state default|onboarding|custom] [--extension-path <path>] [--goal <text>] [--force] [--flow-tags <tags>]
mm launch [--context e2e|prod] [--state default|onboarding|custom] [--extension-path <path>] [--goal <text>] [--force] [--flow-tags <tags>] [--platform browser|ios|android] [--device-id <id>]
mm cleanup [--shutdown]
mm status
mm stop [--force]
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
export type * from './capabilities/types.js';
export * from './capabilities/context.js';

// Platform
export type {
PlatformType,
IPlatformDriver,
ClickActionResult,
TypeActionResult,
GetTextActionResult,
PlatformScreenshotOptions,
} from './platform';
export { PlaywrightPlatformDriver } from './platform';

// Session Manager Interface (transport-agnostic)
export type {
ISessionManager,
Expand Down
12 changes: 12 additions & 0 deletions src/platform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type {
PlatformType,
TargetType,
ClickActionResult,
TypeActionResult,
GetTextActionResult,
PlatformScreenshotOptions,
WithinScope,
IPlatformDriver,
} from './types.js';

export { PlaywrightPlatformDriver } from './playwright-driver.js';
Loading
Loading