Skip to content

Commit 98a5c77

Browse files
committed
Stabilize CLI URL integration test
1 parent 488ef3c commit 98a5c77

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ jobs:
4040

4141
- name: CLI simulator integration tests
4242
run: npm run test:integration:cli
43+
env:
44+
SIMDECK_INTEGRATION_VERBOSE: "1"

scripts/integration/cli.mjs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const serverPort = Number(process.env.SIMDECK_INTEGRATION_PORT ?? "4510");
1212
const serverUrl = `http://127.0.0.1:${serverPort}`;
1313
const origin = serverUrl;
1414
const fixtureBundleId = "dev.nativescript.simdeck.integration.fixture";
15+
const fixtureUrlScheme = "simdeck-fixture";
1516
const fixtureUrl = "simdeck-fixture://integration";
1617
const verbose = process.env.SIMDECK_INTEGRATION_VERBOSE === "1";
1718
const traceHttp = process.env.SIMDECK_INTEGRATION_TRACE_HTTP === "1";
@@ -91,6 +92,7 @@ async function main() {
9192
);
9293

9394
simdeckJson(["install", simulatorUDID, fixture.appPath]);
95+
preapproveFixtureUrlScheme();
9496
await verifyUi("after install");
9597

9698
startServer();
@@ -1381,6 +1383,44 @@ function openSimulatorApp(udid) {
13811383
});
13821384
}
13831385

1386+
function preapproveFixtureUrlScheme() {
1387+
const plist = path.join(
1388+
os.homedir(),
1389+
"Library",
1390+
"Developer",
1391+
"CoreSimulator",
1392+
"Devices",
1393+
simulatorUDID,
1394+
"data",
1395+
"Library",
1396+
"Preferences",
1397+
"com.apple.launchservices.schemeapproval.plist",
1398+
);
1399+
const key = `com.apple.CoreSimulator.CoreSimulatorBridge-->${fixtureUrlScheme}`;
1400+
fs.mkdirSync(path.dirname(plist), { recursive: true });
1401+
1402+
const setResult = spawnSync(
1403+
"/usr/libexec/PlistBuddy",
1404+
["-c", `Set :${key} ${fixtureBundleId}`, plist],
1405+
{
1406+
cwd: root,
1407+
encoding: "utf8",
1408+
timeout: 60_000,
1409+
},
1410+
);
1411+
if (setResult.status === 0) {
1412+
logStep(`preapproved fixture URL scheme in ${path.basename(plist)}`);
1413+
return;
1414+
}
1415+
1416+
runText(
1417+
"/usr/libexec/PlistBuddy",
1418+
["-c", `Add :${key} string ${fixtureBundleId}`, plist],
1419+
{ timeoutMs: 60_000 },
1420+
);
1421+
logStep(`preapproved fixture URL scheme in ${path.basename(plist)}`);
1422+
}
1423+
13841424
function assertSimulatorListed(udid) {
13851425
const payload = simdeckJson(["list"]);
13861426
if (!payload.simulators?.some((simulator) => simulator.udid === udid)) {

0 commit comments

Comments
 (0)