@samsara-dev/appwright 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # appwright
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d5b7e84: Apply BrowserStack iOS permission settings after the app install by default, using a worker fixture so sessions start with the requested configuration.
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixture/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAqDnC,KAAK,iBAAiB,GAAG;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,IAAI,uRAkFf,CAAC;AA8BH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM;2BACY,gBAAgB,YAAY,aAAa;;;;;;;EAUtE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixture/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EAMd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2GnC,KAAK,iBAAiB,GAAG;IACvB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAE/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,IAAI,uRA6Ff,CAAC;AA8BH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM;2BACY,gBAAgB,YAAY,aAAa;;;;;;;EAUtE,CAAC"}
@@ -2,11 +2,49 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expect = exports.test = void 0;
4
4
  const test_1 = require("@playwright/test");
5
+ const types_1 = require("../types");
5
6
  const providers_1 = require("../providers");
6
7
  const workerInfo_1 = require("./workerInfo");
7
8
  const appium_1 = require("../providers/appium");
8
9
  const logger_1 = require("../logger");
9
10
  const persistentDevicesByWorker = new Map();
11
+ async function applyIosAppSettings(project, device) {
12
+ if (project.use.platform !== types_1.Platform.IOS) {
13
+ return;
14
+ }
15
+ const deviceConfig = project.use.device;
16
+ if (!deviceConfig || deviceConfig.provider !== "browserstack") {
17
+ return;
18
+ }
19
+ const browserStackConfig = deviceConfig;
20
+ const envSettingsJson = process.env.APPWRIGHT_BS_UPDATE_APP_SETTINGS_JSON;
21
+ let settings;
22
+ if (envSettingsJson) {
23
+ try {
24
+ settings = JSON.parse(envSettingsJson);
25
+ }
26
+ catch (error) {
27
+ throw new Error("APPWRIGHT_BS_UPDATE_APP_SETTINGS_JSON is not valid JSON. Provide a valid JSON string.");
28
+ }
29
+ }
30
+ else {
31
+ settings = browserStackConfig.updateAppSettings;
32
+ }
33
+ if (!settings || typeof settings !== "object") {
34
+ return;
35
+ }
36
+ try {
37
+ await device.updateAppSettings(settings);
38
+ const hasPermissions = Object.prototype.hasOwnProperty.call(settings, "Permission Settings");
39
+ const customKeys = Object.keys(settings).filter((key) => key !== "Permission Settings");
40
+ if (hasPermissions || customKeys.length > 0) {
41
+ logger_1.logger.log(`iOS app settings applied before tests: permissions=${hasPermissions}, custom_keys=${customKeys.length}`);
42
+ }
43
+ }
44
+ catch (error) {
45
+ logger_1.logger.warn("Failed to apply iOS app settings in fixture", error);
46
+ }
47
+ }
10
48
  function createPersistentContext(device) {
11
49
  return {
12
50
  device,
@@ -57,6 +95,7 @@ exports.test = test_1.test.extend({
57
95
  // Initialize Visual Trace Service for screenshot capture
58
96
  const visualTraceConfig = testInfo.project.use.visualTrace;
59
97
  device.initializeVisualTrace(testInfo, testInfo.retry, visualTraceConfig);
98
+ await applyIosAppSettings(testInfo.project, device);
60
99
  await deviceProvider.syncTestDetails?.({ name: testInfo.title });
61
100
  await use(device);
62
101
  await device.close();
@@ -89,6 +128,7 @@ exports.test = test_1.test.extend({
89
128
  await workerInfoStore.saveWorkerStartTime(workerIndex, sessionId, providerName, beforeSession, afterSession);
90
129
  device.attachDeviceProvider(deviceProvider);
91
130
  device.enablePersistentStatusSync();
131
+ await applyIosAppSettings(project, device);
92
132
  const context = createPersistentContext(device);
93
133
  persistentDevicesByWorker.set(workerIndex, context);
94
134
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/browserstack/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,cAAc,EAGf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAqDtC,qBAAa,0BAA2B,YAAW,cAAc;IAC/D,OAAO,CAAC,cAAc,CAAC,CAA6B;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,OAAO,CAA+B;gBAG5C,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC,EACrC,WAAW,EAAE,MAAM,GAAG,SAAS;IAU3B,WAAW;IAwDX,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAMlC,OAAO,CAAC,cAAc;YASR,YAAY;YAiBZ,iBAAiB;YAKjB,yBAAyB;WAK1B,aAAa,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE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@ class BrowserStackDeviceProvider {
273
273
  updateAppSettings = deviceConfig?.updateAppSettings;
274
274
  }
275
275
  if (updateAppSettings && typeof updateAppSettings === "object") {
276
- // Add to bstack:options as per BrowserStack documentation
277
- bstackOptions.updateAppSettings = updateAppSettings;
278
- // Log for debugging (without exposing sensitive data)
279
- const u = updateAppSettings;
280
- const hasPermissions = !!u["Permission Settings"];
281
- const customKeys = Object.keys(u).filter((k) => k !== "Permission Settings");
276
+ const settings = updateAppSettings;
277
+ const hasPermissions = !!settings["Permission Settings"];
278
+ const customKeys = Object.keys(settings).filter((key) => key !== "Permission Settings");
282
279
  if (hasPermissions || customKeys.length > 0) {
283
- logger_1.logger.log(`iOS app settings configured: permissions=${hasPermissions}, custom_keys=${customKeys.length}`);
280
+ logger_1.logger.log("iOS app settings detected; they will be applied after session start via fixtures.");
284
281
  }
285
282
  }
286
283
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samsara-dev/appwright",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"