create-expo-updates-server 0.4.0 → 0.6.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.
Files changed (175) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +4 -9
  4. package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
  5. package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
  6. package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
  7. package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
  8. package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
  9. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
  10. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
  11. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
  13. package/dist/template/app/api/admin/updates/route.test.ts +21 -0
  14. package/dist/template/app/api/admin/updates/route.ts +12 -1
  15. package/dist/template/app/globals.css +65 -68
  16. package/dist/template/app/login/page.tsx +66 -42
  17. package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
  18. package/dist/template/app/updates/devices/page.tsx +188 -152
  19. package/dist/template/app/updates/embedded/page.tsx +63 -29
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +381 -283
  23. package/dist/template/app/updates/releases.test.tsx +156 -0
  24. package/dist/template/components/admin/admin-role.ts +5 -0
  25. package/dist/template/components/admin/admin-shell.tsx +166 -101
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +25 -17
  28. package/dist/template/components/admin/release-badges.test.tsx +50 -0
  29. package/dist/template/components/admin/release-badges.tsx +101 -0
  30. package/dist/template/components/ui/alert.tsx +10 -3
  31. package/dist/template/components/ui/avatar.tsx +108 -0
  32. package/dist/template/components/ui/badge.tsx +2 -2
  33. package/dist/template/components/ui/breadcrumb.tsx +108 -0
  34. package/dist/template/components/ui/button.tsx +5 -5
  35. package/dist/template/components/ui/card.tsx +2 -2
  36. package/dist/template/components/ui/chart.tsx +1 -1
  37. package/dist/template/components/ui/collapsible.tsx +7 -0
  38. package/dist/template/components/ui/empty.tsx +103 -0
  39. package/dist/template/components/ui/field.tsx +248 -0
  40. package/dist/template/components/ui/input-group.tsx +170 -0
  41. package/dist/template/components/ui/input.tsx +1 -1
  42. package/dist/template/components/ui/native-select.tsx +1 -1
  43. package/dist/template/components/ui/radio-group.tsx +41 -0
  44. package/dist/template/components/ui/status-tones.ts +15 -0
  45. package/dist/template/components/ui/table.tsx +1 -1
  46. package/dist/template/components/ui/textarea.tsx +1 -1
  47. package/dist/template/docs/admin-ui.md +7 -3
  48. package/dist/template/docs/device-targeting.md +2 -7
  49. package/dist/template/docs/doctor.md +2 -2
  50. package/dist/template/docs/expo-app-setup.md +9 -27
  51. package/dist/template/docs/getting-started.md +3 -4
  52. package/dist/template/docs/installation-telemetry.md +2 -8
  53. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  54. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  55. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  56. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  57. package/dist/template/docs/migrations/schema.sql +349 -0
  58. package/dist/template/docs/npm-installer.md +3 -3
  59. package/dist/template/docs/operations-guide.md +8 -6
  60. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  61. package/dist/template/docs/ota-update-policy.md +9 -20
  62. package/dist/template/docs/ru/admin-ui.md +7 -3
  63. package/dist/template/docs/ru/device-targeting.md +2 -2
  64. package/dist/template/docs/ru/doctor.md +2 -2
  65. package/dist/template/docs/ru/expo-app-setup.md +9 -9
  66. package/dist/template/docs/ru/getting-started.md +3 -3
  67. package/dist/template/docs/ru/installation-telemetry.md +2 -2
  68. package/dist/template/docs/ru/npm-installer.md +3 -3
  69. package/dist/template/docs/ru/operations-guide.md +8 -3
  70. package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
  71. package/dist/template/docs/ru/ota-update-policy.md +9 -7
  72. package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
  73. package/dist/template/docs/uk/admin-ui.md +7 -3
  74. package/dist/template/docs/uk/device-targeting.md +2 -2
  75. package/dist/template/docs/uk/doctor.md +2 -2
  76. package/dist/template/docs/uk/expo-app-setup.md +9 -9
  77. package/dist/template/docs/uk/getting-started.md +3 -3
  78. package/dist/template/docs/uk/installation-telemetry.md +2 -2
  79. package/dist/template/docs/uk/npm-installer.md +3 -3
  80. package/dist/template/docs/uk/operations-guide.md +8 -3
  81. package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
  82. package/dist/template/docs/uk/ota-update-policy.md +9 -7
  83. package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
  84. package/dist/template/lib/audience-ids.ts +4 -0
  85. package/dist/template/package-lock.json +46 -0
  86. package/dist/template/package.json +3 -1
  87. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  88. package/dist/template/scripts/create-access-token.mjs +1 -1
  89. package/dist/template/scripts/lib/doctor.mjs +10 -7
  90. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  91. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  92. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  93. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  94. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  95. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  96. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  97. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  98. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  99. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  100. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  101. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  102. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  103. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  104. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  105. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  106. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  107. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  108. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  109. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  110. package/dist/template/scripts/tests/e2e/release-matrix.mjs +303 -0
  111. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  112. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  113. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  114. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  115. package/dist/template/src/client/admin-api.ts +45 -10
  116. package/dist/template/src/client/admin-types.ts +35 -1
  117. package/dist/template/src/client/devices/analytics.tsx +168 -231
  118. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  119. package/dist/template/src/client/devices/device-name.tsx +37 -23
  120. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  121. package/dist/template/src/client/devices/registry.tsx +258 -245
  122. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  123. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  124. package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
  125. package/dist/template/src/client/distribution-control.tsx +89 -57
  126. package/dist/template/src/client/distribution-history.tsx +353 -0
  127. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  128. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  129. package/dist/template/src/client/guard-action-combobox.tsx +133 -239
  130. package/dist/template/src/client/guard-action-options.ts +4 -6
  131. package/dist/template/src/client/i18n/en.json +133 -2
  132. package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
  133. package/dist/template/src/client/i18n/ru.json +133 -2
  134. package/dist/template/src/client/i18n/uk.json +133 -2
  135. package/dist/template/src/client/logout-button.tsx +3 -3
  136. package/dist/template/src/client/policy-draft.ts +138 -0
  137. package/dist/template/src/client/update-audience-editor.tsx +597 -206
  138. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  139. package/dist/template/src/client/update-policy-editor.tsx +454 -320
  140. package/dist/template/src/client/use-filtered-results.ts +55 -0
  141. package/dist/template/src/server/controllers/manifest.test.ts +25 -3
  142. package/dist/template/src/server/controllers/manifest.ts +1 -2
  143. package/dist/template/src/server/devices/audience.ts +9 -5
  144. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  145. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  146. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  147. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  148. package/dist/template/src/server/lib/supabase.js +24 -0
  149. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  150. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  151. package/dist/template/src/server/lib/update-policy.ts +23 -10
  152. package/dist/template/src/server/manifest/manifest-repository.ts +2 -2
  153. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  154. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  155. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  156. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  157. package/dist/template/tsconfig.json +2 -2
  158. package/dist/template-manifest.json +445 -300
  159. package/package.json +1 -1
  160. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  161. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  162. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  163. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  164. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  165. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  166. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  167. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  168. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  169. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  170. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  171. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  172. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  173. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  174. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  175. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -0,0 +1,132 @@
1
+ import assert from "node:assert/strict";
2
+ import { randomUUID } from "node:crypto";
3
+ import { expect } from "@playwright/test";
4
+
5
+ // The signed-in page belongs to the disposable stack created by run.mjs.
6
+ export async function exerciseInstallations(page) {
7
+ const origin = new URL(page.url()).origin;
8
+ const runtime = "browser-installations";
9
+ const id = randomUUID();
10
+ for (const [installationId, channel, nativeBuild] of [
11
+ [id, "analytics-ios", "12"],
12
+ [randomUUID(), "analytics-ios", "13"],
13
+ [randomUUID(), "analytics-preview", "12"],
14
+ ]) {
15
+ const response = await page.request.post(origin + "/api/device-heartbeat", {
16
+ data: {
17
+ installationId,
18
+ eventId: randomUUID(),
19
+ sequence: 1,
20
+ observedAt: new Date().toISOString(),
21
+ platform: "ios",
22
+ channel,
23
+ runtimeVersion: runtime,
24
+ nativeVersion: "1.0",
25
+ nativeBuild,
26
+ updateId: null,
27
+ isEmbeddedLaunch: true,
28
+ isEmergencyLaunch: false,
29
+ },
30
+ });
31
+ assert.deepEqual(await response.json(), { status: "accepted" });
32
+ }
33
+
34
+ await page.goto(origin + "/updates/devices");
35
+ await expect(page.getByRole("tab", { name: "Overview" })).toHaveAttribute(
36
+ "aria-selected",
37
+ "true",
38
+ );
39
+ await page.getByRole("button", { name: "Filters", exact: true }).click();
40
+ await expect(page.getByRole("button", { name: "Apply", exact: true })).toHaveCount(0);
41
+ await page.getByLabel("Runtime", { exact: true }).selectOption(runtime);
42
+ await expect(page.locator('[aria-busy="true"]')).toHaveCount(0);
43
+ await page
44
+ .getByRole("button", { name: "Show daily values", exact: true })
45
+ .click();
46
+ const daily = page.getByRole("table", {
47
+ name: "Show daily values",
48
+ exact: true,
49
+ });
50
+ await expect(daily.getByRole("row").last().getByRole("cell")).toHaveText([
51
+ /./,
52
+ "3",
53
+ "3",
54
+ "Partial day",
55
+ ]);
56
+ await expect(daily.getByRole("row").nth(1).getByRole("cell")).toHaveText([
57
+ /./,
58
+ "—",
59
+ "—",
60
+ "No data",
61
+ ]);
62
+
63
+ await page.getByRole("tab", { name: "Versions", exact: true }).click();
64
+ const ios = page.getByRole("region", {
65
+ name: "Channel analytics-ios, ios",
66
+ exact: true,
67
+ });
68
+ const preview = page.getByRole("region", {
69
+ name: "Channel analytics-preview, ios",
70
+ exact: true,
71
+ });
72
+ await expect(ios.getByRole("img", { name: /50%/ })).toHaveCount(2);
73
+ await expect(preview.getByRole("img", { name: /100%/ })).toHaveCount(1);
74
+
75
+ await page.getByRole("tab", { name: "Cohorts", exact: true }).click();
76
+ await page.getByRole("tab", { name: "Retention" }).click();
77
+ const retention = page.getByRole("tabpanel", { name: "Retention" });
78
+ await expect(retention.getByRole("cell", { name: /100%/ })).toBeVisible();
79
+ await expect(retention.getByRole("cell", { name: /no data/i })).toHaveCount(
80
+ 4,
81
+ );
82
+
83
+ await page.getByRole("tab", { name: "Registry", exact: true }).click();
84
+ const detailsButton = page.getByRole("button", {
85
+ name: "Installation details " + id,
86
+ });
87
+ await detailsButton.click();
88
+ const sheet = page.getByRole("dialog", { name: "Installation details" });
89
+ await expect(sheet.getByText(id, { exact: true })).toBeVisible();
90
+ await page.keyboard.press("Escape");
91
+ await expect(sheet).toBeHidden();
92
+ await expect(detailsButton).toBeFocused();
93
+
94
+ await page.getByLabel("Installation ID", { exact: true }).fill(randomUUID());
95
+ await expect(
96
+ page.getByText("No installations found", { exact: true }),
97
+ ).toBeVisible();
98
+ await page.getByRole("tab", { name: "Overview" }).click();
99
+ await page
100
+ .getByRole("button", { name: "Show daily values", exact: true })
101
+ .click();
102
+ await expect(daily.getByRole("row").last().getByRole("cell")).toHaveText([
103
+ /./,
104
+ "0",
105
+ "0",
106
+ "Partial day",
107
+ ]);
108
+ await page.getByRole("button", { name: "Reset", exact: true }).click();
109
+ await expect(page.getByLabel("Runtime", { exact: true })).toHaveValue("");
110
+ await expect(page.locator('[aria-busy="true"]')).toHaveCount(0);
111
+
112
+ const viewport = page.viewportSize();
113
+ await page.setViewportSize({ width: 390, height: 844 });
114
+ await page.getByLabel("Interface language").selectOption("uk");
115
+ for (const name of ["Огляд", "Версії", "Когорти", "Реєстр"]) {
116
+ const tab = page.getByRole("tab", { name, exact: true });
117
+ await tab.click();
118
+ await expect(tab).toHaveAttribute("aria-selected", "true");
119
+ await expect
120
+ .poll(() =>
121
+ page.evaluate(
122
+ () => document.documentElement.scrollWidth - window.innerWidth,
123
+ ),
124
+ )
125
+ .toBeLessThanOrEqual(1);
126
+ }
127
+ await page.getByLabel("Мова інтерфейсу").selectOption("en");
128
+ if (viewport) await page.setViewportSize(viewport);
129
+ console.log(
130
+ "PASS browser installation filters/reset, missing vs zero vs partial coverage, scoped version shares, cohort maturity, registry focus and mobile Ukrainian tabs",
131
+ );
132
+ }
@@ -0,0 +1,253 @@
1
+ import path from "node:path";
2
+ import { mkdir } from "node:fs/promises";
3
+ import { expect } from "@playwright/test";
4
+ import { seedPublication } from "./delivery.mjs";
5
+
6
+ export async function exercisePolicyEditor(page, { db, storage, password }) {
7
+ const origin = new URL(page.url()).origin;
8
+ const draft = await seedPublication(
9
+ db,
10
+ storage,
11
+ "Policy editor fixture",
12
+ false,
13
+ "ios",
14
+ { channel: "policy-browser" },
15
+ );
16
+ const api = origin + draft.path + "/policy";
17
+ const releasePage = origin + draft.path.replace("/api/admin", "");
18
+ const orphan = "app.contract-review";
19
+ const seeded = await page.request.put(api, {
20
+ data: {
21
+ expectedPolicyVersion: 1,
22
+ delivery: "background",
23
+ guard: { action: orphan, payload: { revision: 2 } },
24
+ },
25
+ });
26
+ expect(seeded.status()).toBe(200);
27
+
28
+ await page.goto(releasePage);
29
+ await page.getByRole("tab", { name: "Policy", exact: true }).click();
30
+ const tab = page.getByRole("tabpanel", { name: "Policy", exact: true });
31
+ const radio = (name) => tab.getByRole("radio", { name, exact: true });
32
+ const save = tab.getByRole("button", { name: "Save policy", exact: true });
33
+ await expect(radio("Custom guard")).toBeChecked();
34
+ await expect(
35
+ tab.getByRole("combobox", { name: "Rule action" }),
36
+ ).toContainText(orphan);
37
+ await expect(tab.getByLabel("Delivery", { exact: true })).toContainText(
38
+ "Background",
39
+ );
40
+ await expect(save).toBeDisabled();
41
+
42
+ // The Radix group supports roving focus and preserves unsaved guard fields on a round trip.
43
+ await radio("Custom guard").focus();
44
+ await page.keyboard.down("ArrowUp");
45
+ await expect(radio("Require a store update")).toBeChecked();
46
+ await page.keyboard.up("ArrowUp");
47
+ await page.keyboard.down("ArrowDown");
48
+ await expect(radio("Custom guard")).toBeChecked();
49
+ await page.keyboard.up("ArrowDown");
50
+ await expect(save).toBeDisabled();
51
+ await expect(tab.getByLabel("Optional custom JSON payload")).toHaveValue(
52
+ /revision/,
53
+ );
54
+
55
+ await radio("Require a store update").click();
56
+ const delivery = tab.getByRole("combobox", { name: "Delivery", exact: true });
57
+ await expect(delivery).toHaveAccessibleDescription(/next full launch.*store button/i);
58
+ await delivery.click();
59
+ await page.getByRole("option", { name: "Manual", exact: true }).click();
60
+ await expect(delivery).toHaveAccessibleDescription(/when to download and restart.*block the OTA download/i);
61
+ await delivery.click();
62
+ await page.getByRole("option", { name: "Background", exact: true }).click();
63
+ await save.click();
64
+ await expect(tab.getByRole("alert")).toContainText(
65
+ "Enter a valid store link",
66
+ );
67
+ await tab
68
+ .getByLabel("iOS store link", { exact: true })
69
+ .fill("itms-apps://apps.apple.com/app/id42");
70
+ await tab
71
+ .getByLabel("Optional custom JSON payload")
72
+ .fill('{"iosUrl":"itms-apps://apps.apple.com/app/id42","legacy":["keep"]}');
73
+ await tab
74
+ .getByLabel("Default store link", { exact: true })
75
+ .fill("https://example.test/app");
76
+ await save.click();
77
+ await expect(
78
+ tab.getByRole("status").filter({ hasText: "Policy saved as version 3." }),
79
+ ).toBeVisible();
80
+ const saved = await (await page.request.get(api)).json();
81
+ expect(saved.guard).toEqual({
82
+ action: "ota-force-store-update",
83
+ payload: {
84
+ iosUrl: "itms-apps://apps.apple.com/app/id42",
85
+ legacy: ["keep"],
86
+ url: "https://example.test/app",
87
+ },
88
+ });
89
+ expect(saved.delivery).toBe("background");
90
+
91
+ const initialViewport = page.viewportSize();
92
+ const artifacts = process.env.OTA_E2E_ARTIFACTS;
93
+ if (artifacts) await mkdir(artifacts, { recursive: true });
94
+ for (const width of [1280, 390]) {
95
+ await page.setViewportSize({ width, height: 900 });
96
+ await expect
97
+ .poll(() =>
98
+ page.evaluate(
99
+ () => document.documentElement.scrollWidth - window.innerWidth,
100
+ ),
101
+ )
102
+ .toBeLessThanOrEqual(1);
103
+ if (artifacts)
104
+ await tab.screenshot({
105
+ path: path.join(artifacts, `policy-store-${width}.png`),
106
+ style: "nextjs-portal { display:none; }",
107
+ });
108
+ }
109
+ if (initialViewport) await page.setViewportSize(initialViewport);
110
+
111
+ await radio("Custom guard").click();
112
+ await tab.getByRole("button", { name: "New action", exact: true }).click();
113
+ await page.keyboard.press("Escape");
114
+ await expect(
115
+ tab.getByRole("button", { name: "New action", exact: true }),
116
+ ).toBeFocused();
117
+ await page.keyboard.press("Enter");
118
+ await tab
119
+ .getByRole("textbox", { name: "Reusable action name" })
120
+ .fill("app.verify-session");
121
+ await page.keyboard.press("Enter");
122
+ await expect(
123
+ tab.getByRole("combobox", { name: "Rule action" }),
124
+ ).toContainText("app.verify-session");
125
+ await tab.getByLabel("Optional custom JSON payload").fill("{");
126
+ await save.click();
127
+ await expect(tab.getByRole("alert")).toContainText(
128
+ "Guard payload must be valid JSON.",
129
+ );
130
+ await tab
131
+ .getByRole("button", { name: "Discard changes", exact: true })
132
+ .click();
133
+ await expect(radio("Require a store update")).toBeChecked();
134
+ await expect(save).toBeDisabled();
135
+
136
+ await radio("Required OTA update").click();
137
+ await save.click();
138
+ await expect(
139
+ tab.getByRole("status").filter({ hasText: "Policy saved as version 4." }),
140
+ ).toBeVisible();
141
+ expect((await (await page.request.get(api)).json()).guard).toEqual({
142
+ action: "ota-force-update",
143
+ });
144
+ const manualRequired = await (await page.request.get(api)).json();
145
+ expect(manualRequired.delivery).toBe("manual");
146
+ await radio("Immediate required update").click();
147
+ await save.click();
148
+ await expect(
149
+ tab.getByRole("status").filter({ hasText: "Policy saved as version 5." }),
150
+ ).toBeVisible();
151
+ const immediate = await (await page.request.get(api)).json();
152
+ expect(immediate.delivery).toBe("background");
153
+ expect(immediate.guard).toEqual({ action: "ota-force-update" });
154
+ await page.reload();
155
+ await page.getByRole("tab", { name: "Policy", exact: true }).click();
156
+ await expect(radio("Immediate required update")).toBeChecked();
157
+ await radio("Background update").click();
158
+ await save.click();
159
+ await expect(
160
+ tab.getByRole("status").filter({ hasText: "Policy saved as version 6." }),
161
+ ).toBeVisible();
162
+ expect((await (await page.request.get(api)).json()).guard).toBeNull();
163
+ await radio("Optional update").click();
164
+ await save.click();
165
+ await expect(
166
+ tab.getByRole("status").filter({ hasText: "Policy saved as version 7." }),
167
+ ).toBeVisible();
168
+
169
+ await radio("Download on postpone").click();
170
+ await save.click();
171
+ await expect(tab.getByRole("status")).toContainText("Policy saved as version 8.");
172
+ await page.reload();
173
+ await page.getByRole("tab", { name: "Policy", exact: true }).click();
174
+ await expect(radio("Download on postpone")).toBeChecked();
175
+ expect((await (await page.request.get(api)).json()).delivery).toBe("manual-postpone");
176
+
177
+ const catalogKey = "app.catalog-demo";
178
+ await tab
179
+ .getByRole("button", { name: "Action catalog", exact: true })
180
+ .click();
181
+ await tab
182
+ .getByRole("textbox", { name: "Add action to catalog" })
183
+ .fill(catalogKey);
184
+ await tab
185
+ .getByRole("button", { name: "Add to catalog", exact: true })
186
+ .click();
187
+ await tab
188
+ .getByRole("searchbox", { name: "Search action catalog" })
189
+ .fill(catalogKey);
190
+ const catalog = tab.getByRole("list", {
191
+ name: "Guard action catalog entries",
192
+ });
193
+ await expect(catalog.getByRole("listitem")).toHaveCount(1);
194
+ await catalog
195
+ .getByRole("button", { name: `Delete ${catalogKey} from action catalog` })
196
+ .click();
197
+ await page
198
+ .getByRole("dialog")
199
+ .getByRole("button", { name: "Delete from catalog" })
200
+ .click();
201
+ await expect(
202
+ tab.getByText("No matching actions", { exact: true }),
203
+ ).toBeVisible();
204
+ await expect(save).toBeDisabled();
205
+ expect((await (await page.request.get(api)).json()).policyVersion).toBe(8);
206
+
207
+ const viewer = await page.context().browser().newContext();
208
+ try {
209
+ expect(
210
+ (
211
+ await viewer.request.post(origin + "/api/admin/login", {
212
+ data: { username: "viewer", password },
213
+ })
214
+ ).status(),
215
+ ).toBe(200);
216
+ const screen = await viewer.newPage();
217
+ await screen.goto(releasePage);
218
+ await screen.getByRole("tab", { name: "Policy", exact: true }).click();
219
+ const policy = screen.getByRole("tabpanel", {
220
+ name: "Policy",
221
+ exact: true,
222
+ });
223
+ await expect(policy.getByRole("radio").first()).toBeDisabled();
224
+ await expect(
225
+ policy.getByRole("button", { name: "Save policy" }),
226
+ ).toHaveCount(0);
227
+ await policy
228
+ .getByRole("button", { name: "Action catalog", exact: true })
229
+ .click();
230
+ await expect(
231
+ policy.getByRole("button", { name: "Add to catalog" }),
232
+ ).toHaveCount(0);
233
+ } finally {
234
+ await viewer.close();
235
+ }
236
+ expect(
237
+ (
238
+ await page.request.post(origin + draft.path + "/deactivate", {
239
+ data: { disabled: false },
240
+ })
241
+ ).status(),
242
+ ).toBe(200);
243
+ await page.reload();
244
+ await page.getByRole("tab", { name: "Policy", exact: true }).click();
245
+ await expect(
246
+ tab.getByText("Published policies are read-only.", { exact: false }),
247
+ ).toBeVisible();
248
+ await expect(radio("Optional update")).toBeDisabled();
249
+ await expect(save).toHaveCount(0);
250
+ console.log(
251
+ "PASS policy profiles, keyboard selection, legacy payload preservation, save/discard, catalog, mobile layout and role locks",
252
+ );
253
+ }
@@ -0,0 +1,59 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawn } from "node:child_process";
3
+ import { once } from "node:events";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ // Exercise the interactive CLI used before registering embedded builds in CI.
7
+ export async function checkRegistrarToken(origin, DATABASE_URL, cwd) {
8
+ const cli = fileURLToPath(
9
+ new URL("../../create-access-token.mjs", import.meta.url),
10
+ );
11
+ const child = spawn(process.execPath, [cli], {
12
+ cwd,
13
+ env: {
14
+ PATH: process.env.PATH,
15
+ DATABASE_PROVIDER: "pg",
16
+ DATABASE_URL,
17
+ },
18
+ });
19
+ let output = "";
20
+ const answers = [
21
+ ["Token name [mobile-builds]: ", "registration-ci"],
22
+ ["Scopes [updates:write]: ", "updates:write"],
23
+ ["Expiration as ISO date, or leave empty for no expiration: ", ""],
24
+ ];
25
+ child.stdout.on("data", (chunk) => {
26
+ output += chunk;
27
+ if (answers.length && output.includes(answers[0][0])) {
28
+ child.stdin.write(answers.shift()[1] + "\n");
29
+ }
30
+ });
31
+ const timer = setTimeout(() => child.kill(), 15000);
32
+ try {
33
+ const [code] = await once(child, "exit");
34
+ assert.equal(code, 0, "Create a registration token in PostgreSQL");
35
+ const token = output.match(/\bota_[\w-]+\b/)?.[0];
36
+ assert.ok(token);
37
+ const response = await fetch(origin + "/api/admin/updates", {
38
+ headers: { authorization: "Bearer " + token },
39
+ });
40
+ assert.equal(response.status, 403, "Write-only token does not grant reads");
41
+ const registered = await fetch(origin + "/api/admin/embedded-updates", {
42
+ method: "POST",
43
+ headers: {
44
+ authorization: "Bearer " + token,
45
+ "content-type": "application/json",
46
+ },
47
+ body: JSON.stringify({
48
+ embeddedUpdateId: crypto.randomUUID(),
49
+ appVersion: "1.0",
50
+ channel: "internal-ci",
51
+ platform: "android",
52
+ createdAt: new Date().toISOString(),
53
+ }),
54
+ });
55
+ assert.equal(registered.status, 201);
56
+ } finally {
57
+ clearTimeout(timer);
58
+ }
59
+ }