@hot-updater/test-utils 1.2.0-rc.21 → 1.2.0-rc.22

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 +132 -10
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -488,20 +488,20 @@ const setupCoreAdminTestSuite = (options) => {
488
488
  const older = await register("64", "store-fingerprint");
489
489
  const newer = await register("65", "store-fingerprint");
490
490
  const otherScope = await register("66", "store-fingerprint-b");
491
- expect(older.store_build).toBeNull();
491
+ expect(older.is_store_build).toBe(false);
492
492
  expect((await adminJson(markRead("store-fingerprint"))).data).toBeNull();
493
493
  const marked = await mark(older.id, true);
494
494
  expect(marked.status).toBe(200);
495
495
  expect(await marked.json()).toMatchObject({ data: {
496
496
  nativeBuild: {
497
497
  id: older.id,
498
- store_build: true
498
+ is_store_build: true
499
499
  },
500
500
  previous: null
501
501
  } });
502
502
  expect((await adminJson(markRead("store-fingerprint"))).data).toEqual({
503
503
  ...older,
504
- store_build: true
504
+ is_store_build: true
505
505
  });
506
506
  expect((await adminJson(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(channel)}&fingerprintHash=store-fingerprint`)).data).toEqual(newer);
507
507
  expect((await adminJson(markRead("store-fingerprint-b"))).data).toBeNull();
@@ -509,24 +509,24 @@ const setupCoreAdminTestSuite = (options) => {
509
509
  expect(await replaced.json()).toMatchObject({ data: {
510
510
  nativeBuild: {
511
511
  id: newer.id,
512
- store_build: true
512
+ is_store_build: true
513
513
  },
514
514
  previous: {
515
515
  id: older.id,
516
- store_build: null
516
+ is_store_build: false
517
517
  }
518
518
  } });
519
519
  expect((await adminJson(`/native-builds/${older.id}`)).data).toEqual(older);
520
520
  expect((await adminJson(markRead("store-fingerprint"))).data).toEqual({
521
521
  ...newer,
522
- store_build: true
522
+ is_store_build: true
523
523
  });
524
524
  const race = async (ids) => {
525
525
  const responses = await Promise.all(ids.map((id) => mark(id, true)));
526
526
  expect(responses.map(({ status }) => status)).toEqual(ids.map(() => 200));
527
527
  const results = await Promise.all(responses.map((response) => response.json()));
528
- expect(results.map(({ data }) => data.nativeBuild.store_build)).toEqual(ids.map(() => true));
529
- const holders = (await Promise.all([older, newer].map(async ({ id }) => (await adminJson(`/native-builds/${id}`)).data))).filter(({ store_build }) => store_build === true);
528
+ expect(results.map(({ data }) => data.nativeBuild.is_store_build)).toEqual(ids.map(() => true));
529
+ const holders = (await Promise.all([older, newer].map(async ({ id }) => (await adminJson(`/native-builds/${id}`)).data))).filter(({ is_store_build }) => is_store_build);
530
530
  expect(holders).toHaveLength(1);
531
531
  expect(ids).toContain(holders[0].id);
532
532
  };
@@ -550,6 +550,81 @@ const setupCoreAdminTestSuite = (options) => {
550
550
  await adminJson(`/native-builds/${otherScope.id}`, jsonRequest("DELETE"));
551
551
  expect((await adminJson(markRead("store-fingerprint-b"))).data).toBeNull();
552
552
  });
553
+ it("records a sandbox build, and refuses one that disagrees with its channel", async () => {
554
+ const sandboxChannel = `sandbox-${namespace}`;
555
+ const channel = `plain-${namespace}`;
556
+ const post = (suffix, body) => {
557
+ const builtIn = bundleRow(suffix);
558
+ return admin("/native-builds", jsonRequest("POST", {
559
+ id: bundleRow(`8${suffix}`).id,
560
+ platform: "ios",
561
+ fingerprintHash: "sandbox-fingerprint",
562
+ appVersion: null,
563
+ minBundleId: builtIn.id,
564
+ gitCommitHash: null,
565
+ buildKey: null,
566
+ artifact: {
567
+ kind: "ipa",
568
+ storageUri: `storage://native-builds/ios/${suffix}/App.ipa`,
569
+ byteSize: 1e3
570
+ },
571
+ embeddedBundle: {
572
+ manifestStorageUri: builtIn.manifest_storage_uri,
573
+ manifestFileHash: builtIn.manifest_file_hash,
574
+ assetBaseStorageUri: builtIn.asset_base_storage_uri
575
+ },
576
+ ...body
577
+ }));
578
+ };
579
+ const refusal = async (suffix, body) => {
580
+ const response = await post(suffix, body);
581
+ await response.text();
582
+ return response.status;
583
+ };
584
+ expect(await refusal("74", {
585
+ channel,
586
+ isSandbox: true
587
+ })).toBe(400);
588
+ expect(await refusal("74", { channel: sandboxChannel })).toBe(400);
589
+ expect(await refusal("74", {
590
+ channel: sandboxChannel,
591
+ isSandbox: false
592
+ })).toBe(400);
593
+ expect(await refusal("74", {
594
+ channel: sandboxChannel,
595
+ isSandbox: null
596
+ })).toBe(400);
597
+ expect(await refusal("74", {
598
+ channel: sandboxChannel,
599
+ isSandbox: "yes"
600
+ })).toBe(400);
601
+ const tagged = await post("72", {
602
+ channel: sandboxChannel,
603
+ isSandbox: true
604
+ });
605
+ expect(tagged.status).toBe(201);
606
+ const sandboxBuild = (await tagged.json()).data;
607
+ const plain = await post("73", {
608
+ channel,
609
+ isSandbox: false
610
+ });
611
+ expect(plain.status).toBe(201);
612
+ const plainBuild = (await plain.json()).data;
613
+ expect(sandboxBuild).toMatchObject({
614
+ is_sandbox: true,
615
+ is_store_build: false
616
+ });
617
+ expect(plainBuild).toMatchObject({
618
+ is_sandbox: false,
619
+ is_store_build: false
620
+ });
621
+ expect((await adminJson(`/native-builds/${sandboxBuild.id}`)).data).toEqual(sandboxBuild);
622
+ expect((await adminJson(`/native-builds/${plainBuild.id}`)).data).toEqual(plainBuild);
623
+ expect((await adminJson(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint`)).data).toEqual(sandboxBuild);
624
+ const marked = await admin(`/native-builds/${sandboxBuild.id}/store-build`, jsonRequest("POST", { storeBuild: true }));
625
+ expect(marked.status).toBe(400);
626
+ await marked.text();
627
+ });
553
628
  it("lists the patches that start from a bundle", async () => {
554
629
  const base = bundleRow("50");
555
630
  const target = bundleRow("51");
@@ -1649,6 +1724,15 @@ const conformanceItems = {
1649
1724
  type: "string",
1650
1725
  nullable: true
1651
1726
  },
1727
+ (
1728
+ /** A unique slot only some rows hold, as long as a scope key. */
1729
+ {
1730
+ name: "slot",
1731
+ type: "string",
1732
+ nullable: true,
1733
+ maxLength: 2048,
1734
+ ascii: true
1735
+ }),
1652
1736
  {
1653
1737
  name: "_v",
1654
1738
  type: "integer",
@@ -1682,6 +1766,12 @@ const conformanceItems = {
1682
1766
  name: "byTag",
1683
1767
  eq: ["tags"],
1684
1768
  sort: ["score"]
1769
+ },
1770
+ {
1771
+ name: "bySlot",
1772
+ eq: ["slot"],
1773
+ sort: [],
1774
+ unique: true
1685
1775
  }
1686
1776
  ]
1687
1777
  };
@@ -1792,6 +1882,7 @@ const item = (id, values = {}) => ({
1792
1882
  tags: null,
1793
1883
  payload: null,
1794
1884
  note: null,
1885
+ slot: null,
1795
1886
  _v: 0,
1796
1887
  ...values
1797
1888
  });
@@ -2102,6 +2193,37 @@ const setupDatabaseAdapterConformanceSuite = (options) => {
2102
2193
  eq: ["L"]
2103
2194
  }))).toEqual(["f"]);
2104
2195
  });
2196
+ it("moves a unique slot between rows in one write, and holds a long ASCII value", async () => {
2197
+ const adapter = await setup();
2198
+ const slot = `s:${"a".repeat(998)}`;
2199
+ await ok(adapter, [
2200
+ insert(item("a", { slot })),
2201
+ insert(item("b")),
2202
+ insert(item("c"))
2203
+ ]);
2204
+ expect(await adapter.write([insert(item("d", { slot }))])).toEqual({
2205
+ ok: false,
2206
+ failedOp: 0
2207
+ });
2208
+ const patch = (id, from, to) => ({
2209
+ type: "patch",
2210
+ table: conformanceItems,
2211
+ key: [id],
2212
+ set: { slot: to },
2213
+ guard: { v: 0 },
2214
+ previous: item(id, { slot: from })
2215
+ });
2216
+ expect(await adapter.write([patch("b", null, slot)])).toEqual({
2217
+ ok: false,
2218
+ failedOp: 0
2219
+ });
2220
+ await ok(adapter, [patch("a", slot, null), patch("b", null, slot)]);
2221
+ expect(ids(await query(adapter, {
2222
+ index: "bySlot",
2223
+ eq: [slot]
2224
+ }))).toEqual(["b"]);
2225
+ expect(await one(adapter, "a")).toMatchObject({ slot: null });
2226
+ });
2105
2227
  it("orders strings by UTF-8 bytes and numbers numerically", async () => {
2106
2228
  const adapter = await setup();
2107
2229
  const names = [
@@ -3462,7 +3584,7 @@ const READ_BUDGETS = [
3462
3584
  },
3463
3585
  check: (build) => expect(build).toMatchObject({
3464
3586
  min_bundle_id: createBundleFixture("011").id,
3465
- store_build: true
3587
+ is_store_build: true
3466
3588
  })
3467
3589
  }),
3468
3590
  budget({
@@ -3846,7 +3968,7 @@ const READ_BUDGETS = [
3846
3968
  check: (result) => expect(result).toMatchObject({
3847
3969
  nativeBuild: {
3848
3970
  min_bundle_id: createBundleFixture("012").id,
3849
- store_build: true
3971
+ is_store_build: true
3850
3972
  },
3851
3973
  previous: { min_bundle_id: createBundleFixture("011").id }
3852
3974
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/test-utils",
3
- "version": "1.2.0-rc.21",
3
+ "version": "1.2.0-rc.22",
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.21",
54
- "@hot-updater/protocol": "^1.2.0-rc.21",
55
- "@hot-updater/plugin-core": "^1.2.0-rc.21",
56
- "@hot-updater/server": "^1.2.0-rc.21"
53
+ "@hot-updater/plugin-insights": "^1.2.0-rc.22",
54
+ "@hot-updater/plugin-core": "^1.2.0-rc.22",
55
+ "@hot-updater/protocol": "^1.2.0-rc.22",
56
+ "@hot-updater/server": "^1.2.0-rc.22"
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.41.7",
87
- "@hot-updater/plugin-insights": "1.2.0-rc.21",
88
- "@hot-updater/plugin-core": "1.2.0-rc.21",
89
- "@hot-updater/protocol": "1.2.0-rc.21",
90
- "@hot-updater/server": "1.2.0-rc.21"
87
+ "@hot-updater/plugin-insights": "1.2.0-rc.22",
88
+ "@hot-updater/plugin-core": "1.2.0-rc.22",
89
+ "@hot-updater/protocol": "1.2.0-rc.22",
90
+ "@hot-updater/server": "1.2.0-rc.22"
91
91
  },
92
92
  "inlinedDependencies": {
93
93
  "@nodelib/fs.scandir": "2.1.5",