@omega.js/desktop 0.52.0 → 0.53.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 +17 -12
- package/dist/assets/css/core/_initialize.scss +1 -1
- package/dist/assets/js/core/app-shell.js +14 -15
- package/dist/assets/themes/_template/_theme.js +6 -6
- package/dist/assets/themes/base/_includes/global/sections/account.html +4 -4
- package/dist/assets/themes/base/_includes/global/sections/app-sidebar.html +5 -5
- package/dist/assets/themes/base/_layouts/frontend/pages/account/index.html +3 -3
- package/dist/assets/themes/base/_layouts/frontend/pages/alternatives/index.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/blog/tags/tag.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/payment/confirmation.html +1 -1
- package/dist/assets/themes/base/_sections/marketing/newsletter-cta/section.js +2 -3
- package/dist/assets/themes/base/_sections/verts/unit/section.html +1 -1
- package/dist/assets/themes/base/_sections/verts/unit/section.js +3 -4
- package/dist/assets/themes/base/_theme.js +4 -3
- package/dist/assets/themes/bootstrap/_theme.js +2 -2
- package/dist/assets/themes/bootstrap/overrides/_links.scss +1 -1
- package/dist/assets/themes/classy/_theme.js +8 -6
- package/dist/assets/themes/classy/css/marketing/_sections.scss +1 -2
- package/dist/assets/themes/classy/js/hero-demo-form.js +3 -2
- package/dist/assets/themes/neobrutalism/_theme.js +5 -5
- package/dist/assets/themes/neobrutalism/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/assets/themes/newsflash/_theme.js +6 -6
- package/dist/assets/themes/newsflash/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/build.js +87 -111
- package/dist/cli.js +1 -1
- package/dist/commands/build.js +2 -2
- package/dist/commands/cdp/capture.js +2 -2
- package/dist/commands/cdp/quit.js +2 -2
- package/dist/commands/cdp/relaunch.js +2 -2
- package/dist/commands/cdp/theme.js +1 -1
- package/dist/commands/clean.js +2 -2
- package/dist/commands/deploy.js +4 -4
- package/dist/commands/finalize-release.js +4 -4
- package/dist/commands/install.js +3 -3
- package/dist/commands/launch.js +2 -2
- package/dist/commands/lib/deploy-precheck.js +3 -3
- package/dist/commands/lib/ensure-target.js +6 -6
- package/dist/commands/package.js +2 -2
- package/dist/commands/publish.js +2 -2
- package/dist/commands/release.js +3 -3
- package/dist/commands/runner.js +11 -11
- package/dist/commands/sign-windows.js +5 -5
- package/dist/commands/test.js +4 -4
- package/dist/commands/update.js +2 -2
- package/dist/commands/validate-certs.js +4 -4
- package/dist/commands/version.js +3 -3
- package/dist/defaults/AGENTS.md +17 -8
- package/dist/defaults/config/omega.json5 +7 -7
- package/dist/defaults/hooks/build/post.js +1 -1
- package/dist/defaults/hooks/build/pre.js +1 -1
- package/dist/defaults/hooks/deploy/pre.js +1 -1
- package/dist/defaults/hooks/release/post.js +1 -1
- package/dist/defaults/hooks/release/pre.js +1 -1
- package/dist/defaults/src/assets/js/components/about/index.js +3 -5
- package/dist/defaults/src/assets/js/components/main/index.js +3 -5
- package/dist/defaults/src/assets/js/components/settings/index.js +3 -5
- package/dist/defaults/src/integrations/context-menu/index.js +2 -2
- package/dist/defaults/src/integrations/menu/index.js +3 -3
- package/dist/defaults/src/integrations/tray/index.js +3 -3
- package/dist/defaults/src/main.js +3 -5
- package/dist/defaults/src/preload.js +3 -5
- package/dist/defaults/test/README.md +2 -2
- package/dist/gulp/main.js +9 -10
- package/dist/gulp/tasks/audit.js +7 -7
- package/dist/gulp/tasks/build-config.js +8 -8
- package/dist/gulp/tasks/bundle.js +16 -16
- package/dist/gulp/tasks/defaults.js +3 -3
- package/dist/gulp/tasks/distribute.js +2 -2
- package/dist/gulp/tasks/html.js +9 -9
- package/dist/gulp/tasks/package-quick.js +3 -3
- package/dist/gulp/tasks/package.js +3 -3
- package/dist/gulp/tasks/release.js +3 -3
- package/dist/gulp/tasks/sass.js +6 -6
- package/dist/gulp/tasks/serve.js +4 -4
- package/dist/hooks/notarize-artifacts.js +1 -1
- package/dist/hooks/notarize.js +1 -1
- package/dist/index.js +5 -8
- package/dist/lib/_environment-mixin.js +50 -0
- package/dist/lib/_lifecycle-mixin.js +45 -0
- package/dist/lib/analytics.js +33 -35
- package/dist/lib/app-state.js +14 -14
- package/dist/lib/auth-flow.js +18 -18
- package/dist/lib/auth-persistence.js +12 -12
- package/dist/lib/auth.js +421 -0
- package/dist/lib/auto-updater.js +49 -49
- package/dist/lib/context-menu.js +13 -13
- package/dist/lib/context.js +19 -19
- package/dist/lib/deep-link.js +34 -34
- package/dist/lib/fontawesome.js +5 -5
- package/dist/lib/ipc.js +4 -4
- package/dist/lib/menu.js +25 -25
- package/dist/lib/protocol.js +5 -5
- package/dist/lib/remote-config.js +22 -22
- package/dist/lib/remote-scripts.js +21 -21
- package/dist/lib/restart-manager/index.js +28 -28
- package/dist/lib/sign-helpers/exec-with-limit.js +1 -1
- package/dist/lib/sign-helpers/sign-events.js +1 -1
- package/dist/lib/startup.js +18 -13
- package/dist/lib/storage.js +10 -10
- package/dist/lib/templating.js +16 -16
- package/dist/lib/theme.js +10 -10
- package/dist/lib/tray.js +27 -27
- package/dist/lib/usage.js +11 -11
- package/dist/lib/window-manager.js +26 -26
- package/dist/main.js +398 -483
- package/dist/preload.js +236 -176
- package/dist/renderer.js +417 -391
- package/dist/test/fixtures/consumer-app/config/omega.json5 +1 -1
- package/dist/test/fixtures/consumer-app/src/assets/js/components/main/index.js +8 -11
- package/dist/test/fixtures/consumer-app/src/main.js +5 -7
- package/dist/test/fixtures/consumer-app/src/preload.js +2 -2
- package/dist/test/harness/boot-entry.js +22 -20
- package/dist/test/harness/main-entry.js +31 -30
- package/dist/test/harness/renderer-entry.js +5 -5
- package/dist/test/harness/renderer-preload.js +137 -141
- package/dist/test/index.js +10 -10
- package/dist/test/runner.js +2 -2
- package/dist/test/runners/boot.js +7 -6
- package/dist/test/runners/electron.js +3 -2
- package/dist/test/runners/render-event.js +2 -2
- package/dist/test/suites/boot/consumer-app-boots.test.js +57 -26
- package/dist/test/suites/boot/restart-manager.test.js +2 -2
- package/dist/test/suites/boot/storage-bundled.test.js +5 -5
- package/dist/test/suites/boot/theme.test.js +13 -13
- package/dist/test/suites/build/audit.test.js +1 -1
- package/dist/test/suites/build/auth-persistence-resolve.test.js +6 -6
- package/dist/test/suites/build/boot-fixture.test.js +2 -2
- package/dist/test/suites/build/boot-runner-timeout.test.js +6 -5
- package/dist/test/suites/build/brand-scss.test.js +1 -1
- package/dist/test/suites/build/build-json-bake.test.js +1 -1
- package/dist/test/suites/build/cli.test.js +2 -2
- package/dist/test/suites/build/config-schema.test.js +5 -5
- package/dist/test/suites/build/defaults-scaffold.test.js +2 -2
- package/dist/test/suites/build/deploy-hook.test.js +3 -3
- package/dist/test/suites/build/ensure-target.test.js +2 -2
- package/dist/test/suites/build/env-delivery.test.js +2 -2
- package/dist/test/suites/build/esm-only-dependency.test.js +2 -2
- package/dist/test/suites/build/exports.test.js +9 -8
- package/dist/test/suites/build/get-config.test.js +4 -4
- package/dist/test/suites/build/manifest-deps.test.js +1 -1
- package/dist/test/suites/build/merge-line-files.test.js +1 -1
- package/dist/test/suites/build/omega-shell.test.js +34 -2
- package/dist/test/suites/build/omega.test.js +350 -0
- package/dist/test/suites/build/renderer-auth-bridge.test.js +211 -78
- package/dist/test/suites/build/runner.test.js +2 -2
- package/dist/test/suites/build/sentry.test.js +2 -2
- package/dist/test/suites/build/sign-windows-e2e.test.js +2 -2
- package/dist/test/suites/build/templating.test.js +3 -3
- package/dist/test/suites/build/test-stealth.test.js +7 -9
- package/dist/test/suites/build/url-helpers.test.js +55 -56
- package/dist/test/suites/build/validate-config.test.js +2 -2
- package/dist/test/suites/build/wave5-pins.test.js +2 -2
- package/dist/test/suites/main/analytics.test.js +59 -59
- package/dist/test/suites/main/app-state.test.js +66 -66
- package/dist/test/suites/main/auth-flow.test.js +41 -41
- package/dist/test/suites/main/auth-persistence.test.js +54 -43
- package/dist/test/suites/main/{client-bridge.integration.test.js → auth.integration.test.js} +10 -9
- package/dist/test/suites/main/auth.test.js +336 -0
- package/dist/test/suites/main/auto-updater.test.js +134 -134
- package/dist/test/suites/main/boot-sequence.test.js +37 -49
- package/dist/test/suites/main/context-menu.test.js +51 -50
- package/dist/test/suites/main/context.test.js +25 -25
- package/dist/test/suites/main/deep-link.test.js +74 -74
- package/dist/test/suites/main/fontawesome.test.js +27 -27
- package/dist/test/suites/main/ipc.test.js +35 -35
- package/dist/test/suites/main/menu.test.js +101 -100
- package/dist/test/suites/main/protocol.test.js +19 -19
- package/dist/test/suites/main/remote-config.test.js +63 -63
- package/dist/test/suites/main/remote-scripts.test.js +103 -103
- package/dist/test/suites/main/request.test.js +71 -0
- package/dist/test/suites/main/restart-manager.test.js +33 -33
- package/dist/test/suites/main/startup-paths-and-ua.test.js +4 -4
- package/dist/test/suites/main/startup.test.js +26 -26
- package/dist/test/suites/main/stealth-window.test.js +1 -1
- package/dist/test/suites/main/storage.test.js +25 -25
- package/dist/test/suites/main/theme.test.js +34 -34
- package/dist/test/suites/main/tray.test.js +79 -79
- package/dist/test/suites/main/url-helpers.test.js +133 -133
- package/dist/test/suites/main/usage.test.js +25 -25
- package/dist/test/suites/main/window-bounds.test.js +27 -27
- package/dist/test/suites/main/window-manager.test.js +44 -44
- package/dist/test/suites/renderer/analytics-bridge.test.js +5 -5
- package/dist/test/suites/renderer/cross-context-helpers.test.js +37 -31
- package/dist/test/suites/renderer/round-trip.test.js +3 -3
- package/dist/test/suites/renderer/tooltips.test.js +15 -15
- package/dist/test/suites/renderer/{window-em-surface.test.js → window-desktop-surface.test.js} +27 -7
- package/dist/test/utils/extended-mode-warning.js +1 -1
- package/dist/utils/boot-harness.js +56 -0
- package/dist/utils/mode-helpers.js +2 -15
- package/dist/utils/ship-keys.js +3 -3
- package/dist/utils/signing-status.js +51 -0
- package/dist/utils/test-events.js +7 -0
- package/dist/utils/test-stealth.js +6 -6
- package/dist/utils/url-helpers.js +52 -42
- package/dist/utils/user-agent.js +44 -0
- package/dist/vendor/account/engine.js +3 -3
- package/dist/vendor/account/index.js +14 -45
- package/dist/vendor/account/resolve-account.js +44 -0
- package/dist/vendor/account/schema.js +1 -1
- package/dist/vendor/account/user.js +99 -0
- package/dist/vendor/config/client-config.js +1 -1
- package/dist/vendor/config/environment.js +11 -30
- package/dist/vendor/config/index.js +8 -11
- package/dist/vendor/config/load.js +1 -2
- package/dist/vendor/config/platforms.js +1 -1
- package/dist/vendor/config/retired-keys.js +2 -2
- package/dist/vendor/config/schema.js +5 -8
- package/dist/vendor/config/site-global.js +2 -3
- package/dist/vendor/config/validate.js +1 -2
- package/dist/vendor/config/winback.js +1 -1
- package/dist/vendor/devkit/actions-secrets.js +1 -1
- package/dist/vendor/devkit/attach-log-file.js +1 -1
- package/dist/vendor/devkit/build-json.js +1 -1
- package/dist/vendor/devkit/cli-router.js +3 -4
- package/dist/vendor/devkit/defaults-engine.js +9 -11
- package/dist/vendor/devkit/local.js +2 -0
- package/dist/vendor/devkit/merge-line-files.js +2 -3
- package/dist/vendor/devkit/test/runner-core.js +6 -6
- package/dist/vendor/monitoring/env.js +2 -2
- package/dist/vendor/monitoring/index.js +1 -1
- package/dist/vendor/monitoring/main.js +1 -1
- package/dist/vendor/monitoring/preload.js +1 -1
- package/dist/vendor/monitoring/renderer.js +1 -1
- package/docs/analytics.md +8 -8
- package/docs/app-state.md +19 -19
- package/docs/audit.md +4 -4
- package/docs/{client-bridge.md → auth.md} +88 -73
- package/docs/auto-updater.md +8 -8
- package/docs/boot-sequence.md +11 -6
- package/docs/build-system.md +1 -1
- package/docs/cdp-debugging.md +1 -1
- package/docs/common-mistakes.md +7 -7
- package/docs/config-schema.md +1 -1
- package/docs/context-menu.md +13 -13
- package/docs/context.md +11 -11
- package/docs/css.md +3 -9
- package/docs/deep-link.md +25 -25
- package/docs/environment-detection.md +16 -16
- package/docs/fontawesome.md +7 -5
- package/docs/hooks.md +8 -8
- package/docs/index.md +38 -27
- package/docs/ipc.md +10 -10
- package/docs/lib-modules.md +9 -9
- package/docs/logging.md +12 -14
- package/docs/menu.md +18 -18
- package/docs/remote-config.md +9 -9
- package/docs/remote-scripts.md +12 -12
- package/docs/restart-manager.md +8 -8
- package/docs/sentry.md +4 -4
- package/docs/shared/analytics.md +1 -1
- package/docs/shared/breaking-changes.md +79 -13
- package/docs/shared/config.md +17 -21
- package/docs/shared/logging.md +1 -1
- package/docs/shared/monitoring.md +5 -5
- package/docs/shared/testing.md +2 -2
- package/docs/shared/theming.md +1 -1
- package/docs/shared/translation.md +19 -10
- package/docs/startup.md +16 -16
- package/docs/storage.md +11 -11
- package/docs/templating.md +3 -3
- package/docs/test-boot-layer.md +12 -12
- package/docs/test-framework.md +17 -17
- package/docs/themes.md +7 -7
- package/docs/tooltips.md +2 -2
- package/docs/tray.md +31 -31
- package/docs/usage.md +7 -7
- package/docs/verts.md +1 -1
- package/docs/windows.md +22 -22
- package/package.json +3 -4
- package/dist/lib/client-bridge.js +0 -374
- package/dist/lib/logger.js +0 -4
- package/dist/test/suites/build/manager.test.js +0 -213
- package/dist/test/suites/main/client-bridge.test.js +0 -262
|
@@ -8,117 +8,117 @@ module.exports = defineCases({
|
|
|
8
8
|
layer: 'main',
|
|
9
9
|
description: 'remote-scripts (main)',
|
|
10
10
|
cleanup: (ctx) => {
|
|
11
|
-
ctx.
|
|
12
|
-
ctx.
|
|
13
|
-
ctx.
|
|
11
|
+
ctx.omega.remoteScripts.shutdown();
|
|
12
|
+
ctx.omega.storage.set('remoteScripts.lastRun', null);
|
|
13
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
14
14
|
},
|
|
15
15
|
tests: [
|
|
16
16
|
// ─── Boot wiring ────────────────────────────────────────────────────────
|
|
17
17
|
{
|
|
18
|
-
name: 'remoteScripts module wired on
|
|
18
|
+
name: 'remoteScripts module wired on omega + initialized during boot',
|
|
19
19
|
run: (ctx) => {
|
|
20
|
-
ctx.expect(ctx.
|
|
21
|
-
ctx.expect(ctx.
|
|
20
|
+
ctx.expect(ctx.omega.remoteScripts).toBeDefined();
|
|
21
|
+
ctx.expect(ctx.omega.remoteScripts._initialized).toBe(true);
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
name: 'off by default: no config.remoteScripts → lane disabled (no URL, no interval)',
|
|
26
26
|
run: (ctx) => {
|
|
27
|
-
ctx.
|
|
28
|
-
const orig = ctx.
|
|
29
|
-
delete ctx.
|
|
27
|
+
ctx.omega.remoteScripts.shutdown();
|
|
28
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
29
|
+
delete ctx.omega.config.remoteScripts;
|
|
30
30
|
try {
|
|
31
|
-
ctx.
|
|
32
|
-
ctx.expect(ctx.
|
|
33
|
-
ctx.expect(ctx.
|
|
34
|
-
ctx.expect(ctx.
|
|
31
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
32
|
+
ctx.expect(ctx.omega.remoteScripts._enabled).toBe(false);
|
|
33
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe(null);
|
|
34
|
+
ctx.expect(ctx.omega.remoteScripts._intervalId).toBe(null);
|
|
35
35
|
} finally {
|
|
36
|
-
ctx.
|
|
37
|
-
ctx.
|
|
38
|
-
ctx.
|
|
36
|
+
ctx.omega.remoteScripts.shutdown();
|
|
37
|
+
ctx.omega.config.remoteScripts = orig;
|
|
38
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
name: 'opted in without explicit url: URL derived from brand.url + /data/scripts/main.js',
|
|
44
44
|
run: (ctx) => {
|
|
45
|
-
ctx.
|
|
46
|
-
const orig = ctx.
|
|
47
|
-
const origBrandUrl = ctx.
|
|
45
|
+
ctx.omega.remoteScripts.shutdown();
|
|
46
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
47
|
+
const origBrandUrl = ctx.omega.config.brand.url;
|
|
48
48
|
// Synthetic loopback brand.url: initialize() fires a real refreshNow(),
|
|
49
49
|
// and in a CONSUMER test run the real brand.url could serve a script
|
|
50
50
|
// this lane would EXECUTE. Port 59987 is deliberately unlikely to listen.
|
|
51
|
-
ctx.
|
|
52
|
-
ctx.
|
|
51
|
+
ctx.omega.config.brand.url = 'http://localhost:59987';
|
|
52
|
+
ctx.omega.config.remoteScripts = { enabled: true };
|
|
53
53
|
try {
|
|
54
|
-
ctx.
|
|
54
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
55
55
|
// brand.url is set, so the URL must actually derive — a null here
|
|
56
56
|
// would let the assertion pass vacuously.
|
|
57
|
-
ctx.expect(ctx.
|
|
57
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe('http://localhost:59987/data/scripts/main.js');
|
|
58
58
|
} finally {
|
|
59
|
-
ctx.
|
|
60
|
-
ctx.
|
|
61
|
-
ctx.
|
|
62
|
-
ctx.
|
|
59
|
+
ctx.omega.remoteScripts.shutdown();
|
|
60
|
+
ctx.omega.config.remoteScripts = orig;
|
|
61
|
+
ctx.omega.config.brand.url = origBrandUrl;
|
|
62
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
name: 'URL override: config.remoteScripts.url wins over brand.url',
|
|
68
68
|
run: (ctx) => {
|
|
69
|
-
ctx.
|
|
70
|
-
const orig = ctx.
|
|
71
|
-
ctx.
|
|
69
|
+
ctx.omega.remoteScripts.shutdown();
|
|
70
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
71
|
+
ctx.omega.config.remoteScripts = { enabled: true, url: 'https://override.example/patch.js' };
|
|
72
72
|
try {
|
|
73
|
-
ctx.
|
|
74
|
-
ctx.expect(ctx.
|
|
73
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
74
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe('https://override.example/patch.js');
|
|
75
75
|
} finally {
|
|
76
|
-
ctx.
|
|
77
|
-
ctx.
|
|
78
|
-
ctx.
|
|
76
|
+
ctx.omega.remoteScripts.shutdown();
|
|
77
|
+
ctx.omega.config.remoteScripts = orig;
|
|
78
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
name: 'transport gate: non-https URL refused (lane disabled), loopback http allowed',
|
|
84
84
|
run: (ctx) => {
|
|
85
|
-
const orig = ctx.
|
|
85
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
86
86
|
try {
|
|
87
|
-
ctx.
|
|
88
|
-
ctx.
|
|
89
|
-
ctx.
|
|
90
|
-
ctx.expect(ctx.
|
|
91
|
-
ctx.expect(ctx.
|
|
87
|
+
ctx.omega.remoteScripts.shutdown();
|
|
88
|
+
ctx.omega.config.remoteScripts = { enabled: true, url: 'http://insecure.example/patch.js' };
|
|
89
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
90
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe(null);
|
|
91
|
+
ctx.expect(ctx.omega.remoteScripts._intervalId).toBe(null);
|
|
92
92
|
|
|
93
93
|
// Port 59987 is deliberately unlikely to be listening — initialize()
|
|
94
94
|
// fires a real refreshNow(), and a live port (4000 = the web dev
|
|
95
95
|
// server) would have its response body EXECUTED by this lane.
|
|
96
|
-
ctx.
|
|
97
|
-
ctx.
|
|
98
|
-
ctx.
|
|
99
|
-
ctx.expect(ctx.
|
|
96
|
+
ctx.omega.remoteScripts.shutdown();
|
|
97
|
+
ctx.omega.config.remoteScripts = { enabled: true, url: 'http://localhost:59987/patch.js' };
|
|
98
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
99
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe('http://localhost:59987/patch.js');
|
|
100
100
|
} finally {
|
|
101
|
-
ctx.
|
|
102
|
-
ctx.
|
|
103
|
-
ctx.
|
|
101
|
+
ctx.omega.remoteScripts.shutdown();
|
|
102
|
+
ctx.omega.config.remoteScripts = orig;
|
|
103
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
name: 'enabled=false: skip everything',
|
|
109
109
|
run: (ctx) => {
|
|
110
|
-
ctx.
|
|
111
|
-
const orig = ctx.
|
|
112
|
-
ctx.
|
|
110
|
+
ctx.omega.remoteScripts.shutdown();
|
|
111
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
112
|
+
ctx.omega.config.remoteScripts = { enabled: false };
|
|
113
113
|
try {
|
|
114
|
-
ctx.
|
|
115
|
-
ctx.expect(ctx.
|
|
116
|
-
ctx.expect(ctx.
|
|
117
|
-
ctx.expect(ctx.
|
|
114
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
115
|
+
ctx.expect(ctx.omega.remoteScripts._enabled).toBe(false);
|
|
116
|
+
ctx.expect(ctx.omega.remoteScripts._url).toBe(null);
|
|
117
|
+
ctx.expect(ctx.omega.remoteScripts._intervalId).toBe(null);
|
|
118
118
|
} finally {
|
|
119
|
-
ctx.
|
|
120
|
-
ctx.
|
|
121
|
-
ctx.
|
|
119
|
+
ctx.omega.remoteScripts.shutdown();
|
|
120
|
+
ctx.omega.config.remoteScripts = orig;
|
|
121
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
},
|
|
@@ -127,9 +127,9 @@ module.exports = defineCases({
|
|
|
127
127
|
{
|
|
128
128
|
name: '_hash: stable — same input produces same 16-char hex',
|
|
129
129
|
run: (ctx) => {
|
|
130
|
-
const rs = ctx.
|
|
131
|
-
const h1 = rs._hash('
|
|
132
|
-
const h2 = rs._hash('
|
|
130
|
+
const rs = ctx.omega.remoteScripts;
|
|
131
|
+
const h1 = rs._hash('omega.storage.delete("x");');
|
|
132
|
+
const h2 = rs._hash('omega.storage.delete("x");');
|
|
133
133
|
ctx.expect(h1).toBe(h2);
|
|
134
134
|
ctx.expect(typeof h1).toBe('string');
|
|
135
135
|
ctx.expect(h1.length).toBe(16);
|
|
@@ -138,41 +138,41 @@ module.exports = defineCases({
|
|
|
138
138
|
{
|
|
139
139
|
name: '_hash: different input produces different hash',
|
|
140
140
|
run: (ctx) => {
|
|
141
|
-
const rs = ctx.
|
|
141
|
+
const rs = ctx.omega.remoteScripts;
|
|
142
142
|
ctx.expect(rs._hash('script v1')).not.toBe(rs._hash('script v2'));
|
|
143
143
|
},
|
|
144
144
|
},
|
|
145
145
|
|
|
146
146
|
// ─── Execution ──────────────────────────────────────────────────────────
|
|
147
147
|
{
|
|
148
|
-
name: '_execute: runs code with
|
|
148
|
+
name: '_execute: runs code with omega in scope',
|
|
149
149
|
run: async (ctx) => {
|
|
150
|
-
ctx.
|
|
151
|
-
await ctx.
|
|
152
|
-
ctx.expect(ctx.
|
|
153
|
-
delete ctx.
|
|
150
|
+
ctx.omega._remoteScriptTestResult = null;
|
|
151
|
+
await ctx.omega.remoteScripts._execute('omega._remoteScriptTestResult = 42;');
|
|
152
|
+
ctx.expect(ctx.omega._remoteScriptTestResult).toBe(42);
|
|
153
|
+
delete ctx.omega._remoteScriptTestResult;
|
|
154
154
|
},
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
157
|
name: '_execute: supports async code (await)',
|
|
158
158
|
run: async (ctx) => {
|
|
159
|
-
ctx.
|
|
160
|
-
await ctx.
|
|
161
|
-
'const v = await Promise.resolve(99);
|
|
159
|
+
ctx.omega._remoteScriptTestResult = null;
|
|
160
|
+
await ctx.omega.remoteScripts._execute(
|
|
161
|
+
'const v = await Promise.resolve(99); omega._remoteScriptTestResult = v;',
|
|
162
162
|
);
|
|
163
|
-
ctx.expect(ctx.
|
|
164
|
-
delete ctx.
|
|
163
|
+
ctx.expect(ctx.omega._remoteScriptTestResult).toBe(99);
|
|
164
|
+
delete ctx.omega._remoteScriptTestResult;
|
|
165
165
|
},
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
168
|
name: '_execute: require is available (e.g. require("path"))',
|
|
169
169
|
run: async (ctx) => {
|
|
170
|
-
ctx.
|
|
171
|
-
await ctx.
|
|
172
|
-
'const path = require("path");
|
|
170
|
+
ctx.omega._remoteScriptTestResult = null;
|
|
171
|
+
await ctx.omega.remoteScripts._execute(
|
|
172
|
+
'const path = require("path"); omega._remoteScriptTestResult = typeof path.join;',
|
|
173
173
|
);
|
|
174
|
-
ctx.expect(ctx.
|
|
175
|
-
delete ctx.
|
|
174
|
+
ctx.expect(ctx.omega._remoteScriptTestResult).toBe('function');
|
|
175
|
+
delete ctx.omega._remoteScriptTestResult;
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
{
|
|
@@ -180,7 +180,7 @@ module.exports = defineCases({
|
|
|
180
180
|
run: async (ctx) => {
|
|
181
181
|
let threw = false;
|
|
182
182
|
try {
|
|
183
|
-
await ctx.
|
|
183
|
+
await ctx.omega.remoteScripts._execute('throw new Error("boom");');
|
|
184
184
|
} catch (e) {
|
|
185
185
|
threw = true;
|
|
186
186
|
ctx.expect(e.message).toBe('boom');
|
|
@@ -193,33 +193,33 @@ module.exports = defineCases({
|
|
|
193
193
|
{
|
|
194
194
|
name: 'getLastRun returns null when no script has run',
|
|
195
195
|
run: (ctx) => {
|
|
196
|
-
ctx.
|
|
197
|
-
ctx.expect(ctx.
|
|
196
|
+
ctx.omega.storage.set('remoteScripts.lastRun', null);
|
|
197
|
+
ctx.expect(ctx.omega.remoteScripts.getLastRun()).toBe(null);
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
201
|
name: 'clearExecuted wipes stored hash',
|
|
202
202
|
run: (ctx) => {
|
|
203
|
-
ctx.
|
|
204
|
-
ctx.expect(ctx.
|
|
205
|
-
ctx.
|
|
206
|
-
ctx.expect(ctx.
|
|
203
|
+
ctx.omega.storage.set('remoteScripts.lastRun', { hash: 'abc', timestamp: 1 });
|
|
204
|
+
ctx.expect(ctx.omega.remoteScripts.getLastRun()).toEqual({ hash: 'abc', timestamp: 1 });
|
|
205
|
+
ctx.omega.remoteScripts.clearExecuted();
|
|
206
|
+
ctx.expect(ctx.omega.remoteScripts.getLastRun()).toBe(null);
|
|
207
207
|
},
|
|
208
208
|
},
|
|
209
209
|
{
|
|
210
210
|
name: 'refreshNow returns null when disabled',
|
|
211
211
|
run: async (ctx) => {
|
|
212
|
-
ctx.
|
|
213
|
-
const orig = ctx.
|
|
214
|
-
ctx.
|
|
212
|
+
ctx.omega.remoteScripts.shutdown();
|
|
213
|
+
const orig = ctx.omega.config.remoteScripts;
|
|
214
|
+
ctx.omega.config.remoteScripts = { enabled: false };
|
|
215
215
|
try {
|
|
216
|
-
ctx.
|
|
217
|
-
const result = await ctx.
|
|
216
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
217
|
+
const result = await ctx.omega.remoteScripts.refreshNow();
|
|
218
218
|
ctx.expect(result).toBe(null);
|
|
219
219
|
} finally {
|
|
220
|
-
ctx.
|
|
221
|
-
ctx.
|
|
222
|
-
ctx.
|
|
220
|
+
ctx.omega.remoteScripts.shutdown();
|
|
221
|
+
ctx.omega.config.remoteScripts = orig;
|
|
222
|
+
ctx.omega.remoteScripts.initialize(ctx.omega);
|
|
223
223
|
}
|
|
224
224
|
},
|
|
225
225
|
},
|
|
@@ -227,18 +227,18 @@ module.exports = defineCases({
|
|
|
227
227
|
{
|
|
228
228
|
name: 'full pipeline: execute script → storage patched → hash stored → same script skipped → changed script re-runs',
|
|
229
229
|
run: async (ctx) => {
|
|
230
|
-
const rs = ctx.
|
|
230
|
+
const rs = ctx.omega.remoteScripts;
|
|
231
231
|
rs.clearExecuted();
|
|
232
232
|
|
|
233
|
-
const scriptV1 = '
|
|
234
|
-
const scriptV2 = '
|
|
233
|
+
const scriptV1 = 'omega.storage.set("remoteScripts._test.patched", true);';
|
|
234
|
+
const scriptV2 = 'omega.storage.set("remoteScripts._test.patched", "v2");';
|
|
235
235
|
|
|
236
236
|
// 1. Execute v1 — should patch storage
|
|
237
237
|
await rs._execute(scriptV1);
|
|
238
238
|
const hashV1 = rs._hash(scriptV1);
|
|
239
|
-
ctx.
|
|
239
|
+
ctx.omega.storage.set('remoteScripts.lastRun', { hash: hashV1, timestamp: Date.now() });
|
|
240
240
|
|
|
241
|
-
ctx.expect(ctx.
|
|
241
|
+
ctx.expect(ctx.omega.storage.get('remoteScripts._test.patched')).toBe(true);
|
|
242
242
|
ctx.expect(rs.getLastRun().hash).toBe(hashV1);
|
|
243
243
|
|
|
244
244
|
// 2. Same script again — hash matches, should be skipped
|
|
@@ -251,25 +251,25 @@ module.exports = defineCases({
|
|
|
251
251
|
ctx.expect(hashV2).not.toBe(hashV1); // proves the hash changes
|
|
252
252
|
|
|
253
253
|
await rs._execute(scriptV2);
|
|
254
|
-
ctx.expect(ctx.
|
|
254
|
+
ctx.expect(ctx.omega.storage.get('remoteScripts._test.patched')).toBe('v2');
|
|
255
255
|
|
|
256
256
|
// Cleanup
|
|
257
|
-
ctx.
|
|
257
|
+
ctx.omega.storage.delete('remoteScripts._test.patched');
|
|
258
258
|
},
|
|
259
259
|
},
|
|
260
260
|
|
|
261
261
|
{
|
|
262
262
|
name: 'shutdown resets all internal state',
|
|
263
263
|
run: (ctx) => {
|
|
264
|
-
ctx.
|
|
265
|
-
const rs = ctx.
|
|
264
|
+
ctx.omega.remoteScripts.shutdown();
|
|
265
|
+
const rs = ctx.omega.remoteScripts;
|
|
266
266
|
ctx.expect(rs._initialized).toBe(false);
|
|
267
|
-
ctx.expect(rs.
|
|
267
|
+
ctx.expect(rs._omega).toBe(null);
|
|
268
268
|
ctx.expect(rs._url).toBe(null);
|
|
269
269
|
ctx.expect(rs._enabled).toBe(false);
|
|
270
270
|
ctx.expect(rs._intervalId).toBe(null);
|
|
271
271
|
// Re-init for cleanup handler
|
|
272
|
-
rs.initialize(ctx.
|
|
272
|
+
rs.initialize(ctx.omega);
|
|
273
273
|
},
|
|
274
274
|
},
|
|
275
275
|
],
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Main-process tests for `omega.request()`: the harmonized API fetch, built once
|
|
2
|
+
// on the instance through @omega.js/client's createRequest, the extension
|
|
3
|
+
// background's shape ([#945](https://github.com/Omega-JS-Stack/omega/issues/945)).
|
|
4
|
+
//
|
|
5
|
+
// The API is a real local HTTP server; the one seam is main's Firebase session
|
|
6
|
+
// (`omega.auth._firebaseAuth`), because a real signed-in session needs the auth
|
|
7
|
+
// emulator, which the e2e-desktop lane drives.
|
|
8
|
+
|
|
9
|
+
const http = require('http');
|
|
10
|
+
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
11
|
+
|
|
12
|
+
// A local API that records what reaches it and answers `{ ok: true }`
|
|
13
|
+
async function startApi() {
|
|
14
|
+
const received = [];
|
|
15
|
+
const server = http.createServer((req, res) => {
|
|
16
|
+
let body = '';
|
|
17
|
+
req.on('data', (chunk) => { body += chunk; });
|
|
18
|
+
req.on('end', () => {
|
|
19
|
+
received.push({ method: req.method, url: req.url, authorization: req.headers.authorization, body });
|
|
20
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
21
|
+
res.end(JSON.stringify({ ok: true }));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
await new Promise((resolve) => server.listen(0, resolve));
|
|
25
|
+
return { port: server.address().port, received, close: () => new Promise((resolve) => server.close(resolve)) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = defineCases({
|
|
29
|
+
type: 'suite',
|
|
30
|
+
layer: 'main',
|
|
31
|
+
description: 'omega.request (main)',
|
|
32
|
+
tests: [
|
|
33
|
+
{
|
|
34
|
+
name: 'omega.request posts with the token omega.auth.getIdToken returns; signed out, getIdToken is null',
|
|
35
|
+
run: async (ctx) => {
|
|
36
|
+
const auth = ctx.omega.auth;
|
|
37
|
+
const api = await startApi();
|
|
38
|
+
const saved = {
|
|
39
|
+
firebaseAuth: auth._firebaseAuth,
|
|
40
|
+
https: process.env.OMEGA_HTTPS_PORT,
|
|
41
|
+
hosting: process.env.OMEGA_HOSTING_PORT,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
auth._firebaseAuth = { currentUser: { getIdToken: async () => 'token-1' } };
|
|
46
|
+
ctx.expect(await auth.getIdToken()).toBe('token-1');
|
|
47
|
+
|
|
48
|
+
// The API base is read as the call starts: the local stack, here this server
|
|
49
|
+
delete process.env.OMEGA_HTTPS_PORT;
|
|
50
|
+
process.env.OMEGA_HOSTING_PORT = String(api.port);
|
|
51
|
+
const answer = await ctx.omega.request('/notes', { method: 'POST', body: { text: 'hi' } });
|
|
52
|
+
|
|
53
|
+
ctx.expect(answer).toEqual({ ok: true });
|
|
54
|
+
ctx.expect(api.received).toEqual([{ method: 'POST', url: '/notes', authorization: 'Bearer token-1', body: '{"text":"hi"}' }]);
|
|
55
|
+
|
|
56
|
+
auth._firebaseAuth = { currentUser: null };
|
|
57
|
+
ctx.expect(await auth.getIdToken()).toBeNull();
|
|
58
|
+
auth._firebaseAuth = null;
|
|
59
|
+
ctx.expect(await auth.getIdToken()).toBeNull();
|
|
60
|
+
} finally {
|
|
61
|
+
auth._firebaseAuth = saved.firebaseAuth;
|
|
62
|
+
if (saved.https === undefined) delete process.env.OMEGA_HTTPS_PORT;
|
|
63
|
+
else process.env.OMEGA_HTTPS_PORT = saved.https;
|
|
64
|
+
if (saved.hosting === undefined) delete process.env.OMEGA_HOSTING_PORT;
|
|
65
|
+
else process.env.OMEGA_HOSTING_PORT = saved.hosting;
|
|
66
|
+
await api.close();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
@@ -85,14 +85,14 @@ module.exports = defineCases({
|
|
|
85
85
|
description: 'restart-manager (main)',
|
|
86
86
|
cleanup: async (ctx) => {
|
|
87
87
|
if (ctx.state.rm) ctx.state.rm.server.close();
|
|
88
|
-
ctx.
|
|
89
|
-
ctx.
|
|
88
|
+
ctx.omega.restartManager.shutdown();
|
|
89
|
+
ctx.omega.restartManager.initialize(ctx.omega);
|
|
90
90
|
},
|
|
91
91
|
tests: [
|
|
92
92
|
{
|
|
93
|
-
name: 'wired on
|
|
93
|
+
name: 'wired on omega with the full v2 API surface',
|
|
94
94
|
run: (ctx) => {
|
|
95
|
-
const rm = ctx.
|
|
95
|
+
const rm = ctx.omega.restartManager;
|
|
96
96
|
ctx.expect(rm).toBeDefined();
|
|
97
97
|
for (const fn of ['register', 'unregister', 'ensureInstalled', 'ensureRunning', 'getStatus', 'shutdown']) {
|
|
98
98
|
ctx.expect(typeof rm[fn]).toBe('function');
|
|
@@ -102,7 +102,7 @@ module.exports = defineCases({
|
|
|
102
102
|
{
|
|
103
103
|
name: 'testing bail: bailed with reason, no timer, no before-quit hook',
|
|
104
104
|
run: (ctx) => {
|
|
105
|
-
const rm = ctx.
|
|
105
|
+
const rm = ctx.omega.restartManager;
|
|
106
106
|
const status = rm.getStatus();
|
|
107
107
|
ctx.expect(status.bailed).toBe(true);
|
|
108
108
|
ctx.expect(status.bailReason).toBe('testing');
|
|
@@ -114,7 +114,7 @@ module.exports = defineCases({
|
|
|
114
114
|
name: 'testing-root isolation: _root lives under the (Testing) userData, never appData',
|
|
115
115
|
run: (ctx) => {
|
|
116
116
|
const { app } = require('electron');
|
|
117
|
-
const rm = ctx.
|
|
117
|
+
const rm = ctx.omega.restartManager;
|
|
118
118
|
ctx.expect(rm._root.startsWith(app.getPath('userData'))).toBe(true);
|
|
119
119
|
ctx.expect(rm._root).not.toBe(protocol.resolveSharedRoot(app.getPath('appData'), {}));
|
|
120
120
|
},
|
|
@@ -122,38 +122,38 @@ module.exports = defineCases({
|
|
|
122
122
|
{
|
|
123
123
|
name: 'enabled=false bail (reason disabled, no timer)',
|
|
124
124
|
run: (ctx) => {
|
|
125
|
-
const rm = ctx.
|
|
125
|
+
const rm = ctx.omega.restartManager;
|
|
126
126
|
rm.shutdown();
|
|
127
|
-
const orig = ctx.
|
|
128
|
-
ctx.
|
|
127
|
+
const orig = ctx.omega.config.restartManager;
|
|
128
|
+
ctx.omega.config.restartManager = { enabled: false };
|
|
129
129
|
try {
|
|
130
|
-
rm.initialize(ctx.
|
|
130
|
+
rm.initialize(ctx.omega);
|
|
131
131
|
// Testing bail fires first in the harness, so force-evaluate the
|
|
132
132
|
// config path: _enabled captured false proves the knob was read.
|
|
133
133
|
ctx.expect(rm._enabled).toBe(false);
|
|
134
134
|
ctx.expect(rm._registerTimer).toBe(null);
|
|
135
135
|
} finally {
|
|
136
136
|
rm.shutdown();
|
|
137
|
-
ctx.
|
|
138
|
-
rm.initialize(ctx.
|
|
137
|
+
ctx.omega.config.restartManager = orig;
|
|
138
|
+
rm.initialize(ctx.omega);
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
name: 'brand.id === "restart-manager" bail (RM does not manage itself)',
|
|
144
144
|
run: (ctx) => {
|
|
145
|
-
const rm = ctx.
|
|
145
|
+
const rm = ctx.omega.restartManager;
|
|
146
146
|
rm.shutdown();
|
|
147
|
-
const origBrand = ctx.
|
|
148
|
-
ctx.
|
|
147
|
+
const origBrand = ctx.omega.config.brand;
|
|
148
|
+
ctx.omega.config.brand = { ...origBrand, id: 'restart-manager' };
|
|
149
149
|
try {
|
|
150
|
-
rm.initialize(ctx.
|
|
150
|
+
rm.initialize(ctx.omega);
|
|
151
151
|
ctx.expect(rm._registerTimer).toBe(null);
|
|
152
152
|
ctx.expect(rm.getStatus().bailed).toBe(true);
|
|
153
153
|
} finally {
|
|
154
154
|
rm.shutdown();
|
|
155
|
-
ctx.
|
|
156
|
-
rm.initialize(ctx.
|
|
155
|
+
ctx.omega.config.brand = origBrand;
|
|
156
|
+
rm.initialize(ctx.omega);
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
},
|
|
@@ -161,14 +161,14 @@ module.exports = defineCases({
|
|
|
161
161
|
name: 'non-production without OMEGA_RESTART_MANAGER_DEV: nothing scheduled',
|
|
162
162
|
run: (ctx) => {
|
|
163
163
|
ctx.expect(process.env.OMEGA_RESTART_MANAGER_DEV).not.toBe('1');
|
|
164
|
-
ctx.expect(ctx.
|
|
165
|
-
ctx.expect(ctx.
|
|
164
|
+
ctx.expect(ctx.omega.isProduction()).toBe(false);
|
|
165
|
+
ctx.expect(ctx.omega.restartManager._registerTimer).toBe(null);
|
|
166
166
|
},
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
169
|
name: '_readRuntime: valid file parses; wrong version / malformed / missing → null',
|
|
170
170
|
run: (ctx) => {
|
|
171
|
-
const rm = ctx.
|
|
171
|
+
const rm = ctx.omega.restartManager;
|
|
172
172
|
const runtimePath = protocol.getRuntimePath(rm._root);
|
|
173
173
|
|
|
174
174
|
writeRuntime(rm._root, 4000);
|
|
@@ -189,7 +189,7 @@ module.exports = defineCases({
|
|
|
189
189
|
{
|
|
190
190
|
name: '_pidAlive: own pid alive, absurd pid dead',
|
|
191
191
|
run: (ctx) => {
|
|
192
|
-
const rm = ctx.
|
|
192
|
+
const rm = ctx.omega.restartManager;
|
|
193
193
|
ctx.expect(rm._pidAlive(process.pid)).toBe(true);
|
|
194
194
|
ctx.expect(rm._pidAlive(999999)).toBe(false);
|
|
195
195
|
},
|
|
@@ -197,14 +197,14 @@ module.exports = defineCases({
|
|
|
197
197
|
{
|
|
198
198
|
name: 'register round-trip: contract-valid payload lands, pid is ours, status flips',
|
|
199
199
|
run: async (ctx) => {
|
|
200
|
-
const rm = ctx.
|
|
200
|
+
const rm = ctx.omega.restartManager;
|
|
201
201
|
ctx.state.rm = await startContractServer();
|
|
202
202
|
writeRuntime(rm._root, ctx.state.rm.port);
|
|
203
203
|
|
|
204
204
|
const ok = await rm.register();
|
|
205
205
|
ctx.expect(ok).toBe(true);
|
|
206
206
|
|
|
207
|
-
const appId = ctx.
|
|
207
|
+
const appId = ctx.omega.config.brand.id;
|
|
208
208
|
const stored = ctx.state.rm.apps.get(appId);
|
|
209
209
|
ctx.expect(stored).toBeDefined();
|
|
210
210
|
ctx.expect(stored.pid).toBe(process.pid);
|
|
@@ -219,7 +219,7 @@ module.exports = defineCases({
|
|
|
219
219
|
{
|
|
220
220
|
name: 'heartbeat: idempotent upsert (1 app, request count climbs), timestamp advances',
|
|
221
221
|
run: async (ctx) => {
|
|
222
|
-
const rm = ctx.
|
|
222
|
+
const rm = ctx.omega.restartManager;
|
|
223
223
|
const before = ctx.state.rm.counts.register;
|
|
224
224
|
|
|
225
225
|
await rm._heartbeatTick();
|
|
@@ -233,7 +233,7 @@ module.exports = defineCases({
|
|
|
233
233
|
{
|
|
234
234
|
name: 'quit flush: capped deregister lands under the 1s budget',
|
|
235
235
|
run: async (ctx) => {
|
|
236
|
-
const rm = ctx.
|
|
236
|
+
const rm = ctx.omega.restartManager;
|
|
237
237
|
const started = Date.now();
|
|
238
238
|
await rm._quitFlush();
|
|
239
239
|
ctx.expect(Date.now() - started).toBeLessThan(1000 + 250);
|
|
@@ -245,9 +245,9 @@ module.exports = defineCases({
|
|
|
245
245
|
name: '_handleBeforeQuit: not-registered path returns without touching the event',
|
|
246
246
|
run: (ctx) => {
|
|
247
247
|
// Only the safe branch is drivable in the harness (the flush branch ends
|
|
248
|
-
// in
|
|
248
|
+
// in omega.quit which would kill the test Electron). _quitFlush itself
|
|
249
249
|
// is proven above.
|
|
250
|
-
const rm = ctx.
|
|
250
|
+
const rm = ctx.omega.restartManager;
|
|
251
251
|
rm._registered = false;
|
|
252
252
|
rm._quitFlushed = false;
|
|
253
253
|
let prevented = false;
|
|
@@ -258,7 +258,7 @@ module.exports = defineCases({
|
|
|
258
258
|
{
|
|
259
259
|
name: 'deregister round-trip: fixture saw { id, pid }',
|
|
260
260
|
run: async (ctx) => {
|
|
261
|
-
const rm = ctx.
|
|
261
|
+
const rm = ctx.omega.restartManager;
|
|
262
262
|
await rm.register();
|
|
263
263
|
ctx.expect(ctx.state.rm.apps.size).toBe(1);
|
|
264
264
|
|
|
@@ -271,7 +271,7 @@ module.exports = defineCases({
|
|
|
271
271
|
{
|
|
272
272
|
name: 'dead server: register resolves false, lastError set, no spawn in testing',
|
|
273
273
|
run: async (ctx) => {
|
|
274
|
-
const rm = ctx.
|
|
274
|
+
const rm = ctx.omega.restartManager;
|
|
275
275
|
// Grab a port that WAS listening and now is not.
|
|
276
276
|
const throwaway = await startContractServer();
|
|
277
277
|
const deadPort = throwaway.port;
|
|
@@ -286,7 +286,7 @@ module.exports = defineCases({
|
|
|
286
286
|
{
|
|
287
287
|
name: 'smart existence: installed app on disk short-circuits before any network',
|
|
288
288
|
run: async (ctx) => {
|
|
289
|
-
const rm = ctx.
|
|
289
|
+
const rm = ctx.omega.restartManager;
|
|
290
290
|
const appPath = protocol.getInstalledAppPath(rm._root, process.platform);
|
|
291
291
|
fs.mkdirSync(appPath, { recursive: true });
|
|
292
292
|
try {
|
|
@@ -301,7 +301,7 @@ module.exports = defineCases({
|
|
|
301
301
|
{
|
|
302
302
|
name: 'not installed in testing: ensureInstalled refuses network and returns false',
|
|
303
303
|
run: async (ctx) => {
|
|
304
|
-
const rm = ctx.
|
|
304
|
+
const rm = ctx.omega.restartManager;
|
|
305
305
|
if (process.env.TEST_EXTENDED_MODE) return ctx.skip('extended mode allows the real download');
|
|
306
306
|
const ok = await rm.ensureInstalled();
|
|
307
307
|
ctx.expect(ok).toBe(false);
|
|
@@ -312,7 +312,7 @@ module.exports = defineCases({
|
|
|
312
312
|
run: async (ctx) => {
|
|
313
313
|
if (!process.env.TEST_EXTENDED_MODE) return ctx.skip('requires TEST_EXTENDED_MODE (live GitHub)');
|
|
314
314
|
const install = require('../../../lib/restart-manager/install.js');
|
|
315
|
-
const rm = ctx.
|
|
315
|
+
const rm = ctx.omega.restartManager;
|
|
316
316
|
try {
|
|
317
317
|
const feed = await install.fetchFeed(rm._feed, process.platform);
|
|
318
318
|
const artifact = install.pickArtifact(feed, process.platform, process.arch);
|