@hot-updater/react-native 1.0.0-rc.16 → 1.0.0-rc.17
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/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +491 -388
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +5 -11
- package/android/src/main/java/com/hotupdater/FileManagerService.kt +45 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +290 -12
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +35 -19
- package/android/src/main/java/com/hotupdater/InstallIdentityService.kt +37 -0
- package/android/src/main/java/com/hotupdater/KeyValueStorageService.kt +86 -0
- package/android/src/main/java/com/hotupdater/NetworkState.kt +31 -0
- package/android/src/main/java/com/hotupdater/NoBackupStorage.kt +17 -0
- package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +110 -52
- package/android/src/main/java/com/hotupdater/PreviousProcessExit.kt +89 -0
- package/android/src/main/java/com/hotupdater/ReactNativeValueConverters.kt +34 -0
- package/android/src/newarch/HotUpdaterModule.kt +74 -69
- package/android/src/oldarch/HotUpdaterModule.kt +63 -59
- package/android/src/oldarch/HotUpdaterSpec.kt +4 -6
- package/android/src/test/java/com/hotupdater/BsdiffPatchTest.kt +1 -1
- package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +446 -61
- package/android/src/test/java/com/hotupdater/HotUpdaterExceptionTest.kt +220 -0
- package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +19 -27
- package/android/src/test/java/com/hotupdater/InstallIdentityServiceTest.kt +71 -0
- package/android/src/test/java/com/hotupdater/KeyValueStorageServiceTest.kt +106 -0
- package/android/src/test/java/com/hotupdater/NoBackupContext.kt +11 -0
- package/android/src/test/java/com/hotupdater/OkHttpDownloadServiceTest.kt +309 -23
- package/android/src/test/java/com/hotupdater/PreviousProcessExitTest.kt +57 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +238 -157
- package/ios/HotUpdater/Internal/BundleMetadata.swift +3 -53
- package/ios/HotUpdater/Internal/FileManagerService.swift +48 -0
- package/ios/HotUpdater/Internal/HotUpdater.mm +8 -18
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +48 -29
- package/ios/HotUpdater/Internal/KeyValueStorageService.swift +71 -0
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +108 -1
- package/ios/HotUpdater/Internal/UpdateFailure.swift +390 -0
- package/lib/commonjs/appReady.js +111 -0
- package/lib/commonjs/appReady.js.map +1 -0
- package/lib/commonjs/appReady.spec.js +360 -0
- package/lib/commonjs/appReady.spec.js.map +1 -0
- package/lib/commonjs/{notifyAppReadyInsights.test-utils.js → appReady.test-utils.js} +4 -3
- package/lib/commonjs/appReady.test-utils.js.map +1 -0
- package/lib/commonjs/baseURL.js +16 -0
- package/lib/commonjs/baseURL.js.map +1 -0
- package/lib/commonjs/checkForUpdate.js +104 -56
- package/lib/commonjs/checkForUpdate.js.map +1 -1
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +337 -74
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +1 -1
- package/lib/commonjs/clientPlugin.js +49 -0
- package/lib/commonjs/clientPlugin.js.map +1 -0
- package/lib/commonjs/entryImportGraph.spec.js +50 -0
- package/lib/commonjs/entryImportGraph.spec.js.map +1 -0
- package/lib/commonjs/fetchJSON.js +2 -6
- package/lib/commonjs/fetchJSON.js.map +1 -1
- package/lib/commonjs/httpClient.js +18 -165
- package/lib/commonjs/httpClient.js.map +1 -1
- package/lib/commonjs/httpClient.spec.js +26 -199
- package/lib/commonjs/httpClient.spec.js.map +1 -1
- package/lib/commonjs/index.js +49 -36
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.spec.js +108 -123
- package/lib/commonjs/index.spec.js.map +1 -1
- package/lib/commonjs/native.js +67 -48
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/native.spec.js +80 -58
- package/lib/commonjs/native.spec.js.map +1 -1
- package/lib/commonjs/pluginHost.js +208 -0
- package/lib/commonjs/pluginHost.js.map +1 -0
- package/lib/commonjs/pluginHost.spec.js +292 -0
- package/lib/commonjs/pluginHost.spec.js.map +1 -0
- package/lib/commonjs/plugins/insights/eventId.js +129 -0
- package/lib/commonjs/plugins/insights/eventId.js.map +1 -0
- package/lib/commonjs/plugins/insights/eventId.spec.js +47 -0
- package/lib/commonjs/plugins/insights/eventId.spec.js.map +1 -0
- package/lib/commonjs/plugins/insights/index.js +272 -0
- package/lib/commonjs/plugins/insights/index.js.map +1 -0
- package/lib/commonjs/plugins/insights/insights.spec.js +640 -0
- package/lib/commonjs/plugins/insights/insights.spec.js.map +1 -0
- package/lib/commonjs/plugins/insights/sender.js +128 -0
- package/lib/commonjs/plugins/insights/sender.js.map +1 -0
- package/lib/commonjs/plugins/insights/sender.spec.js +265 -0
- package/lib/commonjs/plugins/insights/sender.spec.js.map +1 -0
- package/lib/commonjs/plugins/insights/state.js +145 -0
- package/lib/commonjs/plugins/insights/state.js.map +1 -0
- package/lib/commonjs/releaseCatalogCache.js +13 -2
- package/lib/commonjs/releaseCatalogCache.js.map +1 -1
- package/lib/commonjs/releaseCatalogCache.spec.js +18 -0
- package/lib/commonjs/releaseCatalogCache.spec.js.map +1 -1
- package/lib/commonjs/sdkVersion.js +1 -1
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/updateError.js +132 -0
- package/lib/commonjs/updateError.js.map +1 -0
- package/lib/commonjs/updateError.spec.js +149 -0
- package/lib/commonjs/updateError.spec.js.map +1 -0
- package/lib/commonjs/wrap.js +43 -25
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/commonjs/wrap.progress.spec.js +195 -0
- package/lib/commonjs/wrap.progress.spec.js.map +1 -0
- package/lib/commonjs/wrap.spec.js +94 -230
- package/lib/commonjs/wrap.spec.js.map +1 -1
- package/lib/module/appReady.js +103 -0
- package/lib/module/appReady.js.map +1 -0
- package/lib/module/appReady.spec.js +359 -0
- package/lib/module/appReady.spec.js.map +1 -0
- package/lib/module/{notifyAppReadyInsights.test-utils.js → appReady.test-utils.js} +4 -3
- package/lib/module/appReady.test-utils.js.map +1 -0
- package/lib/module/baseURL.js +11 -0
- package/lib/module/baseURL.js.map +1 -0
- package/lib/module/checkForUpdate.js +103 -57
- package/lib/module/checkForUpdate.js.map +1 -1
- package/lib/module/checkForUpdate.releaseCatalog.spec.js +337 -74
- package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +1 -1
- package/lib/module/clientPlugin.js +44 -0
- package/lib/module/clientPlugin.js.map +1 -0
- package/lib/module/entryImportGraph.spec.js +50 -0
- package/lib/module/entryImportGraph.spec.js.map +1 -0
- package/lib/module/fetchJSON.js +2 -6
- package/lib/module/fetchJSON.js.map +1 -1
- package/lib/module/httpClient.js +18 -165
- package/lib/module/httpClient.js.map +1 -1
- package/lib/module/httpClient.spec.js +27 -200
- package/lib/module/httpClient.spec.js.map +1 -1
- package/lib/module/index.js +44 -38
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.spec.js +108 -123
- package/lib/module/index.spec.js.map +1 -1
- package/lib/module/native.js +63 -44
- package/lib/module/native.js.map +1 -1
- package/lib/module/native.spec.js +80 -58
- package/lib/module/native.spec.js.map +1 -1
- package/lib/module/pluginHost.js +200 -0
- package/lib/module/pluginHost.js.map +1 -0
- package/lib/module/pluginHost.spec.js +291 -0
- package/lib/module/pluginHost.spec.js.map +1 -0
- package/lib/module/plugins/insights/eventId.js +122 -0
- package/lib/module/plugins/insights/eventId.js.map +1 -0
- package/lib/module/plugins/insights/eventId.spec.js +47 -0
- package/lib/module/plugins/insights/eventId.spec.js.map +1 -0
- package/lib/module/plugins/insights/index.js +268 -0
- package/lib/module/plugins/insights/index.js.map +1 -0
- package/lib/module/plugins/insights/insights.spec.js +639 -0
- package/lib/module/plugins/insights/insights.spec.js.map +1 -0
- package/lib/module/plugins/insights/sender.js +123 -0
- package/lib/module/plugins/insights/sender.js.map +1 -0
- package/lib/module/plugins/insights/sender.spec.js +265 -0
- package/lib/module/plugins/insights/sender.spec.js.map +1 -0
- package/lib/module/plugins/insights/state.js +139 -0
- package/lib/module/plugins/insights/state.js.map +1 -0
- package/lib/module/releaseCatalogCache.js +13 -2
- package/lib/module/releaseCatalogCache.js.map +1 -1
- package/lib/module/releaseCatalogCache.spec.js +18 -0
- package/lib/module/releaseCatalogCache.spec.js.map +1 -1
- package/lib/module/sdkVersion.js +1 -1
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/updateError.js +126 -0
- package/lib/module/updateError.js.map +1 -0
- package/lib/module/updateError.spec.js +149 -0
- package/lib/module/updateError.spec.js.map +1 -0
- package/lib/module/wrap.js +43 -25
- package/lib/module/wrap.js.map +1 -1
- package/lib/module/wrap.progress.spec.js +196 -0
- package/lib/module/wrap.progress.spec.js.map +1 -0
- package/lib/module/wrap.spec.js +93 -229
- package/lib/module/wrap.spec.js.map +1 -1
- package/lib/typescript/commonjs/appReady.d.ts +23 -0
- package/lib/typescript/commonjs/appReady.d.ts.map +1 -0
- package/lib/typescript/commonjs/appReady.test-utils.d.ts +9 -0
- package/lib/typescript/commonjs/appReady.test-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/baseURL.d.ts +4 -0
- package/lib/typescript/commonjs/baseURL.d.ts.map +1 -0
- package/lib/typescript/commonjs/checkForUpdate.d.ts +15 -2
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/clientPlugin.d.ts +185 -0
- package/lib/typescript/commonjs/clientPlugin.d.ts.map +1 -0
- package/lib/typescript/commonjs/fetchJSON.d.ts +2 -3
- package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/commonjs/httpClient.d.ts +2 -36
- package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -6
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +29 -15
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/pluginHost.d.ts +29 -0
- package/lib/typescript/commonjs/pluginHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugins/insights/eventId.d.ts +18 -0
- package/lib/typescript/commonjs/plugins/insights/eventId.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugins/insights/index.d.ts +40 -0
- package/lib/typescript/commonjs/plugins/insights/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugins/insights/sender.d.ts +74 -0
- package/lib/typescript/commonjs/plugins/insights/sender.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugins/insights/state.d.ts +46 -0
- package/lib/typescript/commonjs/plugins/insights/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/releaseCatalogCache.d.ts +5 -1
- package/lib/typescript/commonjs/releaseCatalogCache.d.ts.map +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +34 -12
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/updateError.d.ts +26 -0
- package/lib/typescript/commonjs/updateError.d.ts.map +1 -0
- package/lib/typescript/commonjs/wrap.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.types.d.ts +6 -10
- package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
- package/lib/typescript/module/appReady.d.ts +23 -0
- package/lib/typescript/module/appReady.d.ts.map +1 -0
- package/lib/typescript/module/appReady.test-utils.d.ts +9 -0
- package/lib/typescript/module/appReady.test-utils.d.ts.map +1 -0
- package/lib/typescript/module/baseURL.d.ts +4 -0
- package/lib/typescript/module/baseURL.d.ts.map +1 -0
- package/lib/typescript/module/checkForUpdate.d.ts +15 -2
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/module/clientPlugin.d.ts +185 -0
- package/lib/typescript/module/clientPlugin.d.ts.map +1 -0
- package/lib/typescript/module/fetchJSON.d.ts +2 -3
- package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/module/httpClient.d.ts +2 -36
- package/lib/typescript/module/httpClient.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -6
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +29 -15
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/pluginHost.d.ts +29 -0
- package/lib/typescript/module/pluginHost.d.ts.map +1 -0
- package/lib/typescript/module/plugins/insights/eventId.d.ts +18 -0
- package/lib/typescript/module/plugins/insights/eventId.d.ts.map +1 -0
- package/lib/typescript/module/plugins/insights/index.d.ts +40 -0
- package/lib/typescript/module/plugins/insights/index.d.ts.map +1 -0
- package/lib/typescript/module/plugins/insights/sender.d.ts +74 -0
- package/lib/typescript/module/plugins/insights/sender.d.ts.map +1 -0
- package/lib/typescript/module/plugins/insights/state.d.ts +46 -0
- package/lib/typescript/module/plugins/insights/state.d.ts.map +1 -0
- package/lib/typescript/module/releaseCatalogCache.d.ts +5 -1
- package/lib/typescript/module/releaseCatalogCache.d.ts.map +1 -1
- package/lib/typescript/module/sdkVersion.d.ts +1 -1
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +34 -12
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/updateError.d.ts +26 -0
- package/lib/typescript/module/updateError.d.ts.map +1 -0
- package/lib/typescript/module/wrap.d.ts.map +1 -1
- package/lib/typescript/module/wrap.types.d.ts +6 -10
- package/lib/typescript/module/wrap.types.d.ts.map +1 -1
- package/package.json +14 -2
- package/plugins/insights/package.json +8 -0
- package/src/appReady.spec.ts +393 -0
- package/src/{notifyAppReadyInsights.test-utils.ts → appReady.test-utils.ts} +7 -7
- package/src/appReady.ts +149 -0
- package/src/baseURL.ts +15 -0
- package/src/checkForUpdate.releaseCatalog.spec.ts +370 -76
- package/src/checkForUpdate.ts +135 -80
- package/src/clientPlugin.ts +231 -0
- package/src/entryImportGraph.spec.ts +65 -0
- package/src/fetchJSON.ts +3 -10
- package/src/httpClient.spec.ts +30 -227
- package/src/httpClient.ts +20 -256
- package/src/index.spec.ts +117 -93
- package/src/index.ts +67 -52
- package/src/native.spec.ts +98 -72
- package/src/native.ts +93 -77
- package/src/pluginHost.spec.ts +297 -0
- package/src/pluginHost.ts +262 -0
- package/src/plugins/insights/eventId.spec.ts +60 -0
- package/src/plugins/insights/eventId.ts +171 -0
- package/src/plugins/insights/index.ts +367 -0
- package/src/plugins/insights/insights.spec.ts +732 -0
- package/src/plugins/insights/sender.spec.ts +287 -0
- package/src/plugins/insights/sender.ts +221 -0
- package/src/plugins/insights/state.ts +184 -0
- package/src/releaseCatalogCache.spec.ts +22 -0
- package/src/releaseCatalogCache.ts +19 -4
- package/src/sdkVersion.ts +1 -1
- package/src/specs/NativeHotUpdater.ts +34 -13
- package/src/updateError.spec.ts +144 -0
- package/src/updateError.ts +153 -0
- package/src/wrap.progress.spec.ts +232 -0
- package/src/wrap.spec.ts +100 -283
- package/src/wrap.tsx +57 -26
- package/src/wrap.types.ts +6 -12
- package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js +0 -225
- package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.js +0 -188
- package/lib/commonjs/notifyAppReadyInsights.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.spec.js +0 -378
- package/lib/commonjs/notifyAppReadyInsights.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +0 -1
- package/lib/commonjs/notifyAppReadyInsights.transport.spec.js +0 -171
- package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +0 -1
- package/lib/commonjs/uuidv7.js +0 -41
- package/lib/commonjs/uuidv7.js.map +0 -1
- package/lib/commonjs/uuidv7.spec.js +0 -30
- package/lib/commonjs/uuidv7.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.boundary.spec.js +0 -224
- package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.js +0 -181
- package/lib/module/notifyAppReadyInsights.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.spec.js +0 -377
- package/lib/module/notifyAppReadyInsights.spec.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.test-utils.js.map +0 -1
- package/lib/module/notifyAppReadyInsights.transport.spec.js +0 -170
- package/lib/module/notifyAppReadyInsights.transport.spec.js.map +0 -1
- package/lib/module/uuidv7.js +0 -36
- package/lib/module/uuidv7.js.map +0 -1
- package/lib/module/uuidv7.spec.js +0 -30
- package/lib/module/uuidv7.spec.js.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +0 -25
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +0 -8
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
- package/lib/typescript/commonjs/uuidv7.d.ts +0 -10
- package/lib/typescript/commonjs/uuidv7.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyInsights.d.ts +0 -25
- package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +0 -8
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +0 -1
- package/lib/typescript/module/uuidv7.d.ts +0 -10
- package/lib/typescript/module/uuidv7.d.ts.map +0 -1
- package/src/notifyAppReadyInsights.boundary.spec.ts +0 -242
- package/src/notifyAppReadyInsights.spec.ts +0 -362
- package/src/notifyAppReadyInsights.transport.spec.ts +0 -196
- package/src/notifyAppReadyInsights.ts +0 -293
- package/src/uuidv7.spec.ts +0 -25
- package/src/uuidv7.ts +0 -38
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _core = require("@hot-updater/core");
|
|
4
4
|
var _vitest = require("vitest");
|
|
5
|
+
var _updateError = require("./updateError.js");
|
|
5
6
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
6
7
|
const MINIMUM_RELEASE_ID = "00000000-0000-7000-8000-000000000001";
|
|
7
8
|
const RELEASE_ID = "00000000-0000-7000-8000-000000000002";
|
|
@@ -16,31 +17,38 @@ const SCOPE_KEY = (0, _core.createReleaseCatalogScopeKey)({
|
|
|
16
17
|
platform: "ios",
|
|
17
18
|
strategy: "APP_VERSION"
|
|
18
19
|
});
|
|
19
|
-
const mocks = _vitest.vi.hoisted(() =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
const mocks = _vitest.vi.hoisted(() => {
|
|
21
|
+
Reflect.set(globalThis, "HotUpdater", {
|
|
22
|
+
SDK_VERSION: "test-sdk-version"
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
addListener: _vitest.vi.fn(() => () => {}),
|
|
26
|
+
acceptReleaseCatalog: _vitest.vi.fn(() => true),
|
|
27
|
+
commitReleaseSelection: _vitest.vi.fn(async () => true),
|
|
28
|
+
getActiveUpdateState: _vitest.vi.fn(() => ({
|
|
29
|
+
activeSelection: null,
|
|
30
|
+
highestSeenCatalogs: {},
|
|
31
|
+
stableSelection: null,
|
|
32
|
+
verificationPending: false
|
|
33
|
+
})),
|
|
34
|
+
getAppVersion: _vitest.vi.fn(() => "1.2"),
|
|
35
|
+
getBundleId: _vitest.vi.fn(() => CURRENT_BUNDLE_ID),
|
|
36
|
+
getChannel: _vitest.vi.fn(() => CHANNEL),
|
|
37
|
+
getCohort: _vitest.vi.fn(() => "123"),
|
|
38
|
+
getCrashHistory: _vitest.vi.fn(() => []),
|
|
39
|
+
getDefaultChannel: _vitest.vi.fn(() => CHANNEL),
|
|
40
|
+
getFingerprintHash: _vitest.vi.fn(() => null),
|
|
41
|
+
getInstallId: _vitest.vi.fn(() => "install-id"),
|
|
42
|
+
getMinBundleId: _vitest.vi.fn(() => MINIMUM_RELEASE_ID),
|
|
43
|
+
isChannelSwitched: _vitest.vi.fn(() => false),
|
|
44
|
+
isReleaseSelectionCurrent: _vitest.vi.fn(() => true),
|
|
45
|
+
resetChannel: _vitest.vi.fn(),
|
|
46
|
+
stageBundle: _vitest.vi.fn(async () => ({
|
|
47
|
+
delivery: "manifest",
|
|
48
|
+
patchFallback: false
|
|
49
|
+
}))
|
|
50
|
+
};
|
|
51
|
+
});
|
|
44
52
|
_vitest.vi.mock("react-native", () => ({
|
|
45
53
|
Platform: {
|
|
46
54
|
OS: "ios"
|
|
@@ -75,11 +83,9 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
75
83
|
archiveUrl: "https://updates.example.com/bundle.tar.br"
|
|
76
84
|
};
|
|
77
85
|
const resolveArtifact = _vitest.vi.fn(async () => artifact);
|
|
78
|
-
const sendInsightsEvent = _vitest.vi.fn(async () => undefined);
|
|
79
86
|
const session = {
|
|
80
87
|
fetchReleaseCatalog,
|
|
81
|
-
resolveArtifact
|
|
82
|
-
sendInsightsEvent
|
|
88
|
+
resolveArtifact
|
|
83
89
|
};
|
|
84
90
|
const client = {
|
|
85
91
|
createSession: _vitest.vi.fn(async () => session)
|
|
@@ -87,10 +93,33 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
87
93
|
return {
|
|
88
94
|
client,
|
|
89
95
|
fetchReleaseCatalog,
|
|
90
|
-
resolveArtifact
|
|
91
|
-
sendInsightsEvent
|
|
96
|
+
resolveArtifact
|
|
92
97
|
};
|
|
93
98
|
};
|
|
99
|
+
/** Records what checks report to plugins, in order. */
|
|
100
|
+
const recordPluginEvents = async () => {
|
|
101
|
+
const {
|
|
102
|
+
configurePlugins
|
|
103
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./pluginHost")));
|
|
104
|
+
const events = [];
|
|
105
|
+
configurePlugins([{
|
|
106
|
+
id: "recorder",
|
|
107
|
+
setup: () => ({
|
|
108
|
+
onUpdateCheck: result => {
|
|
109
|
+
events.push(["onUpdateCheck", result]);
|
|
110
|
+
},
|
|
111
|
+
onBundleDownloaded: info => {
|
|
112
|
+
events.push(["onBundleDownloaded", info]);
|
|
113
|
+
},
|
|
114
|
+
onUpdateError: error => {
|
|
115
|
+
events.push(["onUpdateError", error]);
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
}], {
|
|
119
|
+
baseURL: "https://updates.example.com"
|
|
120
|
+
});
|
|
121
|
+
return events;
|
|
122
|
+
};
|
|
94
123
|
(0, _vitest.describe)("checkForUpdate Release catalog protocol", () => {
|
|
95
124
|
(0, _vitest.beforeEach)(() => {
|
|
96
125
|
_vitest.vi.resetModules();
|
|
@@ -105,58 +134,74 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
105
134
|
});
|
|
106
135
|
mocks.isReleaseSelectionCurrent.mockReturnValue(true);
|
|
107
136
|
mocks.commitReleaseSelection.mockResolvedValue(true);
|
|
108
|
-
mocks.
|
|
137
|
+
mocks.stageBundle.mockResolvedValue({
|
|
138
|
+
delivery: "manifest",
|
|
139
|
+
patchFallback: false
|
|
140
|
+
});
|
|
109
141
|
});
|
|
110
|
-
(0, _vitest.it)("reports
|
|
142
|
+
(0, _vitest.it)("reports the check, then the download only after staging", async () => {
|
|
111
143
|
const {
|
|
112
144
|
checkForUpdate
|
|
113
145
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
146
|
+
const events = await recordPluginEvents();
|
|
114
147
|
const {
|
|
115
|
-
client
|
|
116
|
-
sendInsightsEvent
|
|
148
|
+
client
|
|
117
149
|
} = createClient();
|
|
118
150
|
let complete;
|
|
119
|
-
mocks.
|
|
151
|
+
mocks.stageBundle.mockImplementationOnce(() => new Promise(resolve => {
|
|
120
152
|
complete = resolve;
|
|
121
153
|
}));
|
|
122
154
|
const update = await checkForUpdate({
|
|
123
155
|
client,
|
|
124
|
-
insights: true,
|
|
125
156
|
updateStrategy: "appVersion"
|
|
126
157
|
});
|
|
127
158
|
(0, _vitest.expect)(update?.shouldForceUpdate).toBe(false);
|
|
159
|
+
(0, _vitest.expect)(events).toEqual([["onUpdateCheck", {
|
|
160
|
+
status: "UPDATE_AVAILABLE",
|
|
161
|
+
channel: CHANNEL,
|
|
162
|
+
fromBundleId: CURRENT_BUNDLE_ID,
|
|
163
|
+
fromReleaseId: null,
|
|
164
|
+
toBundleId: TARGET_BUNDLE_ID,
|
|
165
|
+
toReleaseId: RELEASE_ID,
|
|
166
|
+
transitionKind: "INSTALL",
|
|
167
|
+
updateStatus: "UPDATE",
|
|
168
|
+
shouldForceUpdate: false,
|
|
169
|
+
updateStrategy: "appVersion"
|
|
170
|
+
}]]);
|
|
128
171
|
const pending = update.updateBundle();
|
|
129
|
-
await _vitest.vi.waitFor(() => (0, _vitest.expect)(mocks.
|
|
130
|
-
(0, _vitest.expect)(
|
|
131
|
-
complete(
|
|
172
|
+
await _vitest.vi.waitFor(() => (0, _vitest.expect)(mocks.stageBundle).toHaveBeenCalledOnce());
|
|
173
|
+
(0, _vitest.expect)(events).toHaveLength(1);
|
|
174
|
+
complete({
|
|
175
|
+
delivery: "patch",
|
|
176
|
+
patchFallback: true
|
|
177
|
+
});
|
|
132
178
|
await (0, _vitest.expect)(pending).resolves.toBe(true);
|
|
133
|
-
(0, _vitest.expect)(
|
|
134
|
-
|
|
179
|
+
(0, _vitest.expect)(events[1]).toEqual(["onBundleDownloaded", {
|
|
180
|
+
channel: CHANNEL,
|
|
135
181
|
fromBundleId: CURRENT_BUNDLE_ID,
|
|
136
|
-
toBundleId: TARGET_BUNDLE_ID,
|
|
137
182
|
fromReleaseId: null,
|
|
183
|
+
toBundleId: TARGET_BUNDLE_ID,
|
|
138
184
|
toReleaseId: RELEASE_ID,
|
|
139
|
-
updateStrategy: "appVersion"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
185
|
+
updateStrategy: "appVersion",
|
|
186
|
+
delivery: "patch",
|
|
187
|
+
patchFallback: true
|
|
188
|
+
}]);
|
|
143
189
|
});
|
|
144
|
-
_vitest.it.each([
|
|
190
|
+
_vitest.it.each(["nothing new", "failure"])("does not report a download when staging brings %s", async result => {
|
|
145
191
|
const {
|
|
146
192
|
checkForUpdate
|
|
147
193
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
194
|
+
const events = await recordPluginEvents();
|
|
148
195
|
const {
|
|
149
|
-
client
|
|
150
|
-
sendInsightsEvent
|
|
196
|
+
client
|
|
151
197
|
} = createClient();
|
|
152
|
-
if (result ===
|
|
198
|
+
if (result === "nothing new") mocks.stageBundle.mockResolvedValueOnce(null);else mocks.stageBundle.mockRejectedValueOnce(new Error("download failed"));
|
|
153
199
|
const update = await checkForUpdate({
|
|
154
200
|
client,
|
|
155
|
-
insights: true,
|
|
156
201
|
updateStrategy: "appVersion"
|
|
157
202
|
});
|
|
158
203
|
await update.updateBundle().catch(() => false);
|
|
159
|
-
(0, _vitest.expect)(
|
|
204
|
+
(0, _vitest.expect)(events.map(([name]) => name)).not.toContain("onBundleDownloaded");
|
|
160
205
|
});
|
|
161
206
|
(0, _vitest.it)("selects locally and defers Bundle artifact resolution until install", async () => {
|
|
162
207
|
const {
|
|
@@ -193,7 +238,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
193
238
|
requestTimeout: undefined,
|
|
194
239
|
targetBundleId: TARGET_BUNDLE_ID
|
|
195
240
|
});
|
|
196
|
-
(0, _vitest.expect)(mocks.
|
|
241
|
+
(0, _vitest.expect)(mocks.stageBundle).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
197
242
|
bundleId: TARGET_BUNDLE_ID,
|
|
198
243
|
archiveUrl: "https://updates.example.com/bundle.tar.br",
|
|
199
244
|
selection: _vitest.expect.objectContaining({
|
|
@@ -231,10 +276,10 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
231
276
|
shouldForceUpdate: true
|
|
232
277
|
}]
|
|
233
278
|
});
|
|
279
|
+
const events = await recordPluginEvents();
|
|
234
280
|
const {
|
|
235
281
|
client,
|
|
236
|
-
resolveArtifact
|
|
237
|
-
sendInsightsEvent
|
|
282
|
+
resolveArtifact
|
|
238
283
|
} = createClient(forceCatalog);
|
|
239
284
|
const result = await checkForUpdate({
|
|
240
285
|
client,
|
|
@@ -247,8 +292,8 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
247
292
|
});
|
|
248
293
|
await (0, _vitest.expect)(result?.updateBundle()).resolves.toBe(true);
|
|
249
294
|
(0, _vitest.expect)(resolveArtifact).not.toHaveBeenCalled();
|
|
250
|
-
(0, _vitest.expect)(mocks.
|
|
251
|
-
(0, _vitest.expect)(
|
|
295
|
+
(0, _vitest.expect)(mocks.stageBundle).not.toHaveBeenCalled();
|
|
296
|
+
(0, _vitest.expect)(events.map(([name]) => name)).not.toContain("onBundleDownloaded");
|
|
252
297
|
(0, _vitest.expect)(mocks.commitReleaseSelection).toHaveBeenCalledWith({
|
|
253
298
|
guard: _vitest.expect.objectContaining({
|
|
254
299
|
generation: 2,
|
|
@@ -260,7 +305,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
260
305
|
})
|
|
261
306
|
});
|
|
262
307
|
});
|
|
263
|
-
(0, _vitest.it)("reports same-file
|
|
308
|
+
(0, _vitest.it)("reports a same-file adoption as UNCHANGED with the adopted Release", async () => {
|
|
264
309
|
const active = {
|
|
265
310
|
catalogId: CATALOG_ID,
|
|
266
311
|
bundleId: TARGET_BUNDLE_ID,
|
|
@@ -282,24 +327,22 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
282
327
|
const {
|
|
283
328
|
checkForUpdate
|
|
284
329
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
330
|
+
const events = await recordPluginEvents();
|
|
285
331
|
const {
|
|
286
|
-
client
|
|
287
|
-
sendInsightsEvent
|
|
332
|
+
client
|
|
288
333
|
} = createClient();
|
|
289
334
|
const result = await checkForUpdate({
|
|
290
|
-
insights: true,
|
|
291
335
|
client,
|
|
292
336
|
updateStrategy: "appVersion"
|
|
293
337
|
});
|
|
294
338
|
await result?.updateBundle();
|
|
295
|
-
(0, _vitest.expect)(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}));
|
|
339
|
+
(0, _vitest.expect)(events.at(-1)).toEqual(["onUpdateCheck", {
|
|
340
|
+
status: "UNCHANGED",
|
|
341
|
+
channel: CHANNEL,
|
|
342
|
+
bundleId: TARGET_BUNDLE_ID,
|
|
343
|
+
releaseId: RELEASE_ID,
|
|
344
|
+
previousReleaseId: MINIMUM_RELEASE_ID
|
|
345
|
+
}]);
|
|
303
346
|
});
|
|
304
347
|
(0, _vitest.it)("selects a lower-id Release when explicitly switching scopes", async () => {
|
|
305
348
|
const betaChannel = "beta";
|
|
@@ -383,7 +426,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
383
426
|
});
|
|
384
427
|
await (0, _vitest.expect)(result?.updateBundle()).resolves.toBe(true);
|
|
385
428
|
(0, _vitest.expect)(resolveArtifact).not.toHaveBeenCalled();
|
|
386
|
-
(0, _vitest.expect)(mocks.
|
|
429
|
+
(0, _vitest.expect)(mocks.stageBundle).not.toHaveBeenCalled();
|
|
387
430
|
(0, _vitest.expect)(mocks.commitReleaseSelection).toHaveBeenCalledWith({
|
|
388
431
|
guard: _vitest.expect.objectContaining({
|
|
389
432
|
catalogHash: CATALOG_HASH,
|
|
@@ -414,7 +457,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
414
457
|
updateStrategy: "appVersion"
|
|
415
458
|
});
|
|
416
459
|
await (0, _vitest.expect)(result?.updateBundle()).rejects.toBeInstanceOf(StaleReleaseCatalogError);
|
|
417
|
-
(0, _vitest.expect)(mocks.
|
|
460
|
+
(0, _vitest.expect)(mocks.stageBundle).not.toHaveBeenCalled();
|
|
418
461
|
});
|
|
419
462
|
(0, _vitest.it)("installs an older enabled Release as a forced rollback", async () => {
|
|
420
463
|
const active = {
|
|
@@ -463,7 +506,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
463
506
|
transitionKind: "INSTALL"
|
|
464
507
|
});
|
|
465
508
|
await (0, _vitest.expect)(result?.updateBundle()).resolves.toBe(true);
|
|
466
|
-
(0, _vitest.expect)(mocks.
|
|
509
|
+
(0, _vitest.expect)(mocks.stageBundle).toHaveBeenCalledWith(_vitest.expect.objectContaining({
|
|
467
510
|
bundleId: TARGET_BUNDLE_ID,
|
|
468
511
|
status: "ROLLBACK"
|
|
469
512
|
}));
|
|
@@ -564,7 +607,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
564
607
|
})
|
|
565
608
|
}));
|
|
566
609
|
(0, _vitest.expect)(resolveArtifact).not.toHaveBeenCalled();
|
|
567
|
-
(0, _vitest.expect)(mocks.
|
|
610
|
+
(0, _vitest.expect)(mocks.stageBundle).not.toHaveBeenCalled();
|
|
568
611
|
});
|
|
569
612
|
(0, _vitest.it)("does not surface a rollback when the app already uses built-in bytes", async () => {
|
|
570
613
|
mocks.getBundleId.mockReturnValueOnce(MINIMUM_RELEASE_ID);
|
|
@@ -628,7 +671,7 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
628
671
|
}));
|
|
629
672
|
(0, _vitest.expect)(mocks.acceptReleaseCatalog).not.toHaveBeenCalled();
|
|
630
673
|
(0, _vitest.expect)(mocks.commitReleaseSelection).not.toHaveBeenCalled();
|
|
631
|
-
(0, _vitest.expect)(mocks.
|
|
674
|
+
(0, _vitest.expect)(mocks.stageBundle).not.toHaveBeenCalled();
|
|
632
675
|
});
|
|
633
676
|
(0, _vitest.it)("rejects an unexpected Catalog identity before accepting catalog state", async () => {
|
|
634
677
|
const active = {
|
|
@@ -669,5 +712,225 @@ const createClient = (catalog = createCatalog()) => {
|
|
|
669
712
|
}));
|
|
670
713
|
(0, _vitest.expect)(mocks.acceptReleaseCatalog).not.toHaveBeenCalled();
|
|
671
714
|
});
|
|
715
|
+
(0, _vitest.it)("reports a check that found nothing to install as UNCHANGED", async () => {
|
|
716
|
+
mocks.getBundleId.mockReturnValueOnce(MINIMUM_RELEASE_ID);
|
|
717
|
+
const {
|
|
718
|
+
checkForUpdate
|
|
719
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
720
|
+
const events = await recordPluginEvents();
|
|
721
|
+
const {
|
|
722
|
+
client
|
|
723
|
+
} = createClient(createCatalog({
|
|
724
|
+
releases: [],
|
|
725
|
+
rollbackReleases: []
|
|
726
|
+
}));
|
|
727
|
+
await (0, _vitest.expect)(checkForUpdate({
|
|
728
|
+
client,
|
|
729
|
+
updateStrategy: "appVersion"
|
|
730
|
+
})).resolves.toBeNull();
|
|
731
|
+
(0, _vitest.expect)(events).toEqual([["onUpdateCheck", {
|
|
732
|
+
status: "UNCHANGED",
|
|
733
|
+
channel: CHANNEL,
|
|
734
|
+
bundleId: MINIMUM_RELEASE_ID,
|
|
735
|
+
releaseId: null,
|
|
736
|
+
previousReleaseId: null
|
|
737
|
+
}]]);
|
|
738
|
+
});
|
|
739
|
+
(0, _vitest.it)("treats a scope without a catalog as no update, not a failure", async () => {
|
|
740
|
+
const onError = _vitest.vi.fn();
|
|
741
|
+
const {
|
|
742
|
+
checkForUpdate
|
|
743
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
744
|
+
const events = await recordPluginEvents();
|
|
745
|
+
const {
|
|
746
|
+
client,
|
|
747
|
+
fetchReleaseCatalog
|
|
748
|
+
} = createClient();
|
|
749
|
+
fetchReleaseCatalog.mockResolvedValueOnce(null);
|
|
750
|
+
await (0, _vitest.expect)(checkForUpdate({
|
|
751
|
+
client,
|
|
752
|
+
onError,
|
|
753
|
+
updateStrategy: "appVersion"
|
|
754
|
+
})).resolves.toBeNull();
|
|
755
|
+
(0, _vitest.expect)(onError).not.toHaveBeenCalled();
|
|
756
|
+
(0, _vitest.expect)(mocks.acceptReleaseCatalog).not.toHaveBeenCalled();
|
|
757
|
+
(0, _vitest.expect)(events).toEqual([["onUpdateCheck", _vitest.expect.objectContaining({
|
|
758
|
+
status: "UNCHANGED",
|
|
759
|
+
channel: CHANNEL
|
|
760
|
+
})]]);
|
|
761
|
+
});
|
|
762
|
+
_vitest.it.each([{
|
|
763
|
+
label: "an HTTP status",
|
|
764
|
+
error: () => new _updateError.UpdateHttpError(503, "Service Unavailable"),
|
|
765
|
+
expected: {
|
|
766
|
+
reason: "http",
|
|
767
|
+
httpStatus: 503
|
|
768
|
+
}
|
|
769
|
+
}, {
|
|
770
|
+
label: "no response",
|
|
771
|
+
error: () => new TypeError("Network request failed"),
|
|
772
|
+
expected: {
|
|
773
|
+
reason: "network"
|
|
774
|
+
}
|
|
775
|
+
}, {
|
|
776
|
+
label: "a 404 without the no-catalog mark",
|
|
777
|
+
error: () => new _updateError.UpdateHttpError(404, "Not Found"),
|
|
778
|
+
expected: {
|
|
779
|
+
reason: "http",
|
|
780
|
+
httpStatus: 404
|
|
781
|
+
}
|
|
782
|
+
}, {
|
|
783
|
+
label: "a timeout",
|
|
784
|
+
error: () => new Error("Request timed out"),
|
|
785
|
+
expected: {
|
|
786
|
+
reason: "network",
|
|
787
|
+
transport: "timeout"
|
|
788
|
+
}
|
|
789
|
+
}, {
|
|
790
|
+
label: "an invalid catalog",
|
|
791
|
+
error: () => new _updateError.InvalidUpdateResponseError("Received an invalid Release catalog"),
|
|
792
|
+
expected: {
|
|
793
|
+
reason: "invalid_response"
|
|
794
|
+
}
|
|
795
|
+
}])("reports a check failed by $label", async ({
|
|
796
|
+
error,
|
|
797
|
+
expected
|
|
798
|
+
}) => {
|
|
799
|
+
const {
|
|
800
|
+
checkForUpdate
|
|
801
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
802
|
+
const events = await recordPluginEvents();
|
|
803
|
+
const {
|
|
804
|
+
client,
|
|
805
|
+
fetchReleaseCatalog
|
|
806
|
+
} = createClient();
|
|
807
|
+
const cause = error();
|
|
808
|
+
fetchReleaseCatalog.mockRejectedValueOnce(cause);
|
|
809
|
+
await (0, _vitest.expect)(checkForUpdate({
|
|
810
|
+
client,
|
|
811
|
+
updateStrategy: "appVersion"
|
|
812
|
+
})).resolves.toBeNull();
|
|
813
|
+
(0, _vitest.expect)(events).toEqual([["onUpdateError", {
|
|
814
|
+
stage: "check",
|
|
815
|
+
resource: "catalog",
|
|
816
|
+
...expected,
|
|
817
|
+
channel: CHANNEL,
|
|
818
|
+
bundleId: CURRENT_BUNDLE_ID,
|
|
819
|
+
releaseId: null,
|
|
820
|
+
updateStrategy: "appVersion",
|
|
821
|
+
cause
|
|
822
|
+
}]]);
|
|
823
|
+
});
|
|
824
|
+
_vitest.it.each([{
|
|
825
|
+
label: "an artifact request answered 500",
|
|
826
|
+
fail: resolveArtifact => resolveArtifact.mockRejectedValueOnce(new _updateError.UpdateHttpError(500, "Internal Server Error")),
|
|
827
|
+
expected: {
|
|
828
|
+
stage: "download",
|
|
829
|
+
reason: "http",
|
|
830
|
+
resource: "artifact",
|
|
831
|
+
httpStatus: 500
|
|
832
|
+
}
|
|
833
|
+
}, {
|
|
834
|
+
label: "native extraction",
|
|
835
|
+
fail: () => mocks.stageBundle.mockRejectedValueOnce(Object.assign(new Error("Failed to extract archive"), {
|
|
836
|
+
code: "UNKNOWN_ERROR",
|
|
837
|
+
userInfo: {
|
|
838
|
+
reason: "extract",
|
|
839
|
+
stage: "install"
|
|
840
|
+
}
|
|
841
|
+
})),
|
|
842
|
+
expected: {
|
|
843
|
+
stage: "install",
|
|
844
|
+
reason: "extract"
|
|
845
|
+
}
|
|
846
|
+
}, {
|
|
847
|
+
label: "a native HTTP status",
|
|
848
|
+
fail: () => mocks.stageBundle.mockRejectedValueOnce(Object.assign(new Error("Failed to download bundle"), {
|
|
849
|
+
code: "DOWNLOAD_FAILED",
|
|
850
|
+
userInfo: {
|
|
851
|
+
httpStatus: 403,
|
|
852
|
+
originCode: "ExpiredToken",
|
|
853
|
+
reason: "http",
|
|
854
|
+
resource: "archive",
|
|
855
|
+
stage: "download"
|
|
856
|
+
}
|
|
857
|
+
})),
|
|
858
|
+
expected: {
|
|
859
|
+
stage: "download",
|
|
860
|
+
reason: "http",
|
|
861
|
+
resource: "archive",
|
|
862
|
+
httpStatus: 403,
|
|
863
|
+
originCode: "ExpiredToken"
|
|
864
|
+
}
|
|
865
|
+
}, {
|
|
866
|
+
label: "a native connection loss",
|
|
867
|
+
fail: () => mocks.stageBundle.mockRejectedValueOnce(Object.assign(new Error("The network connection was lost."), {
|
|
868
|
+
code: "DOWNLOAD_FAILED",
|
|
869
|
+
userInfo: {
|
|
870
|
+
reason: "network",
|
|
871
|
+
resource: "file",
|
|
872
|
+
stage: "download",
|
|
873
|
+
transport: "connection"
|
|
874
|
+
}
|
|
875
|
+
})),
|
|
876
|
+
expected: {
|
|
877
|
+
stage: "download",
|
|
878
|
+
reason: "network",
|
|
879
|
+
resource: "file",
|
|
880
|
+
transport: "connection"
|
|
881
|
+
}
|
|
882
|
+
}])("reports an install failed by $label and rethrows it", async ({
|
|
883
|
+
fail,
|
|
884
|
+
expected
|
|
885
|
+
}) => {
|
|
886
|
+
const {
|
|
887
|
+
checkForUpdate
|
|
888
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
889
|
+
const events = await recordPluginEvents();
|
|
890
|
+
const {
|
|
891
|
+
client,
|
|
892
|
+
resolveArtifact
|
|
893
|
+
} = createClient();
|
|
894
|
+
fail(resolveArtifact);
|
|
895
|
+
const result = await checkForUpdate({
|
|
896
|
+
client,
|
|
897
|
+
updateStrategy: "appVersion"
|
|
898
|
+
});
|
|
899
|
+
await (0, _vitest.expect)(result.updateBundle()).rejects.toThrow();
|
|
900
|
+
(0, _vitest.expect)(events.filter(([name]) => name === "onUpdateError")).toEqual([["onUpdateError", _vitest.expect.objectContaining({
|
|
901
|
+
...expected,
|
|
902
|
+
channel: CHANNEL,
|
|
903
|
+
bundleId: CURRENT_BUNDLE_ID,
|
|
904
|
+
targetBundleId: TARGET_BUNDLE_ID,
|
|
905
|
+
targetReleaseId: RELEASE_ID,
|
|
906
|
+
updateStrategy: "appVersion"
|
|
907
|
+
})]]);
|
|
908
|
+
});
|
|
909
|
+
_vitest.it.each([{
|
|
910
|
+
label: "a native rejection without a failure class",
|
|
911
|
+
fail: () => mocks.stageBundle.mockRejectedValueOnce(Object.assign(new Error("Release catalog selection is stale"), {
|
|
912
|
+
code: "UNKNOWN_ERROR"
|
|
913
|
+
}))
|
|
914
|
+
}, {
|
|
915
|
+
label: "a selection that became stale",
|
|
916
|
+
fail: () => mocks.isReleaseSelectionCurrent.mockReturnValueOnce(false)
|
|
917
|
+
}])("does not report $label as an update failure", async ({
|
|
918
|
+
fail
|
|
919
|
+
}) => {
|
|
920
|
+
const {
|
|
921
|
+
checkForUpdate
|
|
922
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./checkForUpdate")));
|
|
923
|
+
const events = await recordPluginEvents();
|
|
924
|
+
const {
|
|
925
|
+
client
|
|
926
|
+
} = createClient();
|
|
927
|
+
const result = await checkForUpdate({
|
|
928
|
+
client,
|
|
929
|
+
updateStrategy: "appVersion"
|
|
930
|
+
});
|
|
931
|
+
fail();
|
|
932
|
+
await (0, _vitest.expect)(result.updateBundle()).rejects.toThrow();
|
|
933
|
+
(0, _vitest.expect)(events.map(([name]) => name)).toEqual(["onUpdateCheck"]);
|
|
934
|
+
});
|
|
672
935
|
});
|
|
673
936
|
//# sourceMappingURL=checkForUpdate.releaseCatalog.spec.js.map
|