@hot-updater/test-utils 1.2.0-rc.40 → 1.2.0-rc.41
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/dist/index.mjs +73 -13
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -580,9 +580,15 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
580
580
|
await adminJson(`/native-builds/${otherScope.id}`, jsonRequest("DELETE"));
|
|
581
581
|
expect((await adminJson(markRead("store-fingerprint-b"))).data).toBeNull();
|
|
582
582
|
});
|
|
583
|
-
it("records a sandbox build, and refuses one
|
|
584
|
-
const sandboxChannel = `
|
|
583
|
+
it("records a sandbox build on any channel, finds it through its sandbox scope, and refuses one its artifact doesn't describe", async () => {
|
|
584
|
+
const sandboxChannel = `pr-${namespace}`;
|
|
585
585
|
const channel = `plain-${namespace}`;
|
|
586
|
+
const sandboxFields = {
|
|
587
|
+
isSandbox: true,
|
|
588
|
+
sandboxUrlScheme: "acme-preview",
|
|
589
|
+
sandboxAppId: "com.example.app",
|
|
590
|
+
exportMethod: "ad-hoc"
|
|
591
|
+
};
|
|
586
592
|
const post = (suffix, body) => {
|
|
587
593
|
const builtIn = bundleRow(suffix);
|
|
588
594
|
return admin("/native-builds", jsonRequest("POST", {
|
|
@@ -615,10 +621,14 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
615
621
|
channel,
|
|
616
622
|
isSandbox: true
|
|
617
623
|
})).toBe(400);
|
|
618
|
-
expect(await refusal("74", { channel: sandboxChannel })).toBe(400);
|
|
619
624
|
expect(await refusal("74", {
|
|
620
|
-
channel
|
|
621
|
-
|
|
625
|
+
channel,
|
|
626
|
+
...sandboxFields,
|
|
627
|
+
sandboxAppId: void 0
|
|
628
|
+
})).toBe(400);
|
|
629
|
+
expect(await refusal("74", {
|
|
630
|
+
channel,
|
|
631
|
+
sandboxAppId: "com.example.app"
|
|
622
632
|
})).toBe(400);
|
|
623
633
|
expect(await refusal("74", {
|
|
624
634
|
channel: sandboxChannel,
|
|
@@ -634,12 +644,12 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
634
644
|
})).toBe(400);
|
|
635
645
|
expect(await refusal("74", {
|
|
636
646
|
channel: sandboxChannel,
|
|
637
|
-
|
|
647
|
+
...sandboxFields,
|
|
638
648
|
sandboxUrlScheme: "Acme"
|
|
639
649
|
})).toBe(400);
|
|
640
650
|
expect(await refusal("74", {
|
|
641
651
|
channel: sandboxChannel,
|
|
642
|
-
|
|
652
|
+
...sandboxFields,
|
|
643
653
|
sandboxUrlScheme: 42
|
|
644
654
|
})).toBe(400);
|
|
645
655
|
expect(await refusal("74", {
|
|
@@ -652,14 +662,13 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
652
662
|
})).toBe(400);
|
|
653
663
|
const tagged = await post("72", {
|
|
654
664
|
channel: sandboxChannel,
|
|
655
|
-
|
|
656
|
-
sandboxUrlScheme: "acme-preview",
|
|
665
|
+
...sandboxFields,
|
|
657
666
|
nativeAppVersion: "1.6.0"
|
|
658
667
|
});
|
|
659
668
|
expect(tagged.status).toBe(201);
|
|
660
669
|
const sandboxBuild = (await tagged.json()).data;
|
|
661
670
|
const plain = await post("73", {
|
|
662
|
-
channel,
|
|
671
|
+
channel: sandboxChannel,
|
|
663
672
|
isSandbox: false
|
|
664
673
|
});
|
|
665
674
|
expect(plain.status).toBe(201);
|
|
@@ -677,10 +686,18 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
677
686
|
export_method: null,
|
|
678
687
|
native_app_version: null
|
|
679
688
|
});
|
|
689
|
+
const sandboxLookup = "sandboxAppId=com.example.app&sandboxUrlScheme=acme-preview&artifactKind=ipa&distribution=direct";
|
|
680
690
|
expect((await adminJson(`/native-builds/${sandboxBuild.id}`)).data).toEqual(sandboxBuild);
|
|
681
691
|
expect((await adminJson(`/native-builds/${plainBuild.id}`)).data).toEqual(plainBuild);
|
|
682
|
-
expect((await adminJson(`/native-builds/latest?platform=ios&channel
|
|
683
|
-
expect((await adminJson(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint
|
|
692
|
+
expect((await adminJson(`/native-builds/latest?platform=ios&channel=other-${namespace}&fingerprintHash=sandbox-fingerprint&${sandboxLookup}`)).data).toEqual(sandboxBuild);
|
|
693
|
+
expect((await adminJson(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint`)).data).toEqual(plainBuild);
|
|
694
|
+
const partial = await admin(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint&sandboxAppId=com.example.app`);
|
|
695
|
+
expect(partial.status).toBe(400);
|
|
696
|
+
await partial.text();
|
|
697
|
+
const invalid = await admin(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint&${sandboxLookup.replace("artifactKind=ipa", "artifactKind=apk")}`);
|
|
698
|
+
expect(invalid.status).toBe(400);
|
|
699
|
+
await invalid.text();
|
|
700
|
+
expect((await adminJson(`/native-builds/latest?platform=ios&channel=${encodeURIComponent(sandboxChannel)}&fingerprintHash=sandbox-fingerprint&${sandboxLookup}&builtInOlderThan=ffffffff-ffff-7fff-bfff-ffffffffffff`)).data).toBeNull();
|
|
684
701
|
const patched = await admin(`/bundles/${plainBuild.min_bundle_id}`, jsonRequest("PATCH", { patches: [{
|
|
685
702
|
baseBundleId: sandboxBuild.min_bundle_id,
|
|
686
703
|
baseFileHash: "base-hash",
|
|
@@ -782,6 +799,7 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
782
799
|
const owner = claims.find(({ data }) => data.claimed)?.data.issuerId;
|
|
783
800
|
expect(claims.filter(({ data }) => data.claimed)).toHaveLength(1);
|
|
784
801
|
expect(claims.map(({ data }) => data.issuerId)).toEqual([owner, owner]);
|
|
802
|
+
expect(await adminJson("/ios-devices/account")).toEqual({ data: { issuerId: owner } });
|
|
785
803
|
const buildId = bundleRow("90").id;
|
|
786
804
|
const marked = await admin("/ios-devices/in-build", jsonRequest("POST", {
|
|
787
805
|
buildId,
|
|
@@ -801,6 +819,7 @@ const setupCoreAdminTestSuite = (options) => {
|
|
|
801
819
|
}
|
|
802
820
|
expect(await device(`/ios-devices/udid/${udid}`)).toBeNull();
|
|
803
821
|
expect(await device(`/ios-devices/${id}`, jsonRequest("DELETE"))).toBeNull();
|
|
822
|
+
expect((await adminJson("/ios-devices/account")).data).toMatchObject({ issuerId: expect.any(String) });
|
|
804
823
|
});
|
|
805
824
|
it("lists the patches that start from a bundle", async () => {
|
|
806
825
|
const base = bundleRow("50");
|
|
@@ -3422,6 +3441,13 @@ const nativeBuildScope = {
|
|
|
3422
3441
|
fingerprintHash: "native-fingerprint",
|
|
3423
3442
|
appVersion: null
|
|
3424
3443
|
};
|
|
3444
|
+
/** A sandbox scope of `nativeBuildScope`'s fingerprint, which no build has. */
|
|
3445
|
+
const nativeBuildSandboxScope = {
|
|
3446
|
+
appId: "com.example.app",
|
|
3447
|
+
urlScheme: "acme-preview",
|
|
3448
|
+
artifactKind: "ipa",
|
|
3449
|
+
distribution: "direct"
|
|
3450
|
+
};
|
|
3425
3451
|
/** The native build key the older of the two native builds is registered with. */
|
|
3426
3452
|
const nativeBuildKey = `nbk1:${"0".repeat(64)}`;
|
|
3427
3453
|
const bundleEvents = {
|
|
@@ -3816,7 +3842,7 @@ const READ_BUDGETS = [
|
|
|
3816
3842
|
api: "native build older than a bundle in a sandbox scope: no read",
|
|
3817
3843
|
read: ({ core }) => core.findNativeBuild({
|
|
3818
3844
|
...nativeBuildScope,
|
|
3819
|
-
|
|
3845
|
+
sandbox: nativeBuildSandboxScope
|
|
3820
3846
|
}, { builtInOlderThan: "ffffffff-ffff-7fff-bfff-ffffffffffff" }),
|
|
3821
3847
|
adapter: reads(0, 0, 0, 0),
|
|
3822
3848
|
engine: {
|
|
@@ -3825,6 +3851,20 @@ const READ_BUDGETS = [
|
|
|
3825
3851
|
},
|
|
3826
3852
|
check: (build) => expect(build).toBeNull()
|
|
3827
3853
|
}),
|
|
3854
|
+
budget({
|
|
3855
|
+
api: "sandbox build on any channel: byScope descending, limit 1",
|
|
3856
|
+
read: ({ core }) => core.findNativeBuild({
|
|
3857
|
+
...nativeBuildScope,
|
|
3858
|
+
channel: "pr-140",
|
|
3859
|
+
sandbox: nativeBuildSandboxScope
|
|
3860
|
+
}),
|
|
3861
|
+
adapter: reads(0, 0, 1, 0),
|
|
3862
|
+
engine: {
|
|
3863
|
+
calls: 1,
|
|
3864
|
+
rows: 0
|
|
3865
|
+
},
|
|
3866
|
+
check: (build) => expect(build).toBeNull()
|
|
3867
|
+
}),
|
|
3828
3868
|
budget({
|
|
3829
3869
|
api: "native build by key: byBuildKey descending, limit 1",
|
|
3830
3870
|
read: ({ core }) => core.findNativeBuild(nativeBuildScope, { buildKey: nativeBuildKey }),
|
|
@@ -4285,6 +4325,16 @@ const READ_BUDGETS = [
|
|
|
4285
4325
|
writes: 1,
|
|
4286
4326
|
check: (device) => expect(device?.udid).toBe(BUDGET_PENDING_UDID)
|
|
4287
4327
|
}),
|
|
4328
|
+
budget({
|
|
4329
|
+
api: "iOS device account read, no claim yet: its row, then the rows that name one",
|
|
4330
|
+
read: ({ core }) => core.findIosDeviceAccount(),
|
|
4331
|
+
adapter: reads(1, 1, 1, 2),
|
|
4332
|
+
engine: {
|
|
4333
|
+
calls: 2,
|
|
4334
|
+
rows: 2
|
|
4335
|
+
},
|
|
4336
|
+
check: (account) => expect(account).toEqual({ issuerId: "issuer-a" })
|
|
4337
|
+
}),
|
|
4288
4338
|
budget({
|
|
4289
4339
|
api: "iOS device account, first claim: its one row's read, the registry's rows once, and 1 write",
|
|
4290
4340
|
read: ({ core }) => core.claimIosDeviceAccount("issuer-a"),
|
|
@@ -4299,6 +4349,16 @@ const READ_BUDGETS = [
|
|
|
4299
4349
|
claimed: true
|
|
4300
4350
|
})
|
|
4301
4351
|
}),
|
|
4352
|
+
budget({
|
|
4353
|
+
api: "iOS device account read, claimed: its one row's read",
|
|
4354
|
+
read: ({ core }) => core.findIosDeviceAccount(),
|
|
4355
|
+
adapter: reads(1, 1, 0, 0),
|
|
4356
|
+
engine: {
|
|
4357
|
+
calls: 1,
|
|
4358
|
+
rows: 1
|
|
4359
|
+
},
|
|
4360
|
+
check: (account) => expect(account).toEqual({ issuerId: "issuer-a" })
|
|
4361
|
+
}),
|
|
4302
4362
|
budget({
|
|
4303
4363
|
api: "iOS device account, claimed: its one row's read",
|
|
4304
4364
|
read: ({ core }) => core.claimIosDeviceAccount("issuer-b"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/test-utils",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.41",
|
|
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.
|
|
54
|
-
"@hot-updater/
|
|
55
|
-
"@hot-updater/server": "^1.2.0-rc.
|
|
56
|
-
"@hot-updater/
|
|
53
|
+
"@hot-updater/plugin-insights": "^1.2.0-rc.41",
|
|
54
|
+
"@hot-updater/plugin-core": "^1.2.0-rc.41",
|
|
55
|
+
"@hot-updater/server": "^1.2.0-rc.41",
|
|
56
|
+
"@hot-updater/protocol": "^1.2.0-rc.41"
|
|
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.
|
|
88
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
89
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
90
|
-
"@hot-updater/server": "1.2.0-rc.
|
|
87
|
+
"@hot-updater/plugin-insights": "1.2.0-rc.41",
|
|
88
|
+
"@hot-updater/protocol": "1.2.0-rc.41",
|
|
89
|
+
"@hot-updater/plugin-core": "1.2.0-rc.41",
|
|
90
|
+
"@hot-updater/server": "1.2.0-rc.41"
|
|
91
91
|
},
|
|
92
92
|
"inlinedDependencies": {
|
|
93
93
|
"@clack/core": "1.4.3",
|