@omega.js/desktop 0.51.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 +18 -13
- 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 +145 -48
- 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/.github/workflows/build.yml +2 -0
- 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/runner/job-started.js +1 -1
- 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 +612 -5
- 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 +13 -12
- package/dist/vendor/config/load.js +1 -2
- package/dist/vendor/config/platforms.js +1 -1
- package/dist/vendor/config/repo.js +24 -0
- 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/brand-version.js +162 -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/deploy.js +64 -4
- package/dist/vendor/devkit/git-remote.js +78 -1
- package/dist/vendor/devkit/local.js +53 -3
- package/dist/vendor/devkit/lockfile.js +127 -0
- package/dist/vendor/devkit/merge-line-files.js +2 -3
- package/dist/vendor/devkit/pack-local.js +4 -7
- package/dist/vendor/devkit/preludes/origin-heal.js +35 -49
- package/dist/vendor/devkit/target-secrets.js +34 -45
- 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 +39 -28
- 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/releasing.md +4 -2
- package/docs/remote-config.md +9 -9
- package/docs/remote-scripts.md +12 -12
- package/docs/restart-manager.md +8 -8
- package/docs/runner.md +12 -10
- package/docs/sentry.md +4 -4
- package/docs/shared/analytics.md +1 -1
- package/docs/shared/brands.md +1 -1
- package/docs/shared/breaking-changes.md +79 -13
- package/docs/shared/config.md +24 -21
- package/docs/shared/deploys.md +30 -7
- package/docs/shared/local-dev.md +5 -3
- 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/signing.md +1 -1
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Tests for src/utils/url-helpers.js — getFunctionsUrl / getApiUrl / getWebsiteUrl —
|
|
2
2
|
// plus the getEnvironment() resolution they depend on (getEnvironment itself is the
|
|
3
3
|
// SSOT defined in src/utils/mode-helpers.js; these tests exercise it through the
|
|
4
|
-
//
|
|
5
|
-
// The
|
|
4
|
+
// omega instance because the URL helpers route through `this.config` and `this.getEnvironment()`).
|
|
5
|
+
// The instance (already bootstrapped by the test harness) is the natural object under test.
|
|
6
6
|
|
|
7
7
|
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
8
8
|
const { CLASSIC_PORTS, CLASSIC_DEV_ORIGIN } = require('../../../vendor/config/index.js');
|
|
@@ -13,11 +13,11 @@ const { CLASSIC_PORTS, CLASSIC_DEV_ORIGIN } = require('../../../vendor/config/in
|
|
|
13
13
|
// bakes the classic map as the FLOOR of the resolved one, so the classics reach
|
|
14
14
|
// these helpers the way they reach a shipped dev build, from @omega.js/config,
|
|
15
15
|
// and no copy of the numbers lives in this file or in url-helpers.js.
|
|
16
|
-
function withClassicBakedPorts(
|
|
17
|
-
const original =
|
|
18
|
-
|
|
16
|
+
function withClassicBakedPorts(omega, fn) {
|
|
17
|
+
const original = omega.config.dev;
|
|
18
|
+
omega.config.dev = { ports: { ...CLASSIC_PORTS } };
|
|
19
19
|
try { return fn(); } finally {
|
|
20
|
-
if (original !== undefined)
|
|
20
|
+
if (original !== undefined) omega.config.dev = original; else delete omega.config.dev;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -36,50 +36,50 @@ module.exports = defineCases({
|
|
|
36
36
|
// app.isPackaged / OMEGA_BUILD_MODE / NODE_ENV sniffs.
|
|
37
37
|
name: 'getEnvironment: the process input, then the baked config.environment',
|
|
38
38
|
run: (ctx) => {
|
|
39
|
-
const
|
|
40
|
-
const origConfigEnv =
|
|
39
|
+
const omega = ctx.omega;
|
|
40
|
+
const origConfigEnv = omega.config.environment;
|
|
41
41
|
const origVar = process.env.OMEGA_ENVIRONMENT;
|
|
42
42
|
try {
|
|
43
43
|
// The lane's variable is the answer wherever it exists.
|
|
44
|
-
|
|
44
|
+
omega.config.environment = 'production';
|
|
45
45
|
for (const name of ['development', 'testing', 'production']) {
|
|
46
46
|
process.env.OMEGA_ENVIRONMENT = name;
|
|
47
|
-
ctx.expect(
|
|
47
|
+
ctx.expect(omega.getEnvironment()).toBe(name);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// With no variable, the artifact's own baked word answers.
|
|
51
51
|
delete process.env.OMEGA_ENVIRONMENT;
|
|
52
52
|
for (const name of ['development', 'testing', 'production']) {
|
|
53
|
-
|
|
54
|
-
ctx.expect(
|
|
53
|
+
omega.config.environment = name;
|
|
54
|
+
ctx.expect(omega.getEnvironment()).toBe(name);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Neither is a loud error, never a default.
|
|
58
|
-
delete
|
|
58
|
+
delete omega.config.environment;
|
|
59
59
|
let threw;
|
|
60
|
-
try {
|
|
60
|
+
try { omega.getEnvironment(); } catch (e) { threw = e; }
|
|
61
61
|
ctx.expect(threw).toBeDefined();
|
|
62
62
|
ctx.expect(threw.message).toMatch(/OMEGA_ENVIRONMENT/);
|
|
63
63
|
} finally {
|
|
64
|
-
if (origConfigEnv !== undefined)
|
|
64
|
+
if (origConfigEnv !== undefined) omega.config.environment = origConfigEnv; else delete omega.config.environment;
|
|
65
65
|
if (origVar !== undefined) process.env.OMEGA_ENVIRONMENT = origVar; else delete process.env.OMEGA_ENVIRONMENT;
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
// The three checks DERIVE from getEnvironment(), on the REAL main-process
|
|
71
|
-
//
|
|
71
|
+
// omega instance, so they can never disagree with it.
|
|
72
72
|
name: 'the three is*() checks derive from it, and exactly one is true',
|
|
73
73
|
run: (ctx) => {
|
|
74
|
-
const
|
|
74
|
+
const omega = ctx.omega;
|
|
75
75
|
const origVar = process.env.OMEGA_ENVIRONMENT;
|
|
76
76
|
try {
|
|
77
77
|
for (const name of ['development', 'testing', 'production']) {
|
|
78
78
|
process.env.OMEGA_ENVIRONMENT = name;
|
|
79
|
-
ctx.expect(
|
|
80
|
-
ctx.expect(
|
|
81
|
-
ctx.expect(
|
|
82
|
-
ctx.expect([
|
|
79
|
+
ctx.expect(omega.isDevelopment()).toBe(name === 'development');
|
|
80
|
+
ctx.expect(omega.isTesting()).toBe(name === 'testing');
|
|
81
|
+
ctx.expect(omega.isProduction()).toBe(name === 'production');
|
|
82
|
+
ctx.expect([omega.isDevelopment(), omega.isTesting(), omega.isProduction()].filter(Boolean).length).toBe(1);
|
|
83
83
|
}
|
|
84
84
|
} finally {
|
|
85
85
|
if (origVar !== undefined) process.env.OMEGA_ENVIRONMENT = origVar; else delete process.env.OMEGA_ENVIRONMENT;
|
|
@@ -89,44 +89,44 @@ module.exports = defineCases({
|
|
|
89
89
|
{
|
|
90
90
|
name: 'getFunctionsUrl: dev returns localhost:5001/<projectId>/us-central1',
|
|
91
91
|
run: (ctx) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const orig =
|
|
96
|
-
|
|
92
|
+
const omega = ctx.omega;
|
|
93
|
+
omega.config.cloud = omega.config.cloud || {};
|
|
94
|
+
omega.config.cloud.config = omega.config.cloud.config || {};
|
|
95
|
+
const orig = omega.config.cloud.config.projectId;
|
|
96
|
+
omega.config.cloud.config.projectId = 'demo-app';
|
|
97
97
|
try {
|
|
98
|
-
withClassicBakedPorts(
|
|
99
|
-
ctx.expect(
|
|
98
|
+
withClassicBakedPorts(omega, () => {
|
|
99
|
+
ctx.expect(omega.getFunctionsUrl('development')).toBe('http://localhost:5001/demo-app/us-central1');
|
|
100
100
|
});
|
|
101
|
-
} finally {
|
|
101
|
+
} finally { omega.config.cloud.config.projectId = orig; }
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
name: 'getFunctionsUrl: prod returns us-central1-<projectId>.cloudfunctions.net',
|
|
106
106
|
run: (ctx) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const orig =
|
|
111
|
-
|
|
107
|
+
const omega = ctx.omega;
|
|
108
|
+
omega.config.cloud = omega.config.cloud || {};
|
|
109
|
+
omega.config.cloud.config = omega.config.cloud.config || {};
|
|
110
|
+
const orig = omega.config.cloud.config.projectId;
|
|
111
|
+
omega.config.cloud.config.projectId = 'demo-app';
|
|
112
112
|
try {
|
|
113
|
-
ctx.expect(
|
|
114
|
-
} finally {
|
|
113
|
+
ctx.expect(omega.getFunctionsUrl('production')).toBe('https://us-central1-demo-app.cloudfunctions.net');
|
|
114
|
+
} finally { omega.config.cloud.config.projectId = orig; }
|
|
115
115
|
},
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
name: 'getFunctionsUrl: throws when projectId missing',
|
|
119
119
|
run: (ctx) => {
|
|
120
|
-
const
|
|
121
|
-
const orig =
|
|
122
|
-
if (
|
|
120
|
+
const omega = ctx.omega;
|
|
121
|
+
const orig = omega.config.cloud?.config?.projectId;
|
|
122
|
+
if (omega.config.cloud?.config) delete omega.config.cloud.config.projectId;
|
|
123
123
|
try {
|
|
124
124
|
let threw;
|
|
125
|
-
try {
|
|
125
|
+
try { omega.getFunctionsUrl('production'); } catch (e) { threw = e; }
|
|
126
126
|
ctx.expect(threw).toBeDefined();
|
|
127
127
|
ctx.expect(threw.message).toMatch(/cloud\.config\.projectId/);
|
|
128
128
|
} finally {
|
|
129
|
-
if (orig !== undefined)
|
|
129
|
+
if (orig !== undefined) omega.config.cloud.config.projectId = orig;
|
|
130
130
|
}
|
|
131
131
|
},
|
|
132
132
|
},
|
|
@@ -138,8 +138,8 @@ module.exports = defineCases({
|
|
|
138
138
|
delete process.env.OMEGA_HTTPS_PORT;
|
|
139
139
|
delete process.env.OMEGA_HOSTING_PORT;
|
|
140
140
|
try {
|
|
141
|
-
withClassicBakedPorts(ctx.
|
|
142
|
-
ctx.expect(ctx.
|
|
141
|
+
withClassicBakedPorts(ctx.omega, () => {
|
|
142
|
+
ctx.expect(ctx.omega.getApiUrl('development')).toBe('http://localhost:5002');
|
|
143
143
|
});
|
|
144
144
|
} finally {
|
|
145
145
|
if (origHttps !== undefined) process.env.OMEGA_HTTPS_PORT = origHttps;
|
|
@@ -157,8 +157,8 @@ module.exports = defineCases({
|
|
|
157
157
|
delete process.env.OMEGA_HTTPS_PORT;
|
|
158
158
|
delete process.env.OMEGA_HOSTING_PORT;
|
|
159
159
|
try {
|
|
160
|
-
withClassicBakedPorts(ctx.
|
|
161
|
-
ctx.expect(ctx.
|
|
160
|
+
withClassicBakedPorts(ctx.omega, () => {
|
|
161
|
+
ctx.expect(ctx.omega.getApiUrl('testing')).toBe('http://localhost:5002');
|
|
162
162
|
});
|
|
163
163
|
} finally {
|
|
164
164
|
if (origHttps !== undefined) process.env.OMEGA_HTTPS_PORT = origHttps;
|
|
@@ -172,15 +172,15 @@ module.exports = defineCases({
|
|
|
172
172
|
// published OMEGA_HOSTING_PORT is plain http to the hosting emulator.
|
|
173
173
|
name: 'getApiUrl: dev follows OMEGA_HTTPS_PORT (https) then OMEGA_HOSTING_PORT (http)',
|
|
174
174
|
run: (ctx) => {
|
|
175
|
-
const
|
|
175
|
+
const omega = ctx.omega;
|
|
176
176
|
const origHttps = process.env.OMEGA_HTTPS_PORT;
|
|
177
177
|
const origHosting = process.env.OMEGA_HOSTING_PORT;
|
|
178
178
|
try {
|
|
179
179
|
process.env.OMEGA_HOSTING_PORT = '5099';
|
|
180
180
|
delete process.env.OMEGA_HTTPS_PORT;
|
|
181
|
-
ctx.expect(
|
|
181
|
+
ctx.expect(omega.getApiUrl('development')).toBe('http://localhost:5099');
|
|
182
182
|
process.env.OMEGA_HTTPS_PORT = '5443';
|
|
183
|
-
ctx.expect(
|
|
183
|
+
ctx.expect(omega.getApiUrl('development')).toBe('https://localhost:5443');
|
|
184
184
|
} finally {
|
|
185
185
|
if (origHttps !== undefined) process.env.OMEGA_HTTPS_PORT = origHttps; else delete process.env.OMEGA_HTTPS_PORT;
|
|
186
186
|
if (origHosting !== undefined) process.env.OMEGA_HOSTING_PORT = origHosting; else delete process.env.OMEGA_HOSTING_PORT;
|
|
@@ -190,25 +190,25 @@ module.exports = defineCases({
|
|
|
190
190
|
{
|
|
191
191
|
// #745: the baked `dev.ports` map (written by the bundle task from the
|
|
192
192
|
// sibling backend's ports file) is the second channel, behind the env
|
|
193
|
-
// and ahead of the classics, on the REAL main-process
|
|
193
|
+
// and ahead of the classics, on the REAL main-process omega shape.
|
|
194
194
|
name: 'getApiUrl: dev follows the baked dev.ports map when no env is published',
|
|
195
195
|
run: (ctx) => {
|
|
196
|
-
const
|
|
197
|
-
const origDev =
|
|
196
|
+
const omega = ctx.omega;
|
|
197
|
+
const origDev = omega.config.dev;
|
|
198
198
|
const origHttps = process.env.OMEGA_HTTPS_PORT;
|
|
199
199
|
const origHosting = process.env.OMEGA_HOSTING_PORT;
|
|
200
200
|
try {
|
|
201
201
|
delete process.env.OMEGA_HTTPS_PORT;
|
|
202
202
|
delete process.env.OMEGA_HOSTING_PORT;
|
|
203
|
-
|
|
204
|
-
ctx.expect(
|
|
205
|
-
|
|
206
|
-
ctx.expect(
|
|
203
|
+
omega.config.dev = { ports: { hosting: 5012 } };
|
|
204
|
+
ctx.expect(omega.getApiUrl('development')).toBe('http://localhost:5012');
|
|
205
|
+
omega.config.dev = { ports: { hosting: 5012, https: 5003 } };
|
|
206
|
+
ctx.expect(omega.getApiUrl('development')).toBe('https://localhost:5003');
|
|
207
207
|
process.env.OMEGA_HOSTING_PORT = '5099';
|
|
208
|
-
delete
|
|
209
|
-
ctx.expect(
|
|
208
|
+
delete omega.config.dev.ports.https;
|
|
209
|
+
ctx.expect(omega.getApiUrl('development')).toBe('http://localhost:5099');
|
|
210
210
|
} finally {
|
|
211
|
-
if (origDev !== undefined)
|
|
211
|
+
if (origDev !== undefined) omega.config.dev = origDev; else delete omega.config.dev;
|
|
212
212
|
if (origHttps !== undefined) process.env.OMEGA_HTTPS_PORT = origHttps; else delete process.env.OMEGA_HTTPS_PORT;
|
|
213
213
|
if (origHosting !== undefined) process.env.OMEGA_HOSTING_PORT = origHosting; else delete process.env.OMEGA_HOSTING_PORT;
|
|
214
214
|
}
|
|
@@ -219,36 +219,36 @@ module.exports = defineCases({
|
|
|
219
219
|
// the API base must come from brand.url, never authDomain.
|
|
220
220
|
name: 'getApiUrl: prod returns api.<brand.url host>, never api.<authDomain>',
|
|
221
221
|
run: (ctx) => {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const origUrl =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const origAuth =
|
|
229
|
-
|
|
222
|
+
const omega = ctx.omega;
|
|
223
|
+
omega.config.brand = omega.config.brand || {};
|
|
224
|
+
const origUrl = omega.config.brand.url;
|
|
225
|
+
omega.config.brand.url = 'https://demo-app.example.com';
|
|
226
|
+
omega.config.cloud = omega.config.cloud || {};
|
|
227
|
+
omega.config.cloud.config = omega.config.cloud.config || {};
|
|
228
|
+
const origAuth = omega.config.cloud.config.authDomain;
|
|
229
|
+
omega.config.cloud.config.authDomain = 'demo-app.firebaseapp.com';
|
|
230
230
|
try {
|
|
231
|
-
ctx.expect(
|
|
231
|
+
ctx.expect(omega.getApiUrl('production')).toBe('https://api.demo-app.example.com');
|
|
232
232
|
} finally {
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
omega.config.brand.url = origUrl;
|
|
234
|
+
omega.config.cloud.config.authDomain = origAuth;
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
name: 'getApiUrl: throws when brand.url missing in prod',
|
|
240
240
|
run: (ctx) => {
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
const orig =
|
|
244
|
-
delete
|
|
241
|
+
const omega = ctx.omega;
|
|
242
|
+
omega.config.brand = omega.config.brand || {};
|
|
243
|
+
const orig = omega.config.brand.url;
|
|
244
|
+
delete omega.config.brand.url;
|
|
245
245
|
try {
|
|
246
246
|
let threw;
|
|
247
|
-
try {
|
|
247
|
+
try { omega.getApiUrl('production'); } catch (e) { threw = e; }
|
|
248
248
|
ctx.expect(threw).toBeDefined();
|
|
249
249
|
ctx.expect(threw.message).toMatch(/brand\.url/);
|
|
250
250
|
} finally {
|
|
251
|
-
if (orig !== undefined)
|
|
251
|
+
if (orig !== undefined) omega.config.brand.url = orig;
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
254
|
},
|
|
@@ -258,8 +258,8 @@ module.exports = defineCases({
|
|
|
258
258
|
const orig = process.env.OMEGA_WEBSITE_PORT;
|
|
259
259
|
delete process.env.OMEGA_WEBSITE_PORT;
|
|
260
260
|
try {
|
|
261
|
-
withClassicBakedPorts(ctx.
|
|
262
|
-
ctx.expect(ctx.
|
|
261
|
+
withClassicBakedPorts(ctx.omega, () => {
|
|
262
|
+
ctx.expect(ctx.omega.getWebsiteUrl('development')).toBe('https://localhost:4000');
|
|
263
263
|
});
|
|
264
264
|
} finally {
|
|
265
265
|
if (orig !== undefined) process.env.OMEGA_WEBSITE_PORT = orig;
|
|
@@ -272,7 +272,7 @@ module.exports = defineCases({
|
|
|
272
272
|
const orig = process.env.OMEGA_WEBSITE_PORT;
|
|
273
273
|
try {
|
|
274
274
|
process.env.OMEGA_WEBSITE_PORT = '4001';
|
|
275
|
-
ctx.expect(ctx.
|
|
275
|
+
ctx.expect(ctx.omega.getWebsiteUrl('development')).toBe('https://localhost:4001');
|
|
276
276
|
} finally {
|
|
277
277
|
if (orig !== undefined) process.env.OMEGA_WEBSITE_PORT = orig; else delete process.env.OMEGA_WEBSITE_PORT;
|
|
278
278
|
}
|
|
@@ -281,19 +281,19 @@ module.exports = defineCases({
|
|
|
281
281
|
{
|
|
282
282
|
// #747: the baked `dev.origin` (the live website's published origin,
|
|
283
283
|
// scheme included) is the complete fact and outranks the env port, on
|
|
284
|
-
// the REAL main-process
|
|
284
|
+
// the REAL main-process omega shape; getAuthUrl rides it by construction.
|
|
285
285
|
name: 'getWebsiteUrl: dev follows the baked dev.origin over OMEGA_WEBSITE_PORT',
|
|
286
286
|
run: (ctx) => {
|
|
287
|
-
const
|
|
288
|
-
const origDev =
|
|
287
|
+
const omega = ctx.omega;
|
|
288
|
+
const origDev = omega.config.dev;
|
|
289
289
|
const origPort = process.env.OMEGA_WEBSITE_PORT;
|
|
290
290
|
try {
|
|
291
291
|
process.env.OMEGA_WEBSITE_PORT = '4001';
|
|
292
|
-
|
|
293
|
-
ctx.expect(
|
|
294
|
-
ctx.expect(new URL(
|
|
292
|
+
omega.config.dev = { origin: 'https://localhost:4123' };
|
|
293
|
+
ctx.expect(omega.getWebsiteUrl('development')).toBe('https://localhost:4123');
|
|
294
|
+
ctx.expect(new URL(omega.getAuthUrl('development')).origin).toBe('https://localhost:4123');
|
|
295
295
|
} finally {
|
|
296
|
-
if (origDev !== undefined)
|
|
296
|
+
if (origDev !== undefined) omega.config.dev = origDev; else delete omega.config.dev;
|
|
297
297
|
if (origPort !== undefined) process.env.OMEGA_WEBSITE_PORT = origPort; else delete process.env.OMEGA_WEBSITE_PORT;
|
|
298
298
|
}
|
|
299
299
|
},
|
|
@@ -301,28 +301,28 @@ module.exports = defineCases({
|
|
|
301
301
|
{
|
|
302
302
|
name: 'getWebsiteUrl: prod returns config.brand.url',
|
|
303
303
|
run: (ctx) => {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const orig =
|
|
307
|
-
|
|
304
|
+
const omega = ctx.omega;
|
|
305
|
+
omega.config.brand = omega.config.brand || {};
|
|
306
|
+
const orig = omega.config.brand.url;
|
|
307
|
+
omega.config.brand.url = 'https://example.com';
|
|
308
308
|
try {
|
|
309
|
-
ctx.expect(
|
|
310
|
-
} finally {
|
|
309
|
+
ctx.expect(omega.getWebsiteUrl('production')).toBe('https://example.com');
|
|
310
|
+
} finally { omega.config.brand.url = orig; }
|
|
311
311
|
},
|
|
312
312
|
},
|
|
313
313
|
{
|
|
314
314
|
name: 'getWebsiteUrl: throws in prod when brand.url is missing',
|
|
315
315
|
run: (ctx) => {
|
|
316
|
-
const
|
|
317
|
-
const orig =
|
|
318
|
-
if (
|
|
316
|
+
const omega = ctx.omega;
|
|
317
|
+
const orig = omega.config.brand?.url;
|
|
318
|
+
if (omega.config.brand) delete omega.config.brand.url;
|
|
319
319
|
try {
|
|
320
320
|
let threw;
|
|
321
|
-
try {
|
|
321
|
+
try { omega.getWebsiteUrl('production'); } catch (e) { threw = e; }
|
|
322
322
|
ctx.expect(threw).toBeDefined();
|
|
323
323
|
ctx.expect(threw.message).toMatch(/brand\.url/);
|
|
324
324
|
} finally {
|
|
325
|
-
if (orig !== undefined)
|
|
325
|
+
if (orig !== undefined) omega.config.brand.url = orig;
|
|
326
326
|
}
|
|
327
327
|
},
|
|
328
328
|
},
|
|
@@ -331,13 +331,13 @@ module.exports = defineCases({
|
|
|
331
331
|
// (searchParams round-trip), not by string-matching encodings.
|
|
332
332
|
name: 'getAuthUrl: chains /signin → /token → <brand.id>://auth/token (dev)',
|
|
333
333
|
run: (ctx) => {
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
const origId =
|
|
337
|
-
|
|
334
|
+
const omega = ctx.omega;
|
|
335
|
+
omega.config.brand = omega.config.brand || {};
|
|
336
|
+
const origId = omega.config.brand.id;
|
|
337
|
+
omega.config.brand.id = 'demo';
|
|
338
338
|
try {
|
|
339
|
-
withClassicBakedPorts(
|
|
340
|
-
const url = new URL(
|
|
339
|
+
withClassicBakedPorts(omega, () => {
|
|
340
|
+
const url = new URL(omega.getAuthUrl('development'));
|
|
341
341
|
ctx.expect(url.origin).toBe('https://localhost:4000');
|
|
342
342
|
ctx.expect(url.pathname).toBe('/signin');
|
|
343
343
|
const tokenUrl = new URL(url.searchParams.get('authReturnUrl'));
|
|
@@ -346,29 +346,29 @@ module.exports = defineCases({
|
|
|
346
346
|
ctx.expect(tokenUrl.searchParams.get('authReturnUrl')).toBe('demo://auth/token');
|
|
347
347
|
});
|
|
348
348
|
} finally {
|
|
349
|
-
if (origId !== undefined)
|
|
349
|
+
if (origId !== undefined) omega.config.brand.id = origId; else delete omega.config.brand.id;
|
|
350
350
|
}
|
|
351
351
|
},
|
|
352
352
|
},
|
|
353
353
|
{
|
|
354
354
|
name: 'getAuthUrl: prod rides brand.url',
|
|
355
355
|
run: (ctx) => {
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
const origId =
|
|
359
|
-
const origUrl =
|
|
360
|
-
|
|
361
|
-
|
|
356
|
+
const omega = ctx.omega;
|
|
357
|
+
omega.config.brand = omega.config.brand || {};
|
|
358
|
+
const origId = omega.config.brand.id;
|
|
359
|
+
const origUrl = omega.config.brand.url;
|
|
360
|
+
omega.config.brand.id = 'demo';
|
|
361
|
+
omega.config.brand.url = 'https://example.com';
|
|
362
362
|
try {
|
|
363
|
-
const url = new URL(
|
|
363
|
+
const url = new URL(omega.getAuthUrl('production'));
|
|
364
364
|
ctx.expect(url.origin).toBe('https://example.com');
|
|
365
365
|
ctx.expect(url.pathname).toBe('/signin');
|
|
366
366
|
const tokenUrl = new URL(url.searchParams.get('authReturnUrl'));
|
|
367
367
|
ctx.expect(tokenUrl.origin).toBe('https://example.com');
|
|
368
368
|
ctx.expect(tokenUrl.searchParams.get('authReturnUrl')).toBe('demo://auth/token');
|
|
369
369
|
} finally {
|
|
370
|
-
if (origId !== undefined)
|
|
371
|
-
if (origUrl !== undefined)
|
|
370
|
+
if (origId !== undefined) omega.config.brand.id = origId; else delete omega.config.brand.id;
|
|
371
|
+
if (origUrl !== undefined) omega.config.brand.url = origUrl; else delete omega.config.brand.url;
|
|
372
372
|
}
|
|
373
373
|
},
|
|
374
374
|
},
|
|
@@ -376,38 +376,38 @@ module.exports = defineCases({
|
|
|
376
376
|
// The dev loopback return channel (lib/auth-flow.js) swaps the final hop.
|
|
377
377
|
name: 'getAuthUrl: optional returnUrl overrides the final hop',
|
|
378
378
|
run: (ctx) => {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
const origId =
|
|
382
|
-
|
|
379
|
+
const omega = ctx.omega;
|
|
380
|
+
omega.config.brand = omega.config.brand || {};
|
|
381
|
+
const origId = omega.config.brand.id;
|
|
382
|
+
omega.config.brand.id = 'demo';
|
|
383
383
|
try {
|
|
384
384
|
const loopback = 'http://127.0.0.1:49152/auth/token?state=abc';
|
|
385
|
-
withClassicBakedPorts(
|
|
386
|
-
const url = new URL(
|
|
385
|
+
withClassicBakedPorts(omega, () => {
|
|
386
|
+
const url = new URL(omega.getAuthUrl('development', loopback));
|
|
387
387
|
const tokenUrl = new URL(url.searchParams.get('authReturnUrl'));
|
|
388
388
|
ctx.expect(tokenUrl.pathname).toBe('/token');
|
|
389
389
|
ctx.expect(tokenUrl.searchParams.get('authReturnUrl')).toBe(loopback);
|
|
390
390
|
});
|
|
391
391
|
} finally {
|
|
392
|
-
if (origId !== undefined)
|
|
392
|
+
if (origId !== undefined) omega.config.brand.id = origId; else delete omega.config.brand.id;
|
|
393
393
|
}
|
|
394
394
|
},
|
|
395
395
|
},
|
|
396
396
|
{
|
|
397
397
|
name: 'getAuthUrl: throws when brand.id missing',
|
|
398
398
|
run: (ctx) => {
|
|
399
|
-
const
|
|
400
|
-
const orig =
|
|
401
|
-
if (
|
|
399
|
+
const omega = ctx.omega;
|
|
400
|
+
const orig = omega.config.brand?.id;
|
|
401
|
+
if (omega.config.brand) delete omega.config.brand.id;
|
|
402
402
|
try {
|
|
403
|
-
withClassicBakedPorts(
|
|
403
|
+
withClassicBakedPorts(omega, () => {
|
|
404
404
|
let threw;
|
|
405
|
-
try {
|
|
405
|
+
try { omega.getAuthUrl('development'); } catch (e) { threw = e; }
|
|
406
406
|
ctx.expect(threw).toBeDefined();
|
|
407
407
|
ctx.expect(threw.message).toMatch(/brand\.id/);
|
|
408
408
|
});
|
|
409
409
|
} finally {
|
|
410
|
-
if (orig !== undefined)
|
|
410
|
+
if (orig !== undefined) omega.config.brand.id = orig;
|
|
411
411
|
}
|
|
412
412
|
},
|
|
413
413
|
},
|
|
@@ -416,21 +416,21 @@ module.exports = defineCases({
|
|
|
416
416
|
// the one input (#817): whatever the lane named for this process.
|
|
417
417
|
name: 'getWebsiteUrl: respects the current environment when no arg passed',
|
|
418
418
|
run: (ctx) => {
|
|
419
|
-
const
|
|
419
|
+
const omega = ctx.omega;
|
|
420
420
|
const origVar = process.env.OMEGA_ENVIRONMENT;
|
|
421
|
-
|
|
422
|
-
const origUrl =
|
|
423
|
-
|
|
421
|
+
omega.config.brand = omega.config.brand || {};
|
|
422
|
+
const origUrl = omega.config.brand.url;
|
|
423
|
+
omega.config.brand.url = 'https://example.com';
|
|
424
424
|
try {
|
|
425
425
|
process.env.OMEGA_ENVIRONMENT = 'development';
|
|
426
|
-
withClassicBakedPorts(
|
|
427
|
-
ctx.expect(
|
|
426
|
+
withClassicBakedPorts(omega, () => {
|
|
427
|
+
ctx.expect(omega.getWebsiteUrl()).toBe('https://localhost:4000');
|
|
428
428
|
});
|
|
429
429
|
process.env.OMEGA_ENVIRONMENT = 'production';
|
|
430
|
-
ctx.expect(
|
|
430
|
+
ctx.expect(omega.getWebsiteUrl()).toBe('https://example.com');
|
|
431
431
|
} finally {
|
|
432
432
|
if (origVar !== undefined) process.env.OMEGA_ENVIRONMENT = origVar; else delete process.env.OMEGA_ENVIRONMENT;
|
|
433
|
-
|
|
433
|
+
omega.config.brand.url = origUrl;
|
|
434
434
|
}
|
|
435
435
|
},
|
|
436
436
|
},
|
|
@@ -6,9 +6,9 @@ const STORAGE_KEY = 'usage';
|
|
|
6
6
|
|
|
7
7
|
async function reinitWithSnapshot(ctx, snapshot) {
|
|
8
8
|
// Reset and re-init with a planted previous snapshot.
|
|
9
|
-
ctx.
|
|
10
|
-
ctx.
|
|
11
|
-
ctx.
|
|
9
|
+
ctx.omega.usage.shutdown();
|
|
10
|
+
ctx.omega.storage.set(STORAGE_KEY, snapshot);
|
|
11
|
+
ctx.omega.usage.initialize(ctx.omega);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
module.exports = defineCases({
|
|
@@ -16,28 +16,28 @@ module.exports = defineCases({
|
|
|
16
16
|
layer: 'main',
|
|
17
17
|
description: 'usage (main)',
|
|
18
18
|
cleanup: (ctx) => {
|
|
19
|
-
ctx.
|
|
20
|
-
ctx.
|
|
21
|
-
ctx.
|
|
19
|
+
ctx.omega.usage.shutdown();
|
|
20
|
+
ctx.omega.storage.set(STORAGE_KEY, null);
|
|
21
|
+
ctx.omega.usage.initialize(ctx.omega);
|
|
22
22
|
},
|
|
23
23
|
tests: [
|
|
24
24
|
{
|
|
25
|
-
name: 'usage module wired on
|
|
25
|
+
name: 'usage module wired on omega + initialized during boot',
|
|
26
26
|
run: (ctx) => {
|
|
27
|
-
ctx.expect(ctx.
|
|
28
|
-
ctx.expect(ctx.
|
|
27
|
+
ctx.expect(ctx.omega.usage).toBeDefined();
|
|
28
|
+
ctx.expect(ctx.omega.usage._initialized).toBe(true);
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
name: 'opens() returns at least 1 (this launch)',
|
|
33
33
|
run: (ctx) => {
|
|
34
|
-
ctx.expect(ctx.
|
|
34
|
+
ctx.expect(ctx.omega.usage.opens() >= 1).toBe(true);
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
name: 'hoursThisSession() is a small positive number',
|
|
39
39
|
run: (ctx) => {
|
|
40
|
-
const h = ctx.
|
|
40
|
+
const h = ctx.omega.usage.hoursThisSession();
|
|
41
41
|
ctx.expect(typeof h).toBe('number');
|
|
42
42
|
ctx.expect(h >= 0).toBe(true);
|
|
43
43
|
ctx.expect(h < 1).toBe(true); // tests run in seconds, not hours
|
|
@@ -48,14 +48,14 @@ module.exports = defineCases({
|
|
|
48
48
|
run: async (ctx) => {
|
|
49
49
|
// Plant a known starting state so this test isn't sensitive to whatever
|
|
50
50
|
// accumulated in the prior test's storage.
|
|
51
|
-
ctx.
|
|
52
|
-
ctx.
|
|
53
|
-
ctx.
|
|
54
|
-
const before = ctx.
|
|
51
|
+
ctx.omega.usage.shutdown();
|
|
52
|
+
ctx.omega.storage.set('usage', { opens: 5, hoursTotal: 0, installedAt: '2024-01-01T00:00:00Z', lastLaunchAt: null, lastQuitAt: null });
|
|
53
|
+
ctx.omega.usage.initialize(ctx.omega);
|
|
54
|
+
const before = ctx.omega.usage.opens();
|
|
55
55
|
ctx.expect(before).toBe(6); // 5 + this re-init
|
|
56
|
-
ctx.
|
|
57
|
-
ctx.
|
|
58
|
-
const after = ctx.
|
|
56
|
+
ctx.omega.usage.shutdown();
|
|
57
|
+
ctx.omega.usage.initialize(ctx.omega);
|
|
58
|
+
const after = ctx.omega.usage.opens();
|
|
59
59
|
ctx.expect(after).toBe(before + 1); // 7
|
|
60
60
|
},
|
|
61
61
|
},
|
|
@@ -73,10 +73,10 @@ module.exports = defineCases({
|
|
|
73
73
|
installedAt: '2024-01-01T00:00:00.000Z',
|
|
74
74
|
});
|
|
75
75
|
// After re-init we should have hoursTotal = 10 + 2 = 12 (within rounding).
|
|
76
|
-
const ht = ctx.
|
|
76
|
+
const ht = ctx.omega.usage.hoursTotal();
|
|
77
77
|
ctx.expect(ht > 11.9).toBe(true);
|
|
78
78
|
ctx.expect(ht < 12.1).toBe(true);
|
|
79
|
-
ctx.expect(ctx.
|
|
79
|
+
ctx.expect(ctx.omega.usage.opens()).toBe(6);
|
|
80
80
|
},
|
|
81
81
|
},
|
|
82
82
|
{
|
|
@@ -90,7 +90,7 @@ module.exports = defineCases({
|
|
|
90
90
|
installedAt: '2024-01-01T00:00:00.000Z',
|
|
91
91
|
});
|
|
92
92
|
// Should still be 5 — crashed sessions don't credit hours.
|
|
93
|
-
ctx.expect(ctx.
|
|
93
|
+
ctx.expect(ctx.omega.usage.hoursTotal()).toBe(5);
|
|
94
94
|
},
|
|
95
95
|
},
|
|
96
96
|
{
|
|
@@ -103,13 +103,13 @@ module.exports = defineCases({
|
|
|
103
103
|
lastLaunchAt: new Date().toISOString(),
|
|
104
104
|
lastQuitAt: null,
|
|
105
105
|
});
|
|
106
|
-
ctx.expect(ctx.
|
|
106
|
+
ctx.expect(ctx.omega.usage.installedAt()).toBe('2023-06-15T10:00:00.000Z');
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
name: 'toJSON includes opens, hoursTotal, hoursThisSession, installedAt',
|
|
111
111
|
run: (ctx) => {
|
|
112
|
-
const j = ctx.
|
|
112
|
+
const j = ctx.omega.usage.toJSON();
|
|
113
113
|
ctx.expect(typeof j.opens).toBe('number');
|
|
114
114
|
ctx.expect(typeof j.hoursTotal).toBe('number');
|
|
115
115
|
ctx.expect(typeof j.hoursThisSession).toBe('number');
|
|
@@ -119,8 +119,8 @@ module.exports = defineCases({
|
|
|
119
119
|
{
|
|
120
120
|
name: 'IPC handler desktop:usage:get returns the snapshot',
|
|
121
121
|
run: async (ctx) => {
|
|
122
|
-
const snap = await ctx.
|
|
123
|
-
ctx.expect(snap.opens).toBe(ctx.
|
|
122
|
+
const snap = await ctx.omega.ipc.invoke('desktop:usage:get');
|
|
123
|
+
ctx.expect(snap.opens).toBe(ctx.omega.usage.opens());
|
|
124
124
|
},
|
|
125
125
|
},
|
|
126
126
|
],
|