wip
This commit is contained in:
@@ -28,9 +28,9 @@ export interface PermissionCheckResult {
|
||||
|
||||
/**
|
||||
* PermissionGuard for E2E tests.
|
||||
*
|
||||
*
|
||||
* Checks macOS Accessibility and Screen Recording permissions
|
||||
* required for real nut.js automation. Provides graceful skip
|
||||
* required for real native automation. Provides graceful skip
|
||||
* logic for CI environments or when permissions are unavailable.
|
||||
*/
|
||||
export class PermissionGuard {
|
||||
@@ -203,34 +203,17 @@ export class PermissionGuard {
|
||||
|
||||
/**
|
||||
* Check macOS Screen Recording permission without Electron.
|
||||
* Uses CGPreflightScreenCaptureAccess (requires native code) or heuristics.
|
||||
* Uses `screencapture` heuristics to detect denial.
|
||||
*/
|
||||
private async checkMacOSScreenRecording(): Promise<boolean> {
|
||||
try {
|
||||
// Use screencapture command with minimal output
|
||||
// -c captures to clipboard, -x prevents sound
|
||||
// This will succeed even without permission but we can check for errors
|
||||
const { stderr } = await execAsync('screencapture -x -c 2>&1 || true');
|
||||
|
||||
// If there's a permission error in stderr, we don't have permission
|
||||
|
||||
if (stderr.includes('permission') || stderr.includes('denied')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Additional check: try to use nut.js screen capture
|
||||
// This is the most reliable check but may throw
|
||||
try {
|
||||
const { screen } = await import('@nut-tree-fork/nut-js');
|
||||
await screen.width();
|
||||
return true;
|
||||
} catch (nutError) {
|
||||
const errorStr = String(nutError);
|
||||
if (errorStr.includes('permission') || errorStr.includes('denied') || errorStr.includes('screen')) {
|
||||
return false;
|
||||
}
|
||||
// Other errors might be unrelated to permissions
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ export async function createStepHarness(): Promise<StepHarness> {
|
||||
headless: true,
|
||||
timeout: 5000,
|
||||
mode: 'mock',
|
||||
baseUrl: url,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user