@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
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
// published, then composes OMEGA_WEBSITE_PORT / the baked port over https, then
|
|
12
12
|
// the classic dev origin ([#747](https://github.com/Omega-JS-Stack/omega/issues/747)).
|
|
13
13
|
//
|
|
14
|
-
// The last case pins the auth emulator port
|
|
14
|
+
// The last case pins the auth emulator port lib/auth.js connects a testing
|
|
15
15
|
// run to: the same three-step chain, off the same baked map.
|
|
16
16
|
|
|
17
17
|
const path = require('path');
|
|
18
18
|
|
|
19
19
|
const helpers = require(path.join(__dirname, '..', '..', '..', 'utils', 'url-helpers.js'));
|
|
20
|
-
const
|
|
20
|
+
const auth = require(path.join(__dirname, '..', '..', '..', 'lib', 'auth.js'));
|
|
21
21
|
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
22
22
|
|
|
23
23
|
function withEnv(overrides, fn) {
|
|
@@ -35,9 +35,9 @@ function withEnv(overrides, fn) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// The shape the helpers see at runtime:
|
|
38
|
+
// The shape the helpers see at runtime: an omega instance carrying the resolved config
|
|
39
39
|
// (OMEGA_BUILD_JSON.config, `dev` block and all) plus mode-helpers' getEnvironment().
|
|
40
|
-
function
|
|
40
|
+
function fakeOmega(environment, ports, origin) {
|
|
41
41
|
return {
|
|
42
42
|
getEnvironment: () => environment,
|
|
43
43
|
isTesting: () => environment === 'testing',
|
|
@@ -51,11 +51,11 @@ function fakeManager(environment, ports, origin) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// Run `fn` with
|
|
55
|
-
function
|
|
56
|
-
const original =
|
|
57
|
-
|
|
58
|
-
try { return fn(); } finally {
|
|
54
|
+
// Run `fn` with auth pointed at a stand-in instance, then put the real one back.
|
|
55
|
+
function withAuthOmega(omega, fn) {
|
|
56
|
+
const original = auth._omega;
|
|
57
|
+
auth._omega = omega;
|
|
58
|
+
try { return fn(); } finally { auth._omega = original; }
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// No env channel published: the state a packaged main process is in.
|
|
@@ -72,9 +72,11 @@ module.exports = defineCases({
|
|
|
72
72
|
description: 'utils/url-helpers: every local helper resolves env, then the baked dev.ports, then throws',
|
|
73
73
|
tests: [
|
|
74
74
|
{
|
|
75
|
-
|
|
75
|
+
// Plain functions the `Omega` classes call with themselves as `context`:
|
|
76
|
+
// no mixin onto a constructor any more
|
|
77
|
+
name: 'exports { getApiUrl, localPort, requiredPort } and no attachTo',
|
|
76
78
|
run: (ctx) => {
|
|
77
|
-
ctx.expect(
|
|
79
|
+
ctx.expect(helpers.attachTo).toBeUndefined();
|
|
78
80
|
ctx.expect(typeof helpers.getApiUrl).toBe('function');
|
|
79
81
|
ctx.expect(typeof helpers.localPort).toBe('function');
|
|
80
82
|
ctx.expect(typeof helpers.requiredPort).toBe('function');
|
|
@@ -84,8 +86,8 @@ module.exports = defineCases({
|
|
|
84
86
|
name: 'a BUMPED baked dev.ports.hosting is the api base in testing',
|
|
85
87
|
run: (ctx) => {
|
|
86
88
|
withEnv(NO_ENV, () => {
|
|
87
|
-
const
|
|
88
|
-
ctx.expect(helpers.getApiUrl
|
|
89
|
+
const omega = fakeOmega('testing', { hosting: 5012, auth: 9109 });
|
|
90
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('http://localhost:5012');
|
|
89
91
|
});
|
|
90
92
|
},
|
|
91
93
|
},
|
|
@@ -93,8 +95,8 @@ module.exports = defineCases({
|
|
|
93
95
|
name: 'a BUMPED baked dev.ports.hosting is the api base in development too',
|
|
94
96
|
run: (ctx) => {
|
|
95
97
|
withEnv(NO_ENV, () => {
|
|
96
|
-
const
|
|
97
|
-
ctx.expect(helpers.getApiUrl
|
|
98
|
+
const omega = fakeOmega('development', { hosting: 5012 });
|
|
99
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('http://localhost:5012');
|
|
98
100
|
});
|
|
99
101
|
},
|
|
100
102
|
},
|
|
@@ -102,8 +104,8 @@ module.exports = defineCases({
|
|
|
102
104
|
name: 'OMEGA_HOSTING_PORT wins over the baked value',
|
|
103
105
|
run: (ctx) => {
|
|
104
106
|
withEnv({ ...NO_ENV, OMEGA_HOSTING_PORT: '5022' }, () => {
|
|
105
|
-
const
|
|
106
|
-
ctx.expect(helpers.getApiUrl
|
|
107
|
+
const omega = fakeOmega('testing', { hosting: 5012 });
|
|
108
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('http://localhost:5022');
|
|
107
109
|
});
|
|
108
110
|
},
|
|
109
111
|
},
|
|
@@ -116,9 +118,9 @@ module.exports = defineCases({
|
|
|
116
118
|
run: (ctx) => {
|
|
117
119
|
withEnv(NO_ENV, () => {
|
|
118
120
|
for (const environment of ['testing', 'development']) {
|
|
119
|
-
ctx.expect(() => helpers.getApiUrl
|
|
121
|
+
ctx.expect(() => helpers.getApiUrl(fakeOmega(environment)))
|
|
120
122
|
.toThrow(/dev port for `hosting`/);
|
|
121
|
-
ctx.expect(() => helpers.getApiUrl
|
|
123
|
+
ctx.expect(() => helpers.getApiUrl(fakeOmega(environment)))
|
|
122
124
|
.toThrow(/bundle task/);
|
|
123
125
|
}
|
|
124
126
|
});
|
|
@@ -128,8 +130,8 @@ module.exports = defineCases({
|
|
|
128
130
|
name: 'OMEGA_HTTPS_PORT means the mkcert proxy is up: https, not hosting',
|
|
129
131
|
run: (ctx) => {
|
|
130
132
|
withEnv({ ...NO_ENV, OMEGA_HTTPS_PORT: '5003' }, () => {
|
|
131
|
-
const
|
|
132
|
-
ctx.expect(helpers.getApiUrl
|
|
133
|
+
const omega = fakeOmega('testing', { hosting: 5012 });
|
|
134
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('https://localhost:5003');
|
|
133
135
|
});
|
|
134
136
|
},
|
|
135
137
|
},
|
|
@@ -137,8 +139,8 @@ module.exports = defineCases({
|
|
|
137
139
|
name: 'a baked dev.ports.https does the same with no env published',
|
|
138
140
|
run: (ctx) => {
|
|
139
141
|
withEnv(NO_ENV, () => {
|
|
140
|
-
const
|
|
141
|
-
ctx.expect(helpers.getApiUrl
|
|
142
|
+
const omega = fakeOmega('testing', { https: 5003, hosting: 5443 });
|
|
143
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('https://localhost:5003');
|
|
142
144
|
});
|
|
143
145
|
},
|
|
144
146
|
},
|
|
@@ -146,8 +148,8 @@ module.exports = defineCases({
|
|
|
146
148
|
name: 'production ignores every local channel, giving api.<brand host>',
|
|
147
149
|
run: (ctx) => {
|
|
148
150
|
withEnv({ ...NO_ENV, OMEGA_HOSTING_PORT: '5022' }, () => {
|
|
149
|
-
const
|
|
150
|
-
ctx.expect(helpers.getApiUrl
|
|
151
|
+
const omega = fakeOmega('production', { hosting: 5012 });
|
|
152
|
+
ctx.expect(helpers.getApiUrl(omega)).toBe('https://api.playground.omegajs.dev');
|
|
151
153
|
});
|
|
152
154
|
},
|
|
153
155
|
},
|
|
@@ -155,8 +157,8 @@ module.exports = defineCases({
|
|
|
155
157
|
name: 'getFunctionsUrl: a BUMPED baked dev.ports.functions is the functions base',
|
|
156
158
|
run: (ctx) => {
|
|
157
159
|
withEnv(NO_ENV, () => {
|
|
158
|
-
const
|
|
159
|
-
ctx.expect(helpers.getFunctionsUrl
|
|
160
|
+
const omega = fakeOmega('development', { functions: 5011 });
|
|
161
|
+
ctx.expect(helpers.getFunctionsUrl(omega))
|
|
160
162
|
.toBe('http://localhost:5011/demo-app/us-central1');
|
|
161
163
|
});
|
|
162
164
|
},
|
|
@@ -165,8 +167,8 @@ module.exports = defineCases({
|
|
|
165
167
|
name: 'getFunctionsUrl: OMEGA_FUNCTIONS_PORT wins over the baked value',
|
|
166
168
|
run: (ctx) => {
|
|
167
169
|
withEnv({ ...NO_ENV, OMEGA_FUNCTIONS_PORT: '5021' }, () => {
|
|
168
|
-
const
|
|
169
|
-
ctx.expect(helpers.getFunctionsUrl
|
|
170
|
+
const omega = fakeOmega('testing', { functions: 5011 });
|
|
171
|
+
ctx.expect(helpers.getFunctionsUrl(omega))
|
|
170
172
|
.toBe('http://localhost:5021/demo-app/us-central1');
|
|
171
173
|
});
|
|
172
174
|
},
|
|
@@ -175,7 +177,7 @@ module.exports = defineCases({
|
|
|
175
177
|
name: 'getFunctionsUrl: neither channel → a throw naming the port (#834)',
|
|
176
178
|
run: (ctx) => {
|
|
177
179
|
withEnv(NO_ENV, () => {
|
|
178
|
-
ctx.expect(() => helpers.getFunctionsUrl
|
|
180
|
+
ctx.expect(() => helpers.getFunctionsUrl(fakeOmega('development')))
|
|
179
181
|
.toThrow(/dev port for `functions`/);
|
|
180
182
|
});
|
|
181
183
|
},
|
|
@@ -184,8 +186,8 @@ module.exports = defineCases({
|
|
|
184
186
|
name: 'getFunctionsUrl: production ignores every local channel',
|
|
185
187
|
run: (ctx) => {
|
|
186
188
|
withEnv({ ...NO_ENV, OMEGA_FUNCTIONS_PORT: '5021' }, () => {
|
|
187
|
-
const
|
|
188
|
-
ctx.expect(helpers.getFunctionsUrl
|
|
189
|
+
const omega = fakeOmega('production', { functions: 5011 });
|
|
190
|
+
ctx.expect(helpers.getFunctionsUrl(omega))
|
|
189
191
|
.toBe('https://us-central1-demo-app.cloudfunctions.net');
|
|
190
192
|
});
|
|
191
193
|
},
|
|
@@ -194,8 +196,8 @@ module.exports = defineCases({
|
|
|
194
196
|
name: 'getWebsiteUrl: a BUMPED baked dev.ports.website is the website base',
|
|
195
197
|
run: (ctx) => {
|
|
196
198
|
withEnv(NO_ENV, () => {
|
|
197
|
-
const
|
|
198
|
-
ctx.expect(helpers.getWebsiteUrl
|
|
199
|
+
const omega = fakeOmega('development', { website: 4001 });
|
|
200
|
+
ctx.expect(helpers.getWebsiteUrl(omega)).toBe('https://localhost:4001');
|
|
199
201
|
});
|
|
200
202
|
},
|
|
201
203
|
},
|
|
@@ -203,8 +205,8 @@ module.exports = defineCases({
|
|
|
203
205
|
name: 'getWebsiteUrl: OMEGA_WEBSITE_PORT wins over the baked value',
|
|
204
206
|
run: (ctx) => {
|
|
205
207
|
withEnv({ ...NO_ENV, OMEGA_WEBSITE_PORT: '4002' }, () => {
|
|
206
|
-
const
|
|
207
|
-
ctx.expect(helpers.getWebsiteUrl
|
|
208
|
+
const omega = fakeOmega('testing', { website: 4001 });
|
|
209
|
+
ctx.expect(helpers.getWebsiteUrl(omega)).toBe('https://localhost:4002');
|
|
208
210
|
});
|
|
209
211
|
},
|
|
210
212
|
},
|
|
@@ -212,7 +214,7 @@ module.exports = defineCases({
|
|
|
212
214
|
name: 'getWebsiteUrl: neither channel → a throw naming the port (#834)',
|
|
213
215
|
run: (ctx) => {
|
|
214
216
|
withEnv(NO_ENV, () => {
|
|
215
|
-
ctx.expect(() => helpers.getWebsiteUrl
|
|
217
|
+
ctx.expect(() => helpers.getWebsiteUrl(fakeOmega('development')))
|
|
216
218
|
.toThrow(/dev port for `website`/);
|
|
217
219
|
});
|
|
218
220
|
},
|
|
@@ -224,8 +226,8 @@ module.exports = defineCases({
|
|
|
224
226
|
name: 'getWebsiteUrl: a baked dev.origin wins over OMEGA_WEBSITE_PORT',
|
|
225
227
|
run: (ctx) => {
|
|
226
228
|
withEnv({ ...NO_ENV, OMEGA_WEBSITE_PORT: '4002' }, () => {
|
|
227
|
-
const
|
|
228
|
-
ctx.expect(helpers.getWebsiteUrl
|
|
229
|
+
const omega = fakeOmega('development', { website: 4001 }, 'https://localhost:4123');
|
|
230
|
+
ctx.expect(helpers.getWebsiteUrl(omega)).toBe('https://localhost:4123');
|
|
229
231
|
});
|
|
230
232
|
},
|
|
231
233
|
},
|
|
@@ -233,7 +235,7 @@ module.exports = defineCases({
|
|
|
233
235
|
name: 'getWebsiteUrl: OMEGA_WEBSITE_PORT with no baked origin composes over https',
|
|
234
236
|
run: (ctx) => {
|
|
235
237
|
withEnv({ ...NO_ENV, OMEGA_WEBSITE_PORT: '4321' }, () => {
|
|
236
|
-
ctx.expect(helpers.getWebsiteUrl
|
|
238
|
+
ctx.expect(helpers.getWebsiteUrl(fakeOmega('development'))).toBe('https://localhost:4321');
|
|
237
239
|
});
|
|
238
240
|
},
|
|
239
241
|
},
|
|
@@ -258,11 +260,8 @@ module.exports = defineCases({
|
|
|
258
260
|
name: 'getAuthUrl: dev builds /signin and /token on the https dev origin',
|
|
259
261
|
run: (ctx) => {
|
|
260
262
|
withEnv(NO_ENV, () => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const manager = fakeManager('development', { website: 4000 });
|
|
264
|
-
manager.getWebsiteUrl = helpers.getWebsiteUrl;
|
|
265
|
-
const url = new URL(helpers.getAuthUrl.call(manager));
|
|
263
|
+
const omega = fakeOmega('development', { website: 4000 });
|
|
264
|
+
const url = new URL(helpers.getAuthUrl(omega));
|
|
266
265
|
ctx.expect(url.origin).toBe('https://localhost:4000');
|
|
267
266
|
ctx.expect(url.pathname).toBe('/signin');
|
|
268
267
|
const tokenUrl = new URL(url.searchParams.get('authReturnUrl'));
|
|
@@ -276,31 +275,31 @@ module.exports = defineCases({
|
|
|
276
275
|
name: 'getWebsiteUrl: production ignores every local channel',
|
|
277
276
|
run: (ctx) => {
|
|
278
277
|
withEnv({ ...NO_ENV, OMEGA_WEBSITE_PORT: '4002' }, () => {
|
|
279
|
-
const
|
|
280
|
-
ctx.expect(helpers.getWebsiteUrl
|
|
278
|
+
const omega = fakeOmega('production', { website: 4001 });
|
|
279
|
+
ctx.expect(helpers.getWebsiteUrl(omega)).toBe('https://playground.omegajs.dev');
|
|
281
280
|
});
|
|
282
281
|
},
|
|
283
282
|
},
|
|
284
283
|
{
|
|
285
|
-
//
|
|
284
|
+
// lib/auth.js connects a TESTING run's auth to the emulator. Same chain:
|
|
286
285
|
// env, then the baked map, then classic 9099.
|
|
287
|
-
name: 'the auth emulator port rides the same chain (
|
|
286
|
+
name: 'the auth emulator port rides the same chain (lib/auth.js)',
|
|
288
287
|
run: (ctx) => {
|
|
289
288
|
withEnv({ OMEGA_AUTH_PORT: null }, () => {
|
|
290
|
-
|
|
291
|
-
ctx.expect(
|
|
289
|
+
withAuthOmega(fakeOmega('testing', { auth: 9109 }), () => {
|
|
290
|
+
ctx.expect(auth._authEmulatorPort()).toBe(9109);
|
|
292
291
|
});
|
|
293
292
|
// The classic 9099 used to answer here (#834): nothing identity-checks
|
|
294
293
|
// what holds that port, so a neighbouring project's emulator read as
|
|
295
294
|
// an auth mystery instead of a port problem.
|
|
296
|
-
|
|
297
|
-
ctx.expect(() =>
|
|
298
|
-
ctx.expect(() =>
|
|
295
|
+
withAuthOmega(fakeOmega('testing'), () => {
|
|
296
|
+
ctx.expect(() => auth._authEmulatorPort()).toThrow(/dev port for `auth`/);
|
|
297
|
+
ctx.expect(() => auth._authEmulatorPort()).toThrow(/bundle task/);
|
|
299
298
|
});
|
|
300
299
|
});
|
|
301
300
|
withEnv({ OMEGA_AUTH_PORT: '9119' }, () => {
|
|
302
|
-
|
|
303
|
-
ctx.expect(
|
|
301
|
+
withAuthOmega(fakeOmega('testing', { auth: 9109 }), () => {
|
|
302
|
+
ctx.expect(auth._authEmulatorPort()).toBe('9119');
|
|
304
303
|
});
|
|
305
304
|
});
|
|
306
305
|
},
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
const { validateConfig, runSchema, formatErrors, loadConfig } = require('../../../vendor/config/index.js');
|
|
8
8
|
|
|
9
9
|
const path = require('path');
|
|
10
|
-
const
|
|
10
|
+
const build = require('../../../build.js');
|
|
11
11
|
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
12
|
-
const root =
|
|
12
|
+
const root = build.getRootPath('main');
|
|
13
13
|
|
|
14
14
|
// Minimal "good" config — passes every required check.
|
|
15
15
|
const VALID = {
|
|
@@ -25,10 +25,10 @@ module.exports = defineCases({
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
// wave-5 F1: main.js must release the deep-link boot queue after full init.
|
|
28
|
-
name: 'main.js drains the deep-link boot queue via
|
|
28
|
+
name: 'main.js drains the deep-link boot queue via markOmegaReady()',
|
|
29
29
|
run: (ctx) => {
|
|
30
30
|
const source = fs.readFileSync(path.join(SRC, 'main.js'), 'utf8');
|
|
31
|
-
ctx.expect(source.includes('deepLink.
|
|
31
|
+
ctx.expect(source.includes('deepLink.markOmegaReady()')).toBe(true);
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
],
|
|
@@ -6,7 +6,7 @@ const { v5: uuidv5 } = require('uuid');
|
|
|
6
6
|
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
7
7
|
|
|
8
8
|
async function reinit(ctx, env, configOverrides) {
|
|
9
|
-
ctx.
|
|
9
|
+
ctx.omega.analytics.shutdown();
|
|
10
10
|
const saved = {
|
|
11
11
|
GOOGLE_ANALYTICS_SECRET: process.env.GOOGLE_ANALYTICS_SECRET,
|
|
12
12
|
};
|
|
@@ -14,19 +14,19 @@ async function reinit(ctx, env, configOverrides) {
|
|
|
14
14
|
if (v == null) delete process.env[k];
|
|
15
15
|
else process.env[k] = v;
|
|
16
16
|
}
|
|
17
|
-
const cfgOrig = ctx.
|
|
17
|
+
const cfgOrig = ctx.omega.config.analytics;
|
|
18
18
|
if (configOverrides !== undefined) {
|
|
19
|
-
ctx.
|
|
19
|
+
ctx.omega.config.analytics = configOverrides;
|
|
20
20
|
}
|
|
21
|
-
ctx.
|
|
21
|
+
ctx.omega.analytics.initialize(ctx.omega);
|
|
22
22
|
return () => {
|
|
23
|
-
ctx.
|
|
23
|
+
ctx.omega.analytics.shutdown();
|
|
24
24
|
for (const [k, v] of Object.entries(saved)) {
|
|
25
25
|
if (v == null) delete process.env[k];
|
|
26
26
|
else process.env[k] = v;
|
|
27
27
|
}
|
|
28
|
-
ctx.
|
|
29
|
-
ctx.
|
|
28
|
+
ctx.omega.config.analytics = cfgOrig;
|
|
29
|
+
ctx.omega.analytics.initialize(ctx.omega);
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -35,15 +35,15 @@ module.exports = defineCases({
|
|
|
35
35
|
layer: 'main',
|
|
36
36
|
description: 'analytics (main)',
|
|
37
37
|
cleanup: async (ctx) => {
|
|
38
|
-
ctx.
|
|
38
|
+
ctx.omega.analytics.shutdown();
|
|
39
39
|
delete process.env.GOOGLE_ANALYTICS_SECRET;
|
|
40
|
-
ctx.
|
|
40
|
+
ctx.omega.analytics.initialize(ctx.omega);
|
|
41
41
|
},
|
|
42
42
|
tests: [
|
|
43
43
|
{
|
|
44
|
-
name: 'analytics module wired on
|
|
44
|
+
name: 'analytics module wired on omega',
|
|
45
45
|
run: (ctx) => {
|
|
46
|
-
ctx.expect(ctx.
|
|
46
|
+
ctx.expect(ctx.omega.analytics).toBeDefined();
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
{
|
|
@@ -51,8 +51,8 @@ module.exports = defineCases({
|
|
|
51
51
|
run: async (ctx) => {
|
|
52
52
|
const restore = await reinit(ctx, {}, { enabled: false });
|
|
53
53
|
try {
|
|
54
|
-
ctx.expect(ctx.
|
|
55
|
-
ctx.expect(ctx.
|
|
54
|
+
ctx.expect(ctx.omega.analytics._enabled).toBe(false);
|
|
55
|
+
ctx.expect(ctx.omega.analytics._clientId).toBe(null);
|
|
56
56
|
} finally { await restore(); }
|
|
57
57
|
},
|
|
58
58
|
},
|
|
@@ -64,7 +64,7 @@ module.exports = defineCases({
|
|
|
64
64
|
providers: { google: { id: '' } },
|
|
65
65
|
});
|
|
66
66
|
try {
|
|
67
|
-
ctx.expect(ctx.
|
|
67
|
+
ctx.expect(ctx.omega.analytics._enabled).toBe(false);
|
|
68
68
|
} finally { await restore(); }
|
|
69
69
|
},
|
|
70
70
|
},
|
|
@@ -76,7 +76,7 @@ module.exports = defineCases({
|
|
|
76
76
|
providers: { google: { id: 'G-TESTID12' } },
|
|
77
77
|
});
|
|
78
78
|
try {
|
|
79
|
-
ctx.expect(ctx.
|
|
79
|
+
ctx.expect(ctx.omega.analytics._enabled).toBe(false);
|
|
80
80
|
} finally { await restore(); }
|
|
81
81
|
},
|
|
82
82
|
},
|
|
@@ -88,14 +88,14 @@ module.exports = defineCases({
|
|
|
88
88
|
providers: { google: { id: 'G-TESTID12' } },
|
|
89
89
|
});
|
|
90
90
|
try {
|
|
91
|
-
ctx.expect(ctx.
|
|
92
|
-
ctx.expect(typeof ctx.
|
|
93
|
-
ctx.expect(ctx.
|
|
91
|
+
ctx.expect(ctx.omega.analytics._enabled).toBe(true);
|
|
92
|
+
ctx.expect(typeof ctx.omega.analytics._clientId).toBe('string');
|
|
93
|
+
ctx.expect(ctx.omega.analytics._clientId.length).toBe(36);
|
|
94
94
|
// Confirm it's a stable derivation: same deviceId + same namespace should
|
|
95
95
|
// produce the same uuidv5 every time.
|
|
96
|
-
const ns = ctx.
|
|
97
|
-
const deviceId = ctx.
|
|
98
|
-
ctx.expect(ctx.
|
|
96
|
+
const ns = ctx.omega.analytics._namespace;
|
|
97
|
+
const deviceId = ctx.omega.context.session.deviceId;
|
|
98
|
+
ctx.expect(ctx.omega.analytics._clientId).toBe(uuidv5(deviceId, ns));
|
|
99
99
|
} finally { await restore(); }
|
|
100
100
|
},
|
|
101
101
|
},
|
|
@@ -105,24 +105,24 @@ module.exports = defineCases({
|
|
|
105
105
|
// launch a new GA client, so initialize raises instead of limping.
|
|
106
106
|
name: 'no context.session.deviceId: initialize raises (the boot-order invariant)',
|
|
107
107
|
run: async (ctx) => {
|
|
108
|
-
const savedDeviceId = ctx.
|
|
108
|
+
const savedDeviceId = ctx.omega.context.session.deviceId;
|
|
109
109
|
const savedSecret = process.env.GOOGLE_ANALYTICS_SECRET;
|
|
110
|
-
const savedConfig = ctx.
|
|
110
|
+
const savedConfig = ctx.omega.config.analytics;
|
|
111
111
|
|
|
112
|
-
ctx.
|
|
113
|
-
ctx.
|
|
112
|
+
ctx.omega.analytics.shutdown();
|
|
113
|
+
ctx.omega.context.session.deviceId = null;
|
|
114
114
|
process.env.GOOGLE_ANALYTICS_SECRET = 'fake-secret';
|
|
115
|
-
ctx.
|
|
115
|
+
ctx.omega.config.analytics = { enabled: true, providers: { google: { id: 'G-TESTID12' } } };
|
|
116
116
|
|
|
117
117
|
try {
|
|
118
|
-
await ctx.expect(() => ctx.
|
|
118
|
+
await ctx.expect(() => ctx.omega.analytics.initialize(ctx.omega)).toThrow(/boot sequence/);
|
|
119
119
|
} finally {
|
|
120
|
-
ctx.
|
|
121
|
-
ctx.
|
|
120
|
+
ctx.omega.context.session.deviceId = savedDeviceId;
|
|
121
|
+
ctx.omega.config.analytics = savedConfig;
|
|
122
122
|
if (savedSecret == null) delete process.env.GOOGLE_ANALYTICS_SECRET;
|
|
123
123
|
else process.env.GOOGLE_ANALYTICS_SECRET = savedSecret;
|
|
124
|
-
ctx.
|
|
125
|
-
ctx.
|
|
124
|
+
ctx.omega.analytics.shutdown();
|
|
125
|
+
ctx.omega.analytics.initialize(ctx.omega);
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
},
|
|
@@ -136,7 +136,7 @@ module.exports = defineCases({
|
|
|
136
136
|
providers: { google: { id: 'G-TESTID12' } },
|
|
137
137
|
});
|
|
138
138
|
try {
|
|
139
|
-
const a = ctx.
|
|
139
|
+
const a = ctx.omega.analytics;
|
|
140
140
|
const ns = a._namespace;
|
|
141
141
|
a.setUserId('firebase-uid-abc-123');
|
|
142
142
|
const expected = uuidv5('firebase-uid-abc-123', ns);
|
|
@@ -153,7 +153,7 @@ module.exports = defineCases({
|
|
|
153
153
|
run: async (ctx) => {
|
|
154
154
|
// Hand-rolled (not reinit()): the helper's leading shutdown() would
|
|
155
155
|
// wipe the very _pendingUid this test plants.
|
|
156
|
-
const a = ctx.
|
|
156
|
+
const a = ctx.omega.analytics;
|
|
157
157
|
a.shutdown(); // _namespace null — the pre-init state
|
|
158
158
|
|
|
159
159
|
a.setUserId('early-uid-before-boot');
|
|
@@ -161,18 +161,18 @@ module.exports = defineCases({
|
|
|
161
161
|
|
|
162
162
|
const savedSecret = process.env.GOOGLE_ANALYTICS_SECRET;
|
|
163
163
|
process.env.GOOGLE_ANALYTICS_SECRET = 'fake-secret';
|
|
164
|
-
const cfgOrig = ctx.
|
|
165
|
-
ctx.
|
|
164
|
+
const cfgOrig = ctx.omega.config.analytics;
|
|
165
|
+
ctx.omega.config.analytics = { enabled: true, providers: { google: { id: 'G-TESTID12' } } };
|
|
166
166
|
try {
|
|
167
|
-
a.initialize(ctx.
|
|
167
|
+
a.initialize(ctx.omega);
|
|
168
168
|
ctx.expect(a._pendingUid).toBe(null);
|
|
169
169
|
ctx.expect(a._userId).toBe(uuidv5('early-uid-before-boot', a._namespace));
|
|
170
170
|
} finally {
|
|
171
171
|
a.shutdown();
|
|
172
172
|
if (savedSecret == null) delete process.env.GOOGLE_ANALYTICS_SECRET;
|
|
173
173
|
else process.env.GOOGLE_ANALYTICS_SECRET = savedSecret;
|
|
174
|
-
ctx.
|
|
175
|
-
a.initialize(ctx.
|
|
174
|
+
ctx.omega.config.analytics = cfgOrig;
|
|
175
|
+
a.initialize(ctx.omega);
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
},
|
|
@@ -184,10 +184,10 @@ module.exports = defineCases({
|
|
|
184
184
|
providers: { google: { id: 'G-TESTID12' } },
|
|
185
185
|
});
|
|
186
186
|
try {
|
|
187
|
-
ctx.
|
|
188
|
-
ctx.expect(ctx.
|
|
189
|
-
ctx.
|
|
190
|
-
ctx.expect(ctx.
|
|
187
|
+
ctx.omega.analytics.setUserId('some-uid');
|
|
188
|
+
ctx.expect(ctx.omega.analytics._userId).not.toBe(null);
|
|
189
|
+
ctx.omega.analytics.setUserId(null);
|
|
190
|
+
ctx.expect(ctx.omega.analytics._userId).toBe(null);
|
|
191
191
|
} finally { await restore(); }
|
|
192
192
|
},
|
|
193
193
|
},
|
|
@@ -203,7 +203,7 @@ module.exports = defineCases({
|
|
|
203
203
|
providers: { google: { id: 'G-TESTID12' } },
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
-
const a = ctx.
|
|
206
|
+
const a = ctx.omega.analytics;
|
|
207
207
|
const origSend = a._send;
|
|
208
208
|
const sent = [];
|
|
209
209
|
a._send = (descriptor) => { sent.push(descriptor); return true; };
|
|
@@ -230,7 +230,7 @@ module.exports = defineCases({
|
|
|
230
230
|
{
|
|
231
231
|
name: '_enrichParams adds session_id + engagement_time_msec',
|
|
232
232
|
run: (ctx) => {
|
|
233
|
-
const params = ctx.
|
|
233
|
+
const params = ctx.omega.analytics._enrichParams({ custom: 'value' });
|
|
234
234
|
ctx.expect(params.custom).toBe('value');
|
|
235
235
|
ctx.expect(typeof params.session_id).toBe('string');
|
|
236
236
|
ctx.expect(typeof params.engagement_time_msec).toBe('number');
|
|
@@ -245,7 +245,7 @@ module.exports = defineCases({
|
|
|
245
245
|
const restore = await reinit(ctx, {}, { enabled: false });
|
|
246
246
|
try {
|
|
247
247
|
// Should not throw.
|
|
248
|
-
ctx.
|
|
248
|
+
ctx.omega.analytics.event('app_launch', { x: 1 });
|
|
249
249
|
ctx.expect(true).toBe(true);
|
|
250
250
|
} finally { await restore(); }
|
|
251
251
|
},
|
|
@@ -253,28 +253,28 @@ module.exports = defineCases({
|
|
|
253
253
|
{
|
|
254
254
|
name: 'event() before init queues, queue is bounded',
|
|
255
255
|
run: (ctx) => {
|
|
256
|
-
const a = ctx.
|
|
256
|
+
const a = ctx.omega.analytics;
|
|
257
257
|
a.shutdown(); // back to uninitialized state
|
|
258
258
|
a.event('queued_one');
|
|
259
259
|
a.event('queued_two');
|
|
260
260
|
ctx.expect(a._queue.length).toBe(2);
|
|
261
|
-
ctx.
|
|
261
|
+
ctx.omega.analytics.initialize(ctx.omega); // restore for downstream tests
|
|
262
262
|
},
|
|
263
263
|
},
|
|
264
264
|
{
|
|
265
265
|
name: 'queue flushes on init',
|
|
266
266
|
run: async (ctx) => {
|
|
267
267
|
// Force a "before init" state with a couple of queued items.
|
|
268
|
-
ctx.
|
|
269
|
-
ctx.
|
|
270
|
-
ctx.
|
|
268
|
+
ctx.omega.analytics.shutdown();
|
|
269
|
+
ctx.omega.analytics._queue.push({ name: 'x', params: {} });
|
|
270
|
+
ctx.omega.analytics._queue.push({ name: 'y', params: {} });
|
|
271
271
|
const restore = await reinit(ctx, { GOOGLE_ANALYTICS_SECRET: 'fake-secret' }, {
|
|
272
272
|
enabled: true,
|
|
273
273
|
providers: { google: { id: 'G-TESTID12' } },
|
|
274
274
|
});
|
|
275
275
|
try {
|
|
276
276
|
// After init, queue should be drained.
|
|
277
|
-
ctx.expect(ctx.
|
|
277
|
+
ctx.expect(ctx.omega.analytics._queue.length).toBe(0);
|
|
278
278
|
} finally { await restore(); }
|
|
279
279
|
},
|
|
280
280
|
},
|
|
@@ -286,7 +286,7 @@ module.exports = defineCases({
|
|
|
286
286
|
providers: { google: { id: 'G-TESTID12' } },
|
|
287
287
|
});
|
|
288
288
|
try {
|
|
289
|
-
const a = ctx.
|
|
289
|
+
const a = ctx.omega.analytics;
|
|
290
290
|
// Simulate auth bridge firing.
|
|
291
291
|
a._handleAuthChange({ uid: 'user-123' });
|
|
292
292
|
ctx.expect(a._userId).not.toBe(null);
|
|
@@ -304,9 +304,9 @@ module.exports = defineCases({
|
|
|
304
304
|
providers: { google: { id: 'G-TESTID12' } },
|
|
305
305
|
});
|
|
306
306
|
try {
|
|
307
|
-
ctx.
|
|
308
|
-
ctx.expect(ctx.
|
|
309
|
-
ctx.expect(ctx.
|
|
307
|
+
ctx.omega.analytics.setUserProperties({ plan: 'premium', custom_flag: true });
|
|
308
|
+
ctx.expect(ctx.omega.analytics._userProperties.plan).toEqual({ value: 'premium' });
|
|
309
|
+
ctx.expect(ctx.omega.analytics._userProperties.custom_flag).toEqual({ value: true });
|
|
310
310
|
} finally { await restore(); }
|
|
311
311
|
},
|
|
312
312
|
},
|
|
@@ -318,7 +318,7 @@ module.exports = defineCases({
|
|
|
318
318
|
providers: { google: { id: 'G-TESTID12' } },
|
|
319
319
|
});
|
|
320
320
|
try {
|
|
321
|
-
const snap = await ctx.
|
|
321
|
+
const snap = await ctx.omega.ipc.invoke('desktop:analytics:status');
|
|
322
322
|
ctx.expect(snap.enabled).toBe(true);
|
|
323
323
|
ctx.expect(snap.measurementId).toBe('G-TESTID12');
|
|
324
324
|
} finally { await restore(); }
|
|
@@ -327,13 +327,13 @@ module.exports = defineCases({
|
|
|
327
327
|
{
|
|
328
328
|
name: 'IPC listener desktop:analytics:event routes to analytics.event',
|
|
329
329
|
run: async (ctx) => {
|
|
330
|
-
const a = ctx.
|
|
330
|
+
const a = ctx.omega.analytics;
|
|
331
331
|
const origEvent = a.event;
|
|
332
332
|
let captured = null;
|
|
333
333
|
a.event = (name, params) => { captured = { name, params }; };
|
|
334
334
|
try {
|
|
335
335
|
// Simulate an inbound IPC call (renderer would do ipcRenderer.send).
|
|
336
|
-
const listeners = ctx.
|
|
336
|
+
const listeners = ctx.omega.ipc._listeners?.['desktop:analytics:event'];
|
|
337
337
|
ctx.expect(listeners).toBeDefined();
|
|
338
338
|
listeners.forEach((fn) => fn({ name: 'rendererEvent', params: { x: 1 } }));
|
|
339
339
|
ctx.expect(captured).toEqual({ name: 'rendererEvent', params: { x: 1 } });
|
|
@@ -348,7 +348,7 @@ module.exports = defineCases({
|
|
|
348
348
|
providers: { google: { id: 'G-TESTID12' } },
|
|
349
349
|
});
|
|
350
350
|
try {
|
|
351
|
-
const j = ctx.
|
|
351
|
+
const j = ctx.omega.analytics.toJSON();
|
|
352
352
|
ctx.expect(j.enabled).toBe(true);
|
|
353
353
|
ctx.expect(j.measurementId).toBe('G-TESTID12');
|
|
354
354
|
ctx.expect(typeof j.clientId).toBe('string');
|