create-expo-updates-server 0.3.0 → 0.6.0
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/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +5 -10
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +382 -248
- package/dist/template/app/updates/devices/page.tsx +187 -145
- package/dist/template/app/updates/embedded/page.tsx +80 -34
- package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +385 -274
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -95
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +27 -16
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/dialog.tsx +13 -4
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/sheet.tsx +6 -2
- package/dist/template/components/ui/sidebar.tsx +62 -17
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +22 -24
- package/dist/template/docs/device-targeting.md +6 -12
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/getting-started.ru.md +11 -544
- package/dist/template/docs/index.md +1 -1
- package/dist/template/docs/installation-telemetry.md +6 -12
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +9 -7
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-emergency-recovery.md +34 -57
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +33 -0
- package/dist/template/docs/ru/device-targeting.md +59 -0
- package/dist/template/docs/ru/doctor.md +98 -0
- package/dist/template/docs/ru/expo-app-setup.md +497 -0
- package/dist/template/docs/ru/getting-started.md +391 -0
- package/dist/template/docs/ru/index.md +50 -0
- package/dist/template/docs/ru/installation-telemetry.md +125 -0
- package/dist/template/docs/ru/npm-installer.md +71 -0
- package/dist/template/docs/ru/operations-guide.md +322 -0
- package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/ru/ota-update-policy.md +69 -0
- package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
- package/dist/template/docs/ru/supabase-setup.md +120 -0
- package/dist/template/docs/uk/admin-ui.md +33 -0
- package/dist/template/docs/uk/device-targeting.md +59 -0
- package/dist/template/docs/uk/doctor.md +98 -0
- package/dist/template/docs/uk/expo-app-setup.md +497 -0
- package/dist/template/docs/uk/getting-started.md +391 -0
- package/dist/template/docs/uk/index.md +50 -0
- package/dist/template/docs/uk/installation-telemetry.md +125 -0
- package/dist/template/docs/uk/npm-installer.md +71 -0
- package/dist/template/docs/uk/operations-guide.md +322 -0
- package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/uk/ota-update-policy.md +69 -0
- package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
- package/dist/template/docs/uk/supabase-setup.md +120 -0
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +4 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +169 -219
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -21
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +265 -233
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
- package/dist/template/src/client/distribution-control.tsx +98 -53
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +134 -234
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +335 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
- package/dist/template/src/client/i18n/messages.test.ts +102 -19
- package/dist/template/src/client/i18n/messages.ts +31 -16
- package/dist/template/src/client/i18n/provider.tsx +6 -3
- package/dist/template/src/client/i18n/ru.json +619 -0
- package/dist/template/src/client/i18n/uk.json +619 -0
- package/dist/template/src/client/i18n/use-formatters.ts +5 -0
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -199
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +466 -307
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +571 -271
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
"Детали обновления": "Update details",
|
|
208
208
|
"Метаданные, политика доставки и управление публикацией.": "Metadata, delivery policy and release management.",
|
|
209
209
|
"Загрузка...": "Loading...",
|
|
210
|
-
"⚠️ Rollback активен в этом канале/платформе.": "
|
|
210
|
+
"⚠️ Rollback активен в этом канале/платформе.": "Rollback is active in this channel/platform.",
|
|
211
211
|
"Сейчас раздаётся updateId: ": "Currently serving update ID: ",
|
|
212
212
|
"Новые апдейты автоматически игнорируются до выполнения Promote.": "New updates are ignored until Promote is performed.",
|
|
213
213
|
"Этот апдейт сейчас не доставляется.": "This update is not being delivered.",
|
|
@@ -282,5 +282,338 @@
|
|
|
282
282
|
"Страница ": "Page ",
|
|
283
283
|
"Вперёд": "Next",
|
|
284
284
|
"Неверные учётные данные": "Invalid credentials",
|
|
285
|
-
"Вход временно недоступен": "Login is temporarily unavailable"
|
|
285
|
+
"Вход временно недоступен": "Login is temporarily unavailable",
|
|
286
|
+
"Interface language": "Interface language",
|
|
287
|
+
"Release workspace": "Release workspace",
|
|
288
|
+
"Native:": "Native:",
|
|
289
|
+
"Runtime": "Runtime",
|
|
290
|
+
"Embedded": "Embedded",
|
|
291
|
+
"Native": "Native",
|
|
292
|
+
"Emergency": "Emergency",
|
|
293
|
+
"Runtime / native": "Runtime / native",
|
|
294
|
+
"Rule action": "Rule action",
|
|
295
|
+
"Action (required)": "Action (required)",
|
|
296
|
+
"Guard action catalog": "Guard action catalog",
|
|
297
|
+
"Delete from catalog": "Delete from catalog",
|
|
298
|
+
"No matching actions": "No matching actions",
|
|
299
|
+
"Toggle Sidebar": "Toggle Sidebar",
|
|
300
|
+
"Close": "Close",
|
|
301
|
+
"Device IDs": "Device IDs",
|
|
302
|
+
"Installation IDs": "Installation IDs",
|
|
303
|
+
"Read only · updates:write": "Read only · updates:write",
|
|
304
|
+
"· version": "· version",
|
|
305
|
+
"Update policy": "Update policy",
|
|
306
|
+
"Manual": "Manual",
|
|
307
|
+
"Background": "Background",
|
|
308
|
+
"Published policies are read-only. Publish a new update ID to change policy.": "Published policies are read-only. Publish a new update ID to change policy.",
|
|
309
|
+
"Note:": "Note:",
|
|
310
|
+
"a Guard is usually paired with Background delivery so the candidate can fetch silently. Activation is still allowed.": "a Guard is usually paired with Background delivery so the candidate can fetch silently. Activation is still allowed.",
|
|
311
|
+
"Action catalog:": "Action catalog:",
|
|
312
|
+
"Add action to catalog": "Add action to catalog",
|
|
313
|
+
"Reusable action name": "Reusable action name",
|
|
314
|
+
"Adds a reusable catalog item without changing this policy.": "Adds a reusable catalog item without changing this policy.",
|
|
315
|
+
"Action catalog": "Action catalog",
|
|
316
|
+
"Guard action catalog entries": "Guard action catalog entries",
|
|
317
|
+
"No catalog actions found.": "No catalog actions found.",
|
|
318
|
+
"Guard enabled": "Guard enabled",
|
|
319
|
+
"When enabled, this Guard applies unconditionally whenever this OTA is selected for a client.": "When enabled, this Guard applies unconditionally whenever this OTA is selected for a client.",
|
|
320
|
+
"Optional custom JSON payload": "Optional custom JSON payload",
|
|
321
|
+
"No Guard will be emitted in the update manifest.": "No Guard will be emitted in the update manifest.",
|
|
322
|
+
"Save policy": "Save policy",
|
|
323
|
+
"Installation ID": "Installation ID",
|
|
324
|
+
"Device ID": "Device ID",
|
|
325
|
+
"Stage": "Stage",
|
|
326
|
+
"Latest": "Latest",
|
|
327
|
+
"Rollback": "Rollback",
|
|
328
|
+
"Guard": "Guard",
|
|
329
|
+
"Policy": "Policy",
|
|
330
|
+
"Assets": "Assets",
|
|
331
|
+
"Update ID": "Update ID",
|
|
332
|
+
"Promote": "Promote",
|
|
333
|
+
"Created At": "Created At",
|
|
334
|
+
"App version": "App version",
|
|
335
|
+
"Embedded ID": "Embedded ID",
|
|
336
|
+
"Action": "Action",
|
|
337
|
+
"OTA Updates": "OTA Updates",
|
|
338
|
+
"Rollback lock:": "Rollback lock:",
|
|
339
|
+
"Runtime / App": "Runtime / App",
|
|
340
|
+
"App": "App",
|
|
341
|
+
"Runtime version": "Runtime version",
|
|
342
|
+
"Embedded update ID": "Embedded update ID",
|
|
343
|
+
"From channel": "From channel",
|
|
344
|
+
"To channel": "To channel",
|
|
345
|
+
"Target mode": "Target mode",
|
|
346
|
+
"Pinned update": "Pinned update",
|
|
347
|
+
"Follow channel": "Follow channel",
|
|
348
|
+
"Scope": "Scope",
|
|
349
|
+
"Redirect": "Redirect",
|
|
350
|
+
"Target": "Target",
|
|
351
|
+
"Actions": "Actions",
|
|
352
|
+
"Edit": "Edit",
|
|
353
|
+
"Read only": "Read only",
|
|
354
|
+
"Expected update ID": "Expected update ID",
|
|
355
|
+
"Expected update ID (optional)": "Expected update ID (optional)",
|
|
356
|
+
"Enabled": "Enabled",
|
|
357
|
+
"Disabled": "Disabled",
|
|
358
|
+
"Disable": "Disable",
|
|
359
|
+
"Enable": "Enable",
|
|
360
|
+
"Adding…": "Adding…",
|
|
361
|
+
"Add to catalog": "Add to catalog",
|
|
362
|
+
"Ignored by rollback": "Ignored by rollback",
|
|
363
|
+
"Scope open": "Scope open",
|
|
364
|
+
"None": "None",
|
|
365
|
+
"draft": "draft",
|
|
366
|
+
"published": "published",
|
|
367
|
+
"active": "active",
|
|
368
|
+
"inactive": "inactive",
|
|
369
|
+
"disabled": "disabled",
|
|
370
|
+
"admin": "admin",
|
|
371
|
+
"operator": "operator",
|
|
372
|
+
"viewer": "viewer",
|
|
373
|
+
"Native version / build": "Native version / build",
|
|
374
|
+
"OTA artifact ID": "OTA artifact ID",
|
|
375
|
+
"Launch update ID": "Launch update ID",
|
|
376
|
+
"Runtime {0}": "Runtime {0}",
|
|
377
|
+
"Loading update policy…": "Loading update policy…",
|
|
378
|
+
"Delete \"{0}\" from the action catalog? Existing policies are unaffected.": "Delete \"{0}\" from the action catalog? Existing policies are unaffected.",
|
|
379
|
+
"Policy saved as version {0}.": "Policy saved as version {0}.",
|
|
380
|
+
" · published {0}": " · published {0}",
|
|
381
|
+
" · draft": " · draft",
|
|
382
|
+
"Delete {0} from action catalog": "Delete {0} from action catalog",
|
|
383
|
+
"Create “{0}”": "Create “{0}”",
|
|
384
|
+
"Failed to load action catalog": "Failed to load action catalog",
|
|
385
|
+
"Failed to load policy": "Failed to load policy",
|
|
386
|
+
"Action remains selected but was not saved to the catalog.": "Action remains selected but was not saved to the catalog.",
|
|
387
|
+
"Failed to add action to the catalog.": "Failed to add action to the catalog.",
|
|
388
|
+
"Failed to delete action from catalog": "Failed to delete action from catalog",
|
|
389
|
+
"Select or create a Guard action.": "Select or create a Guard action.",
|
|
390
|
+
"Guard payload must be valid JSON.": "Guard payload must be valid JSON.",
|
|
391
|
+
"Failed to save policy": "Failed to save policy",
|
|
392
|
+
"Action must contain between 1 and 100 characters.": "Action must contain between 1 and 100 characters.",
|
|
393
|
+
"Action must not contain control characters.": "Action must not contain control characters.",
|
|
394
|
+
"Rules: {0}": "Rules: {0}",
|
|
395
|
+
"Builds: {0}": "Builds: {0}",
|
|
396
|
+
"Ascending": "Ascending",
|
|
397
|
+
"Descending": "Descending",
|
|
398
|
+
"Unauthorized": "Unauthorized",
|
|
399
|
+
"Forbidden": "Forbidden",
|
|
400
|
+
"Invalid filters": "Invalid filters",
|
|
401
|
+
"Device report unavailable": "Device report unavailable",
|
|
402
|
+
"Invalid platform": "Invalid platform",
|
|
403
|
+
"Invalid device ID": "Invalid device ID",
|
|
404
|
+
"Device name unavailable": "Device name unavailable",
|
|
405
|
+
"Devices unavailable": "Devices unavailable",
|
|
406
|
+
"Invalid device name": "Invalid device name",
|
|
407
|
+
"Failed to name device": "Failed to name device",
|
|
408
|
+
"Invalid JSON request body": "Invalid JSON request body",
|
|
409
|
+
"Invalid JSON request body.": "Invalid JSON request body.",
|
|
410
|
+
"Invalid request body": "Invalid request body",
|
|
411
|
+
"Request body must be a JSON object.": "Request body must be a JSON object.",
|
|
412
|
+
"Failed to list emergency redirects": "Failed to list emergency redirects",
|
|
413
|
+
"Failed to create emergency redirect": "Failed to create emergency redirect",
|
|
414
|
+
"Failed to update emergency redirect": "Failed to update emergency redirect",
|
|
415
|
+
"Failed to delete emergency redirect": "Failed to delete emergency redirect",
|
|
416
|
+
"Failed to read OTA distribution control.": "Failed to read OTA distribution control.",
|
|
417
|
+
"Failed to update OTA distribution control.": "Failed to update OTA distribution control.",
|
|
418
|
+
"Failed to list guard actions": "Failed to list guard actions",
|
|
419
|
+
"Failed to create guard action": "Failed to create guard action",
|
|
420
|
+
"Failed to delete guard action": "Failed to delete guard action",
|
|
421
|
+
"Audience unavailable": "Audience unavailable",
|
|
422
|
+
"Update not found": "Update not found",
|
|
423
|
+
"Failed to fetch updates": "Failed to fetch updates",
|
|
424
|
+
"Failed to fetch update": "Failed to fetch update",
|
|
425
|
+
"Failed to fetch embedded updates": "Failed to fetch embedded updates",
|
|
426
|
+
"Failed to delete embedded update": "Failed to delete embedded update",
|
|
427
|
+
"Failed to fetch update policy": "Failed to fetch update policy",
|
|
428
|
+
"Failed to update policy": "Failed to update policy",
|
|
429
|
+
"Failed to promote latest update": "Failed to promote latest update",
|
|
430
|
+
"Failed to deactivate update": "Failed to deactivate update",
|
|
431
|
+
"Failed to delete update": "Failed to delete update",
|
|
432
|
+
"Failed to update JSON": "Failed to update JSON",
|
|
433
|
+
"Failed to rollback update": "Failed to rollback update",
|
|
434
|
+
"Failed to fetch": "Failed to fetch",
|
|
435
|
+
"Load failed": "Load failed",
|
|
436
|
+
"Emergency redirect must be a JSON object": "Emergency redirect must be a JSON object",
|
|
437
|
+
"Patch must be a JSON object": "Patch must be a JSON object",
|
|
438
|
+
"name must be a non-empty string": "name must be a non-empty string",
|
|
439
|
+
"embeddedUpdateId must be a non-empty string": "embeddedUpdateId must be a non-empty string",
|
|
440
|
+
"runtimeVersion must be a non-empty string": "runtimeVersion must be a non-empty string",
|
|
441
|
+
"fromChannel must be a non-empty string": "fromChannel must be a non-empty string",
|
|
442
|
+
"toChannel must be a non-empty string": "toChannel must be a non-empty string",
|
|
443
|
+
"name must contain at most 120 characters": "name must contain at most 120 characters",
|
|
444
|
+
"embeddedUpdateId must be a UUID": "embeddedUpdateId must be a UUID",
|
|
445
|
+
"platform must be android or ios": "platform must be android or ios",
|
|
446
|
+
"fromChannel and toChannel must differ": "fromChannel and toChannel must differ",
|
|
447
|
+
"targetMode must be pinned or follow": "targetMode must be pinned or follow",
|
|
448
|
+
"enabled must be boolean": "enabled must be boolean",
|
|
449
|
+
"expectedUpdateId is required in pinned mode": "expectedUpdateId is required in pinned mode",
|
|
450
|
+
"expectedUpdateId must be a UUID": "expectedUpdateId must be a UUID",
|
|
451
|
+
"Invalid audience": "Invalid audience",
|
|
452
|
+
"Invalid target IDs (maximum 100 per type)": "Invalid target IDs (maximum 100 per type)",
|
|
453
|
+
"Invalid audience mode or version": "Invalid audience mode or version",
|
|
454
|
+
"Select at least one device or installation": "Select at least one device or installation",
|
|
455
|
+
"Audience changed or distribution blocked. Refresh and try again.": "Audience changed or distribution blocked. Refresh and try again.",
|
|
456
|
+
"Failed to save audience": "Failed to save audience",
|
|
457
|
+
"Guard action must be a JSON object": "Guard action must be a JSON object",
|
|
458
|
+
"actionKey must be a string": "actionKey must be a string",
|
|
459
|
+
"actionKey must contain between 1 and 100 characters": "actionKey must contain between 1 and 100 characters",
|
|
460
|
+
"actionKey must not contain control characters": "actionKey must not contain control characters",
|
|
461
|
+
"id must be a UUID": "id must be a UUID",
|
|
462
|
+
"expectedPolicyVersion must be a positive integer.": "expectedPolicyVersion must be a positive integer.",
|
|
463
|
+
"Update policy is immutable after publication.": "Update policy is immutable after publication.",
|
|
464
|
+
"reason is required when OTA distribution is blocked.": "reason is required when OTA distribution is blocked.",
|
|
465
|
+
"reason must contain at most 500 characters and no control characters.": "reason must contain at most 500 characters and no control characters.",
|
|
466
|
+
"content must be a JSON object": "content must be a JSON object",
|
|
467
|
+
"Cannot promote: latest update is not set for this scope.": "Cannot promote: latest update is not set for this scope.",
|
|
468
|
+
"Promote is allowed only on the latest update.": "Promote is allowed only on the latest update.",
|
|
469
|
+
"Promote is not available because rollback is not active.": "Promote is not available because rollback is not active.",
|
|
470
|
+
"Rollback is not available: no active update is currently served for this scope.": "Rollback is not available: no active update is currently served for this scope.",
|
|
471
|
+
"Rollback is not available for the currently served update.": "Rollback is not available for the currently served update.",
|
|
472
|
+
"Rollback is not available: currently served update is not active.": "Rollback is not available: currently served update is not active.",
|
|
473
|
+
"Rollback is allowed only when a newer active update exists in the same scope.": "Rollback is allowed only when a newer active update exists in the same scope.",
|
|
474
|
+
"Direct activation is allowed only for the newest update in scope. Use Rollback for older updates.": "Direct activation is allowed only for the newest update in scope. Use Rollback for older updates.",
|
|
475
|
+
"Direct activation is unavailable while rollback mode is active. Use Promote on the newest update.": "Direct activation is unavailable while rollback mode is active. Use Promote on the newest update.",
|
|
476
|
+
"Version {0}": "Version {0}",
|
|
477
|
+
" · version {0}": " · version {0}",
|
|
478
|
+
"policy.delivery: must be manual or background": "policy.delivery: must be manual or background",
|
|
479
|
+
"policy.guard.action: must be a string": "policy.guard.action: must be a string",
|
|
480
|
+
"policy.guard.payload: must be absent when action is empty": "policy.guard.payload: must be absent when action is empty",
|
|
481
|
+
"policy.guard.action: must contain at most 100 characters": "policy.guard.action: must contain at most 100 characters",
|
|
482
|
+
"policy.guard.payload: must be JSON-serializable": "policy.guard.payload: must be JSON-serializable",
|
|
483
|
+
"Distribution control version conflict. Refresh and try again.": "Distribution control version conflict. Refresh and try again.",
|
|
484
|
+
"OTA distribution is globally blocked. Disable the emergency switch before starting distribution.": "OTA distribution is globally blocked. Disable the emergency switch before starting distribution.",
|
|
485
|
+
"policy.guard.action: must be trimmed, contain 1-100 characters, and have no control characters": "policy.guard.action: must be trimmed, contain 1-100 characters, and have no control characters",
|
|
486
|
+
"policy.guard.payload: must not exceed 16384 UTF-8 bytes": "policy.guard.payload: must not exceed 16384 UTF-8 bytes",
|
|
487
|
+
"policy.guard.payload: JSON depth must not exceed 10": "policy.guard.payload: JSON depth must not exceed 10",
|
|
488
|
+
"Analytics": "Analytics",
|
|
489
|
+
"Overview": "Overview",
|
|
490
|
+
"Versions": "Versions",
|
|
491
|
+
"Cohorts": "Cohorts",
|
|
492
|
+
"Registry": "Registry",
|
|
493
|
+
"New installations": "New installations",
|
|
494
|
+
"First seen during this period": "First seen during this period",
|
|
495
|
+
"Reported versions": "Reported versions",
|
|
496
|
+
"Distinct version combinations": "Distinct version combinations",
|
|
497
|
+
"{0} filters applied": "{0} filters applied",
|
|
498
|
+
"Versions and activity reported by app installations.": "Versions and activity reported by app installations.",
|
|
499
|
+
"Shares across all installations in the selected period.": "Shares across all installations in the selected period.",
|
|
500
|
+
"Search embedded builds": "Search builds by ID, version, platform or channel",
|
|
501
|
+
"Matching build": "Matching build",
|
|
502
|
+
"Destination release": "Destination release",
|
|
503
|
+
"Manage release audiences, delivery policies and rollbacks.": "Manage release audiences, delivery policies and rollbacks.",
|
|
504
|
+
"Release history": "Release history",
|
|
505
|
+
"Search releases": "Search releases",
|
|
506
|
+
"Search by comment, update ID, version or channel": "Search by comment, update ID, version or channel",
|
|
507
|
+
"All runtimes": "All runtimes",
|
|
508
|
+
"All statuses": "All statuses",
|
|
509
|
+
"All audiences": "All audiences",
|
|
510
|
+
"Showing the previous results.": "Showing the previous results.",
|
|
511
|
+
"Release": "Release",
|
|
512
|
+
"Compatibility": "Compatibility",
|
|
513
|
+
"Audience": "Audience",
|
|
514
|
+
"No matching releases": "No matching releases",
|
|
515
|
+
"Release {0}": "Release {0}",
|
|
516
|
+
"All devices": "All devices",
|
|
517
|
+
"Page {0} of {1}": "Page {0} of {1}",
|
|
518
|
+
"Release sections": "Release sections",
|
|
519
|
+
"Metadata": "Metadata",
|
|
520
|
+
"My favorites": "My favorites",
|
|
521
|
+
"Bookmark a recipient below to reuse it across releases.": "Bookmark a recipient below to reuse it across releases.",
|
|
522
|
+
"Target is no longer in the registry": "Target is no longer in the registry",
|
|
523
|
+
"{0} is selected": "{0} is selected",
|
|
524
|
+
"Add {0} to audience": "Add {0} to audience",
|
|
525
|
+
"Remove {0} from favorites": "Remove {0} from favorites",
|
|
526
|
+
"Bookmark {0}": "Bookmark {0}",
|
|
527
|
+
"Selected": "Selected",
|
|
528
|
+
"Add": "Add",
|
|
529
|
+
"Save favorite": "Save favorite",
|
|
530
|
+
"Only your account sees this name.": "Only your account sees this name.",
|
|
531
|
+
"Bookmark target": "Bookmark target",
|
|
532
|
+
"Favorite name": "Favorite name",
|
|
533
|
+
"Favorites unavailable": "Favorites unavailable",
|
|
534
|
+
"Invalid favorite name": "Invalid favorite name",
|
|
535
|
+
"Invalid favorite target": "Invalid favorite target",
|
|
536
|
+
"Could not remove favorite": "Could not remove favorite",
|
|
537
|
+
"Could not save favorite": "Could not save favorite",
|
|
538
|
+
"Optional update": "Optional update",
|
|
539
|
+
"Users can download the update, restart to apply it, or continue with their current version.": "Users can download the update, restart to apply it, or continue with their current version.",
|
|
540
|
+
"Background update": "Background update",
|
|
541
|
+
"The app downloads the update silently and applies it on the next launch.": "The app downloads the update silently and applies it on the next launch.",
|
|
542
|
+
"Required OTA update": "Required OTA update",
|
|
543
|
+
"The app blocks access and downloads this update. Users restart to continue.": "The app blocks access and downloads this update. Users restart to continue.",
|
|
544
|
+
"Require a store update": "Require a store update",
|
|
545
|
+
"The app blocks access and opens the configured store link when the user chooses to upgrade.": "The app blocks access and opens the configured store link when the user chooses to upgrade.",
|
|
546
|
+
"Custom guard": "Custom guard",
|
|
547
|
+
"The app runs the selected action. Access stays blocked unless the app’s handler allows it.": "The app runs the selected action. Access stays blocked unless the app’s handler allows it.",
|
|
548
|
+
"Choose how this release reaches users.": "Choose how this release reaches users.",
|
|
549
|
+
"Your role has read-only access to this policy.": "Your role has read-only access to this policy.",
|
|
550
|
+
"Update behavior": "Update behavior",
|
|
551
|
+
"Default store link": "Default store link",
|
|
552
|
+
"iOS store link": "iOS store link",
|
|
553
|
+
"Android store link": "Android store link",
|
|
554
|
+
"The app uses its platform link first, then the default link. Use https, market or itms-apps links.": "The app uses its platform link first, then the default link. Use https, market or itms-apps links.",
|
|
555
|
+
"Edit the existing store payload in advanced settings to preserve its structure.": "Edit the existing store payload in advanced settings to preserve its structure.",
|
|
556
|
+
"Advanced settings": "Advanced settings",
|
|
557
|
+
"When OTA is allowed, the default client lets the user choose when to download and restart. They can postpone the update.": "When OTA is allowed, the default client lets the user choose when to download and restart. They can postpone the update.",
|
|
558
|
+
"When OTA is allowed, the app downloads it silently during use. It takes effect on the next full launch. For an automatic restart, select Immediate required update.": "When OTA is allowed, the app downloads it silently during use. It takes effect on the next full launch. For an automatic restart, select Immediate required update.",
|
|
559
|
+
"This release requires an update from the store. Both delivery modes show the store button and block the OTA download.": "This release requires an update from the store. Both delivery modes show the store button and block the OTA download.",
|
|
560
|
+
"Delivery starts only after the app’s custom action allows the update.": "Delivery starts only after the app’s custom action allows the update.",
|
|
561
|
+
"Unsaved changes": "Unsaved changes",
|
|
562
|
+
"Discard changes": "Discard changes",
|
|
563
|
+
"Select an action": "Select an action",
|
|
564
|
+
"New action": "New action",
|
|
565
|
+
"Use action": "Use action",
|
|
566
|
+
"Choose the corresponding built-in behavior for this action.": "Choose the corresponding built-in behavior for this action.",
|
|
567
|
+
"Enter a valid store link for this platform or a default store link.": "Enter a valid store link for this platform or a default store link.",
|
|
568
|
+
"Reload saved policy": "Reload saved policy",
|
|
569
|
+
"Search action catalog": "Search action catalog",
|
|
570
|
+
"Activated at": "Activated at",
|
|
571
|
+
"Public delivery": "Public delivery",
|
|
572
|
+
"Current and previous releases served to all devices in each scope.": "Current and previous releases served to all devices in each scope.",
|
|
573
|
+
"Find a delivery scope": "Find a delivery scope",
|
|
574
|
+
"No matching scopes": "No matching scopes",
|
|
575
|
+
"No public release history yet": "No public release history yet",
|
|
576
|
+
"Try another runtime, channel or platform.": "Try another runtime, channel or platform.",
|
|
577
|
+
"Manually activate a release for all devices to start its history.": "Manually activate a release for all devices to start its history.",
|
|
578
|
+
"Delivery scope": "Delivery scope",
|
|
579
|
+
"Currently serving": "Currently serving",
|
|
580
|
+
"Previous public release": "Previous public release",
|
|
581
|
+
"No active release": "No active release",
|
|
582
|
+
"No previous release": "No previous release",
|
|
583
|
+
"Restore": "Restore",
|
|
584
|
+
"Restore release": "Restore release",
|
|
585
|
+
"Resume public delivery of {0} in {1}?": "Resume public delivery of {0} in {1}?",
|
|
586
|
+
"Restored {0} in {1}.": "Restored {0} in {1}.",
|
|
587
|
+
"Delivery changed. Review the refreshed scope before restoring.": "Delivery changed. Review the refreshed scope before restoring.",
|
|
588
|
+
"Could not restore release.": "Could not restore release.",
|
|
589
|
+
"Unable to load delivery history.": "Unable to load delivery history.",
|
|
590
|
+
"Download on postpone": "Download on postpone",
|
|
591
|
+
"Offer the update first. If the user postpones it, download silently and apply it on the next full launch.": "Offer the update first. If the user postpones it, download silently and apply it on the next full launch.",
|
|
592
|
+
"Immediate required update": "Immediate required update",
|
|
593
|
+
"The app silently downloads this update and restarts as soon as it is active and ready. Users can retry if the update fails.": "The app silently downloads this update and restarts as soon as it is active and ready. Users can retry if the update fails.",
|
|
594
|
+
"Delete this release and its files from storage.": "Delete this release and its files from storage.",
|
|
595
|
+
"Who should receive this update?": "Who should receive this update?",
|
|
596
|
+
"Selected recipients": "Selected recipients",
|
|
597
|
+
"Add recipients": "Add recipients",
|
|
598
|
+
"Favorites": "Favorites",
|
|
599
|
+
"Paste IDs": "Paste IDs",
|
|
600
|
+
"No recipients match your search.": "No recipients match your search.",
|
|
601
|
+
"No installations registered for {0} yet.": "No installations registered for {0} yet.",
|
|
602
|
+
"Showing up to 50 matches from the latest 500 installations.": "Showing up to 50 matches from the latest 500 installations.",
|
|
603
|
+
"Device or installation IDs": "Device or installation IDs",
|
|
604
|
+
"Add to selection": "Add to selection",
|
|
605
|
+
"Unrecognized ID “{0}”.": "Unrecognized ID “{0}”.",
|
|
606
|
+
"Up to {0} device IDs and {0} installation IDs per audience.": "Up to {0} device IDs and {0} installation IDs per audience.",
|
|
607
|
+
"These recipients are already selected.": "These recipients are already selected.",
|
|
608
|
+
"Recipients added to the selection.": "Recipients added to the selection.",
|
|
609
|
+
"Remove {0} from selection": "Remove {0} from selection",
|
|
610
|
+
"Add at least one recipient to save this audience.": "Add at least one recipient to save this audience.",
|
|
611
|
+
"Changes apply at the next update check. Previously downloaded updates stay on the device.": "Changes apply at the next update check. Previously downloaded updates stay on the device.",
|
|
612
|
+
"Saving sets the audience. Activate the release when you are ready to distribute it.": "Saving sets the audience. Activate the release when you are ready to distribute it.",
|
|
613
|
+
"Add the entered IDs or clear the field before saving.": "Add the entered IDs or clear the field before saving.",
|
|
614
|
+
"Audience saved.": "Audience saved.",
|
|
615
|
+
"Bookmark a recipient in the registry to reuse it across releases.": "Bookmark a recipient in the registry to reuse it across releases.",
|
|
616
|
+
"Saving makes this the public release for this platform, channel and runtime, replacing any current public release.": "Saving makes this the public release for this platform, channel and runtime, replacing any current public release.",
|
|
617
|
+
"Device ID (64 hex characters) keeps targeting the device after reinstall. Installation ID (UUID) targets one installation. Separate IDs with a comma, space or new line.": "Device ID (64 hex characters) keeps targeting the device after reinstall. Installation ID (UUID) targets one installation. Separate IDs with a comma, space or new line.",
|
|
618
|
+
"{0} · Channel {1} · Runtime {2}": "{0} · Channel {1} · Runtime {2}"
|
|
286
619
|
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { AdminRoleContext } from "@/components/admin/admin-role";
|
|
7
|
+
import { LanguageSwitcher } from "@/components/admin/language-switcher";
|
|
8
|
+
import EmergencyRedirectsPage from "@/app/updates/emergency-redirects/page";
|
|
9
|
+
import UpdatePolicyEditor from "@/src/client/update-policy-editor";
|
|
10
|
+
import LoginPage from "@/app/login/page";
|
|
11
|
+
import { LocaleProvider, useI18n } from "./provider";
|
|
12
|
+
import { useFormatters } from "./use-formatters";
|
|
13
|
+
import { LOCALE_COOKIE, resolveLocale, type Locale } from "./messages";
|
|
14
|
+
|
|
15
|
+
const api = vi.hoisted(() => ({
|
|
16
|
+
getEmergencyRedirects: vi.fn(),
|
|
17
|
+
getAdminSession: vi.fn(),
|
|
18
|
+
createEmergencyRedirect: vi.fn(),
|
|
19
|
+
updateEmergencyRedirect: vi.fn(),
|
|
20
|
+
deleteEmergencyRedirect: vi.fn(),
|
|
21
|
+
getUpdatePolicy: vi.fn(),
|
|
22
|
+
getGuardActions: vi.fn(),
|
|
23
|
+
putUpdatePolicy: vi.fn(),
|
|
24
|
+
createGuardAction: vi.fn(),
|
|
25
|
+
deleteGuardAction: vi.fn(),
|
|
26
|
+
adminLogin: vi.fn(),
|
|
27
|
+
}));
|
|
28
|
+
vi.mock("@/src/client/admin-api", () => api);
|
|
29
|
+
vi.mock("next/navigation", () => ({
|
|
30
|
+
useRouter: () => ({ replace: vi.fn() }),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
let root: Root;
|
|
34
|
+
let container: HTMLDivElement;
|
|
35
|
+
const redirect = {
|
|
36
|
+
id: "rule-1",
|
|
37
|
+
name: "Мой канал / $&",
|
|
38
|
+
enabled: true,
|
|
39
|
+
embeddedUpdateId: "11111111-1111-4111-8111-111111111111",
|
|
40
|
+
runtimeVersion: "1.0.0",
|
|
41
|
+
platform: "android",
|
|
42
|
+
fromChannel: "development",
|
|
43
|
+
toChannel: "production",
|
|
44
|
+
targetMode: "pinned",
|
|
45
|
+
expectedUpdateId: "22222222-2222-4222-8222-222222222222",
|
|
46
|
+
};
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
vi.stubGlobal("ResizeObserver", class {
|
|
49
|
+
observe() {}
|
|
50
|
+
unobserve() {}
|
|
51
|
+
disconnect() {}
|
|
52
|
+
});
|
|
53
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
54
|
+
container = document.createElement("div");
|
|
55
|
+
document.body.append(container);
|
|
56
|
+
root = createRoot(container);
|
|
57
|
+
document.cookie = `${LOCALE_COOKIE}=; Path=/; Max-Age=0`;
|
|
58
|
+
api.getEmergencyRedirects.mockResolvedValue({ items: [redirect] });
|
|
59
|
+
api.getAdminSession.mockResolvedValue({ role: "admin" });
|
|
60
|
+
api.updateEmergencyRedirect.mockResolvedValue(redirect);
|
|
61
|
+
api.getUpdatePolicy.mockResolvedValue({
|
|
62
|
+
delivery: "manual",
|
|
63
|
+
guard: null,
|
|
64
|
+
policyVersion: 1,
|
|
65
|
+
editable: true,
|
|
66
|
+
publishedAt: null,
|
|
67
|
+
});
|
|
68
|
+
api.getGuardActions.mockResolvedValue({ items: [], canWrite: true });
|
|
69
|
+
vi.spyOn(window, "scrollTo").mockImplementation(() => {});
|
|
70
|
+
});
|
|
71
|
+
afterEach(async () => {
|
|
72
|
+
await act(async () => root.unmount());
|
|
73
|
+
container.remove();
|
|
74
|
+
vi.restoreAllMocks();
|
|
75
|
+
vi.clearAllMocks();
|
|
76
|
+
});
|
|
77
|
+
async function switchTo(locale: Locale) {
|
|
78
|
+
const select = container.querySelector<HTMLSelectElement>(
|
|
79
|
+
"select[aria-label]",
|
|
80
|
+
)!;
|
|
81
|
+
await act(async () => {
|
|
82
|
+
select.value = locale;
|
|
83
|
+
select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async function click(text: string) {
|
|
87
|
+
const button = [...container.querySelectorAll("button")].find(
|
|
88
|
+
(b) => b.textContent?.trim() === text,
|
|
89
|
+
);
|
|
90
|
+
expect(button, text).toBeDefined();
|
|
91
|
+
await act(async () => button!.click());
|
|
92
|
+
}
|
|
93
|
+
function Formats() {
|
|
94
|
+
const { formatLocale } = useI18n();
|
|
95
|
+
const { number, fullDate } = useFormatters();
|
|
96
|
+
return (
|
|
97
|
+
<output data-locale={formatLocale}>
|
|
98
|
+
{number(12345.6)} | {fullDate("2026-10-26T12:34:00Z")}
|
|
99
|
+
</output>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
describe("language switching", () => {
|
|
104
|
+
it("switches recovery forms, status, notices and accessibility labels without losing data", async () => {
|
|
105
|
+
await act(async () =>
|
|
106
|
+
root.render(
|
|
107
|
+
<LocaleProvider initialLocale="en">
|
|
108
|
+
<LanguageSwitcher />
|
|
109
|
+
<EmergencyRedirectsPage />
|
|
110
|
+
</LocaleProvider>,
|
|
111
|
+
),
|
|
112
|
+
);
|
|
113
|
+
expect(container.textContent).toContain("Emergency redirects");
|
|
114
|
+
await click("Edit");
|
|
115
|
+
await switchTo("ru");
|
|
116
|
+
expect(container.textContent).toContain("Исходный канал");
|
|
117
|
+
expect(container.textContent).toContain("Закреплённое обновление");
|
|
118
|
+
expect(
|
|
119
|
+
container
|
|
120
|
+
.querySelector("select[aria-label]")
|
|
121
|
+
?.getAttribute("aria-label"),
|
|
122
|
+
).toBe("Язык интерфейса");
|
|
123
|
+
expect(
|
|
124
|
+
[...container.querySelectorAll("input")].map((i) => i.value),
|
|
125
|
+
).toContain(redirect.name);
|
|
126
|
+
await click("Сохранить изменения");
|
|
127
|
+
expect(api.updateEmergencyRedirect).toHaveBeenCalledWith(
|
|
128
|
+
"rule-1",
|
|
129
|
+
expect.objectContaining({
|
|
130
|
+
name: redirect.name,
|
|
131
|
+
fromChannel: "development",
|
|
132
|
+
toChannel: "production",
|
|
133
|
+
targetMode: "pinned",
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
expect(container.textContent).toContain("Аварийный маршрут обновлён");
|
|
137
|
+
await switchTo("uk");
|
|
138
|
+
expect(container.textContent).toContain("Аварійний маршрут оновлено");
|
|
139
|
+
expect(container.querySelector("form")).toBeNull();
|
|
140
|
+
expect(container.textContent).toContain("Увімкнено");
|
|
141
|
+
expect(container.textContent).toContain(redirect.name);
|
|
142
|
+
expect(document.documentElement.lang).toBe("uk");
|
|
143
|
+
expect(document.cookie).toContain(`${LOCALE_COOKIE}=uk`);
|
|
144
|
+
expect(api.getEmergencyRedirects).toHaveBeenCalledTimes(2);
|
|
145
|
+
await switchTo("en");
|
|
146
|
+
expect(container.textContent).toContain("Emergency redirect updated");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("localizes recovery validation errors and read-only actions", async () => {
|
|
150
|
+
api.getAdminSession.mockResolvedValue({ role: "viewer" });
|
|
151
|
+
await act(async () =>
|
|
152
|
+
root.render(
|
|
153
|
+
<LocaleProvider initialLocale="uk">
|
|
154
|
+
<LanguageSwitcher />
|
|
155
|
+
<EmergencyRedirectsPage />
|
|
156
|
+
</LocaleProvider>,
|
|
157
|
+
),
|
|
158
|
+
);
|
|
159
|
+
expect(container.textContent).toContain("Лише читання");
|
|
160
|
+
expect(container.querySelector("form")).toBeNull();
|
|
161
|
+
expect(container.textContent).not.toContain("Read only");
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("renders login and formatting in the saved locale on remount and on the server", async () => {
|
|
165
|
+
await act(async () =>
|
|
166
|
+
root.render(
|
|
167
|
+
<LocaleProvider initialLocale="en">
|
|
168
|
+
<LanguageSwitcher />
|
|
169
|
+
<Formats />
|
|
170
|
+
</LocaleProvider>,
|
|
171
|
+
),
|
|
172
|
+
);
|
|
173
|
+
await switchTo("uk");
|
|
174
|
+
expect(container.querySelector("output")?.dataset.locale).toBe("uk-UA");
|
|
175
|
+
expect(container.querySelector("output")?.textContent).toContain(
|
|
176
|
+
new Intl.NumberFormat("uk-UA").format(12345.6),
|
|
177
|
+
);
|
|
178
|
+
expect(container.querySelector("output")?.textContent).toContain(
|
|
179
|
+
new Intl.DateTimeFormat("uk-UA", {
|
|
180
|
+
dateStyle: "medium",
|
|
181
|
+
timeStyle: "short",
|
|
182
|
+
timeZone: "UTC",
|
|
183
|
+
}).format(new Date("2026-10-26T12:34:00Z")),
|
|
184
|
+
);
|
|
185
|
+
const saved = resolveLocale(document.cookie.split("=")[1]);
|
|
186
|
+
await act(async () =>
|
|
187
|
+
root.render(
|
|
188
|
+
<LocaleProvider key="reload" initialLocale={saved}>
|
|
189
|
+
<LoginPage />
|
|
190
|
+
</LocaleProvider>,
|
|
191
|
+
),
|
|
192
|
+
);
|
|
193
|
+
expect(container.textContent).toContain("Увійти");
|
|
194
|
+
expect(container.querySelector("select")?.value).toBe("uk");
|
|
195
|
+
const html = renderToString(
|
|
196
|
+
<LocaleProvider initialLocale={saved}>
|
|
197
|
+
<LanguageSwitcher />
|
|
198
|
+
</LocaleProvider>,
|
|
199
|
+
);
|
|
200
|
+
expect(html).toContain('aria-label="Мова інтерфейсу"');
|
|
201
|
+
expect(html).toContain('value="uk" lang="uk" selected=""');
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("switches the policy editor, catalog, and errors in place", async () => {
|
|
205
|
+
await act(async () =>
|
|
206
|
+
root.render(
|
|
207
|
+
<LocaleProvider initialLocale="ru">
|
|
208
|
+
<LanguageSwitcher />
|
|
209
|
+
<AdminRoleContext.Provider value="operator"><UpdatePolicyEditor encodedKey="test" onSaved={async () => {}} /></AdminRoleContext.Provider>
|
|
210
|
+
</LocaleProvider>,
|
|
211
|
+
),
|
|
212
|
+
);
|
|
213
|
+
expect(container.textContent).toContain("Политика обновления");
|
|
214
|
+
expect(container.textContent).toContain("Каталог действий");
|
|
215
|
+
await click("Каталог действий");
|
|
216
|
+
await switchTo("uk");
|
|
217
|
+
expect(container.textContent).toContain("Політика оновлення");
|
|
218
|
+
expect(container.textContent).toContain("Додати дію до каталогу");
|
|
219
|
+
api.putUpdatePolicy.mockRejectedValue(
|
|
220
|
+
new Error("Update policy is immutable after publication."),
|
|
221
|
+
);
|
|
222
|
+
const background = container.querySelector<HTMLButtonElement>('#behavior-background')!;
|
|
223
|
+
await act(async () => background.click());
|
|
224
|
+
await click("Зберегти політику");
|
|
225
|
+
expect(container.textContent).toContain(
|
|
226
|
+
"Політику оновлення не можна змінити після публікації.",
|
|
227
|
+
);
|
|
228
|
+
await switchTo("ru");
|
|
229
|
+
expect(container.textContent).toContain(
|
|
230
|
+
"Политику обновления нельзя изменить после публикации.",
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
});
|