()
| 58 | }); |
| 59 | |
| 60 | async function main() { |
| 61 | if (process.platform !== "darwin") { |
| 62 | throw new Error("SimDeck WebRTC integration tests require macOS."); |
| 63 | } |
| 64 | if (!fs.existsSync(simdeck)) { |
| 65 | throw new Error(`Missing ${simdeck}. Run npm run build:cli first.`); |
| 66 | } |
| 67 | |
| 68 | const { runtime, deviceType, sdkVersion } = selectIntegrationSimulator({ |
| 69 | runJson, |
| 70 | runText, |
| 71 | timeoutMs: coreSimulatorCommandTimeoutMs, |
| 72 | }); |
| 73 | const simulatorName = `SimDeck WebRTC Integration ${Date.now()}`; |
| 74 | simulatorUDID = runText("xcrun", [ |
| 75 | "simctl", |
| 76 | "create", |
| 77 | simulatorName, |
| 78 | deviceType.identifier, |
| 79 | runtime.identifier, |
| 80 | ]).trim(); |
| 81 | console.log( |
| 82 | `created ${simulatorUDID} (${deviceType.name}, ${runtime.version}; iphonesimulator SDK ${sdkVersion})`, |
| 83 | ); |
| 84 | |
| 85 | startServer(); |
| 86 | await waitForHealth(); |
| 87 | await retrySimdeckJson(["boot", simulatorUDID], "WebRTC boot simulator", { |
| 88 | attempts: 3, |
| 89 | delayMs: 3_000, |
| 90 | timeoutMs: simdeckBootTimeoutMs, |
| 91 | }); |
| 92 | runText("xcrun", ["simctl", "bootstatus", simulatorUDID, "-b"], { |
| 93 | timeoutMs: 600_000, |
| 94 | }); |
| 95 | |
| 96 | const fixture = buildCachedFixtureApp({ |
| 97 | root, |
| 98 | tempRoot, |
| 99 | bundleId: fixtureBundleId, |
| 100 | urlScheme: fixtureUrlScheme, |
| 101 | }); |
| 102 | await launchFixtureWithRecovery(fixture.appPath); |
| 103 | |
| 104 | const screenshotPath = path.join(tempRoot, "reference.png"); |
| 105 | await retrySimdeckJson( |
| 106 | ["screenshot", simulatorUDID, "--output", screenshotPath], |
| 107 | "WebRTC reference screenshot", |
| 108 | { |
| 109 | attempts: process.env.CI === "true" ? 3 : 2, |
| 110 | delayMs: 5_000, |
| 111 | timeoutMs: process.env.CI === "true" ? 120_000 : 60_000, |
| 112 | }, |
| 113 | ); |
| 114 | const { width, height } = pngSize(screenshotPath); |
| 115 | console.log(`reference screenshot ${width}x${height}`); |
| 116 | |
| 117 | const viewerUrl = new URL(serverUrl); |
no test coverage detected