From fa060a49fd6564cf41c492dc18b8f25bb270178a Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Sun, 3 Dec 2023 18:13:43 -0800 Subject: [PATCH] fix: handle location command as case insensitive (#407) --- lib/extensions/permissions.js | 4 +++- test/functional/simulator-e2e-specs.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/extensions/permissions.js b/lib/extensions/permissions.js index 347cb8f..a761fc3 100644 --- a/lib/extensions/permissions.js +++ b/lib/extensions/permissions.js @@ -116,7 +116,9 @@ async function setAccess (simctl, udid, bundleId, permissionsMapping) { if (!PERMISSIONS_APPLIED_VIA_SIMCTL.includes(serviceName)) { wixPermissions[serviceName] = permissionsMapping[serviceName]; } else { - switch (permissionsMapping[serviceName]) { + // xcrun simctl privacy expects to be lower case while AppleSimulatorUtils is upper case. + // To keep the compatibility, we should convert here to lower case explicitly. + switch (_.toLower(permissionsMapping[serviceName])) { case STATUS.YES: grantPermissions.push(serviceName); break; diff --git a/test/functional/simulator-e2e-specs.js b/test/functional/simulator-e2e-specs.js index 77c1bd0..b67625a 100644 --- a/test/functional/simulator-e2e-specs.js +++ b/test/functional/simulator-e2e-specs.js @@ -354,7 +354,7 @@ describe('advanced features', function () { it('should set and get with simctrl privacy command', async function () { // no exceptions await expect(sim.setPermission('com.apple.Maps', 'location', 'yes')).not.to.be.rejected; - await expect(sim.setPermission('com.apple.Maps', 'location', 'no')).not.to.be.rejected; + await expect(sim.setPermission('com.apple.Maps', 'location', 'NO')).not.to.be.rejected; await expect(sim.setPermission('com.apple.Maps', 'location', 'unset')).not.to.be.rejected; await expect(sim.setPermission('com.apple.Maps', 'location', 'unsupported')).to.be.rejected; });