@hot-updater/test-utils 1.2.0-rc.42 → 1.2.0-rc.43

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.
Files changed (2) hide show
  1. package/dist/index.mjs +145 -0
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -729,6 +729,55 @@ const setupCoreAdminTestSuite = (options) => {
729
729
  expect(marked.status).toBe(400);
730
730
  await marked.text();
731
731
  });
732
+ it("finds a scope's build of one kind, and a sandbox build's other install target", async () => {
733
+ const channel = `kinds-${namespace}`;
734
+ const register = async (suffix, kind, body = {}) => {
735
+ const builtIn = bundleRow(suffix);
736
+ const response = await admin("/native-builds", jsonRequest("POST", {
737
+ id: bundleRow(`8${suffix}`).id,
738
+ platform: "ios",
739
+ channel,
740
+ fingerprintHash: "kind-fingerprint",
741
+ appVersion: null,
742
+ minBundleId: builtIn.id,
743
+ gitCommitHash: null,
744
+ buildKey: null,
745
+ artifact: {
746
+ kind,
747
+ storageUri: `storage://native-builds/ios/${suffix}/App.${kind === "ipa" ? "ipa" : "app.zip"}`,
748
+ byteSize: 1e3
749
+ },
750
+ embeddedBundle: {
751
+ manifestStorageUri: builtIn.manifest_storage_uri,
752
+ manifestFileHash: builtIn.manifest_file_hash,
753
+ assetBaseStorageUri: builtIn.asset_base_storage_uri
754
+ },
755
+ ...body
756
+ }));
757
+ expect(response.status).toBe(201);
758
+ return (await response.json()).data;
759
+ };
760
+ const sandbox = (exportMethod) => ({
761
+ isSandbox: true,
762
+ sandboxUrlScheme: "acme-preview",
763
+ sandboxAppId: "com.example.app",
764
+ exportMethod
765
+ });
766
+ const ipa = await register("81", "ipa");
767
+ const app = await register("82", "app");
768
+ const latest = `/native-builds/latest?platform=ios&channel=${encodeURIComponent(channel)}&fingerprintHash=kind-fingerprint`;
769
+ expect((await adminJson(latest)).data).toEqual(app);
770
+ expect((await adminJson(`${latest}&kind=ipa`)).data).toEqual(ipa);
771
+ const refused = await admin(`${latest}&kind=apk`);
772
+ expect(refused.status).toBe(400);
773
+ await refused.text();
774
+ const sandboxIpa = await register("83", "ipa", sandbox("ad-hoc"));
775
+ const sandboxApp = await register("84", "app", sandbox(null));
776
+ expect((await adminJson(`/native-builds/${sandboxIpa.id}/sibling`)).data).toEqual(sandboxApp);
777
+ expect((await adminJson(`/native-builds/${sandboxApp.id}/sibling`)).data).toEqual(sandboxIpa);
778
+ expect((await adminJson(`/native-builds/${ipa.id}/sibling`)).data).toBeNull();
779
+ expect((await adminJson(`/native-builds/${bundleRow("899").id}/sibling`)).data).toBeNull();
780
+ });
732
781
  it("requests, approves, renames, records, and removes iOS devices", async () => {
733
782
  const udid = namespace.replaceAll("-", "").padEnd(40, "0");
734
783
  const device = async (path, init) => (await adminJson(path, init)).data;
@@ -3448,6 +3497,34 @@ const nativeBuildSandboxScope = {
3448
3497
  artifactKind: "ipa",
3449
3498
  distribution: "direct"
3450
3499
  };
3500
+ /**
3501
+ * A sandbox ad hoc .ipa of `nativeBuildScope`'s fingerprint, as a build page
3502
+ * holds its row: the source of a sibling read.
3503
+ */
3504
+ const sandboxIpaRow = {
3505
+ id: "01ffffff-ffff-7fff-bfff-ffffffffffff",
3506
+ scope_key: `v1:sandbox:ios:${nativeBuildSandboxScope.appId}:${nativeBuildSandboxScope.urlScheme}:ipa:direct:fingerprint:${nativeBuildScope.fingerprintHash}`,
3507
+ platform: "ios",
3508
+ channel_id: "channel:pr-140",
3509
+ fingerprint_hash: nativeBuildScope.fingerprintHash,
3510
+ app_version: null,
3511
+ min_bundle_id: "01ffffff-ffff-7fff-bfff-fffffffffffe",
3512
+ artifact_kind: "ipa",
3513
+ artifact_storage_uri: "storage://read-budgets/native-builds/ipa/App.ipa",
3514
+ byte_size: 1e3,
3515
+ git_commit_hash: null,
3516
+ created_at_ms: 0,
3517
+ build_key: null,
3518
+ build_number: null,
3519
+ submitted_to: null,
3520
+ submitted_at_ms: null,
3521
+ submitted_version: null,
3522
+ is_store_build: false,
3523
+ is_sandbox: true,
3524
+ sandbox_url_scheme: nativeBuildSandboxScope.urlScheme,
3525
+ export_method: "ad-hoc",
3526
+ native_app_version: null
3527
+ };
3451
3528
  /** The native build key the older of the two native builds is registered with. */
3452
3529
  const nativeBuildKey = `nbk1:${"0".repeat(64)}`;
3453
3530
  const bundleEvents = {
@@ -3530,6 +3607,27 @@ const seed = async (database) => {
3530
3607
  }
3531
3608
  });
3532
3609
  await core.markNativeBuild(createBundleFixture("8011").id, { storeBuild: true });
3610
+ await core.registerNativeBuild({
3611
+ ...nativeBuildScope,
3612
+ channel: "beta",
3613
+ id: createBundleFixture("8005").id,
3614
+ minBundleId: createBundleFixture("005").id,
3615
+ gitCommitHash: null,
3616
+ buildKey: null,
3617
+ isSandbox: true,
3618
+ sandboxAppId: nativeBuildSandboxScope.appId,
3619
+ sandboxUrlScheme: nativeBuildSandboxScope.urlScheme,
3620
+ artifact: {
3621
+ kind: "app",
3622
+ storageUri: "storage://read-budgets/native-builds/005/App.app.zip",
3623
+ byteSize: 1e3
3624
+ },
3625
+ embeddedBundle: {
3626
+ manifestStorageUri: "storage://bundles/005/manifest.json",
3627
+ manifestFileHash: "manifest-hash-005",
3628
+ assetBaseStorageUri: "storage://read-budgets/assets"
3629
+ }
3630
+ });
3533
3631
  const pendingDevice = (await core.requestIosDevice({
3534
3632
  udid: BUDGET_PENDING_UDID,
3535
3633
  name: "Pending iPhone",
@@ -3878,6 +3976,53 @@ const READ_BUDGETS = [
3878
3976
  build_key: nativeBuildKey
3879
3977
  })
3880
3978
  }),
3979
+ budget({
3980
+ api: "native build of a kind: byScopeKind descending, limit 1",
3981
+ read: ({ core }) => core.findNativeBuild(nativeBuildScope, { artifactKind: "ipa" }),
3982
+ adapter: reads(0, 0, 1, 1),
3983
+ engine: {
3984
+ calls: 1,
3985
+ rows: 1
3986
+ },
3987
+ check: (build) => expect(build).toMatchObject({ min_bundle_id: createBundleFixture("012").id })
3988
+ }),
3989
+ budget({
3990
+ api: "native build of a kind with none: byScopeKind, then byScope, limit 1",
3991
+ read: ({ core }) => core.findNativeBuild(nativeBuildScope, { artifactKind: "app" }),
3992
+ adapter: reads(0, 0, 2, 1),
3993
+ engine: {
3994
+ calls: 2,
3995
+ rows: 1
3996
+ },
3997
+ check: (build) => expect(build).toBeNull()
3998
+ }),
3999
+ budget({
4000
+ api: "sandbox build's other install target: byScope descending, limit 1",
4001
+ read: ({ core }) => core.findNativeBuildSibling(sandboxIpaRow),
4002
+ adapter: reads(0, 0, 1, 1),
4003
+ engine: {
4004
+ calls: 1,
4005
+ rows: 1
4006
+ },
4007
+ check: (build) => expect(build).toMatchObject({
4008
+ id: createBundleFixture("8005").id,
4009
+ artifact_kind: "app"
4010
+ })
4011
+ }),
4012
+ budget({
4013
+ api: "normal build's other install target: no read",
4014
+ read: ({ core }) => core.findNativeBuildSibling({
4015
+ ...sandboxIpaRow,
4016
+ is_sandbox: false,
4017
+ scope_key: "normal"
4018
+ }),
4019
+ adapter: reads(0, 0, 0, 0),
4020
+ engine: {
4021
+ calls: 0,
4022
+ rows: 0
4023
+ },
4024
+ check: (build) => expect(build).toBeNull()
4025
+ }),
3881
4026
  budget({
3882
4027
  api: "native build list: all descending, limit rows",
3883
4028
  read: ({ core }) => core.listNativeBuilds({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/test-utils",
3
- "version": "1.2.0-rc.42",
3
+ "version": "1.2.0-rc.43",
4
4
  "type": "module",
5
5
  "description": "Test utilities for Hot Updater packages",
6
6
  "sideEffects": false,
@@ -50,10 +50,10 @@
50
50
  "mysql2": "*",
51
51
  "pg": "*",
52
52
  "vitest": "^4.0.0",
53
- "@hot-updater/plugin-insights": "^1.2.0-rc.42",
54
- "@hot-updater/protocol": "^1.2.0-rc.42",
55
- "@hot-updater/plugin-core": "^1.2.0-rc.42",
56
- "@hot-updater/server": "^1.2.0-rc.42"
53
+ "@hot-updater/plugin-insights": "^1.2.0-rc.43",
54
+ "@hot-updater/protocol": "^1.2.0-rc.43",
55
+ "@hot-updater/plugin-core": "^1.2.0-rc.43",
56
+ "@hot-updater/server": "^1.2.0-rc.43"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "@electric-sql/pglite": {
@@ -84,10 +84,10 @@
84
84
  "typescript": "npm:@typescript/typescript6@6.0.2",
85
85
  "vitest": "4.1.4",
86
86
  "workspace-tools": "^0.42.3",
87
- "@hot-updater/plugin-insights": "1.2.0-rc.42",
88
- "@hot-updater/protocol": "1.2.0-rc.42",
89
- "@hot-updater/plugin-core": "1.2.0-rc.42",
90
- "@hot-updater/server": "1.2.0-rc.42"
87
+ "@hot-updater/plugin-insights": "1.2.0-rc.43",
88
+ "@hot-updater/protocol": "1.2.0-rc.43",
89
+ "@hot-updater/plugin-core": "1.2.0-rc.43",
90
+ "@hot-updater/server": "1.2.0-rc.43"
91
91
  },
92
92
  "inlinedDependencies": {
93
93
  "@clack/core": "1.4.3",