@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
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
// Build-time tests for the Manager class (build.js).
|
|
2
|
-
|
|
3
|
-
const Manager = require('../../../build.js');
|
|
4
|
-
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
5
|
-
|
|
6
|
-
// The one input and the two lane flags that decide it, saved and restored
|
|
7
|
-
// around every case that touches them (#817).
|
|
8
|
-
const LANE_KEYS = ['OMEGA_ENVIRONMENT', 'OMEGA_BUILD_MODE', 'OMEGA_TEST_MODE', 'NODE_ENV'];
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Run `fn` with exactly `vars` set on the lane keys (null clears them all).
|
|
12
|
-
* @param {object|null} vars - the lane env for this case.
|
|
13
|
-
* @param {function} fn - the body.
|
|
14
|
-
* @returns {*} whatever `fn` returns.
|
|
15
|
-
*/
|
|
16
|
-
function withEnvironment(vars, fn) {
|
|
17
|
-
const saved = {};
|
|
18
|
-
for (const key of LANE_KEYS) saved[key] = process.env[key];
|
|
19
|
-
try {
|
|
20
|
-
for (const key of LANE_KEYS) delete process.env[key];
|
|
21
|
-
Object.assign(process.env, vars || {});
|
|
22
|
-
return fn();
|
|
23
|
-
} finally {
|
|
24
|
-
for (const key of LANE_KEYS) {
|
|
25
|
-
if (saved[key] === undefined) delete process.env[key];
|
|
26
|
-
else process.env[key] = saved[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* What src/build.js resolves at LOAD for a given lane. build.js sets the input
|
|
33
|
-
* once, at require time, so this loads a fresh copy of it per lane.
|
|
34
|
-
* @param {object} vars - the lane env.
|
|
35
|
-
* @returns {string} the resolved environment.
|
|
36
|
-
*/
|
|
37
|
-
function laneEnvironment(vars) {
|
|
38
|
-
const buildPath = require.resolve('../../../build.js');
|
|
39
|
-
return withEnvironment(vars, () => {
|
|
40
|
-
const saved = require.cache[buildPath];
|
|
41
|
-
delete require.cache[buildPath];
|
|
42
|
-
try {
|
|
43
|
-
return require(buildPath).getEnvironment();
|
|
44
|
-
} finally {
|
|
45
|
-
if (saved) require.cache[buildPath] = saved;
|
|
46
|
-
else delete require.cache[buildPath];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = defineCases({
|
|
52
|
-
type: 'group', // independent tests; run all even on failure
|
|
53
|
-
layer: 'build',
|
|
54
|
-
description: 'Manager (build.js)',
|
|
55
|
-
tests: [
|
|
56
|
-
{
|
|
57
|
-
name: 'class is exported and instantiable',
|
|
58
|
-
run: (ctx) => {
|
|
59
|
-
ctx.expect(typeof Manager).toBe('function');
|
|
60
|
-
ctx.expect(new Manager()).toBeInstanceOf(Manager);
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'getMode returns the mode shape',
|
|
65
|
-
run: (ctx) => {
|
|
66
|
-
const mode = Manager.getMode();
|
|
67
|
-
ctx.expect(mode).toHaveProperty('build');
|
|
68
|
-
ctx.expect(mode).toHaveProperty('publish');
|
|
69
|
-
ctx.expect(mode).toHaveProperty('server');
|
|
70
|
-
ctx.expect(mode).toHaveProperty('environment');
|
|
71
|
-
ctx.expect(['development', 'testing', 'production']).toContain(mode.environment);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
// The environment reads ONE input, `OMEGA_ENVIRONMENT`
|
|
76
|
-
// ([#817](https://github.com/Omega-JS-Stack/omega/issues/817)), and the
|
|
77
|
-
// lane that boots or builds this app sets it (src/build.js does, at load).
|
|
78
|
-
// Nothing sniffs NODE_ENV, app.isPackaged or OMEGA_TEST_MODE any more.
|
|
79
|
-
name: 'getEnvironment answers the one input, for each of the three names',
|
|
80
|
-
run: (ctx) => {
|
|
81
|
-
withEnvironment(null, () => {
|
|
82
|
-
for (const name of ['development', 'testing', 'production']) {
|
|
83
|
-
process.env.OMEGA_ENVIRONMENT = name;
|
|
84
|
-
ctx.expect(Manager.getEnvironment()).toBe(name);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
// The bug this replaced: with no signal desktop's own copy answered
|
|
91
|
-
// 'production', so a plain `npm start` bundled itself as a production
|
|
92
|
-
// artifact, while @omega.js/extension's copy of the same function
|
|
93
|
-
// answered 'development' from the same inputs (#817).
|
|
94
|
-
name: 'the build lane resolves production, a dev boot resolves development',
|
|
95
|
-
run: (ctx) => {
|
|
96
|
-
const buildLane = laneEnvironment({ OMEGA_BUILD_MODE: 'true' });
|
|
97
|
-
ctx.expect(buildLane).toBe('production');
|
|
98
|
-
|
|
99
|
-
const devBoot = laneEnvironment({});
|
|
100
|
-
ctx.expect(devBoot).toBe('development');
|
|
101
|
-
|
|
102
|
-
// A lane that already named one keeps it, EXCEPT a build lane: a
|
|
103
|
-
// production build spawned from a test run still bakes production.
|
|
104
|
-
ctx.expect(laneEnvironment({ OMEGA_ENVIRONMENT: 'testing' })).toBe('testing');
|
|
105
|
-
ctx.expect(laneEnvironment({ OMEGA_ENVIRONMENT: 'testing', OMEGA_BUILD_MODE: 'true' })).toBe('production');
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'no input at all is a loud error naming OMEGA_ENVIRONMENT, never a default',
|
|
110
|
-
run: (ctx) => {
|
|
111
|
-
withEnvironment(null, () => {
|
|
112
|
-
delete process.env.OMEGA_ENVIRONMENT;
|
|
113
|
-
ctx.expect(() => Manager.getEnvironment()).toThrow(/OMEGA_ENVIRONMENT/);
|
|
114
|
-
process.env.OMEGA_ENVIRONMENT = 'staging';
|
|
115
|
-
ctx.expect(() => Manager.getEnvironment()).toThrow(/OMEGA_ENVIRONMENT/);
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
// The core invariant: is*() DERIVE from getEnvironment(), so they can
|
|
121
|
-
// NEVER disagree with it, and exactly one is always true.
|
|
122
|
-
name: 'invariant: is*() exactly matches getEnvironment() + mutually exclusive (every scenario)',
|
|
123
|
-
run: (ctx) => {
|
|
124
|
-
withEnvironment(null, () => {
|
|
125
|
-
for (const name of ['development', 'testing', 'production']) {
|
|
126
|
-
process.env.OMEGA_ENVIRONMENT = name;
|
|
127
|
-
const e = Manager.getEnvironment();
|
|
128
|
-
ctx.expect(e).toBe(name);
|
|
129
|
-
ctx.expect(Manager.isDevelopment()).toBe(e === 'development');
|
|
130
|
-
ctx.expect(Manager.isTesting()).toBe(e === 'testing');
|
|
131
|
-
ctx.expect(Manager.isProduction()).toBe(e === 'production');
|
|
132
|
-
const trueCount = [Manager.isDevelopment(), Manager.isTesting(), Manager.isProduction()].filter(Boolean).length;
|
|
133
|
-
ctx.expect(trueCount).toBe(1);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: 'getPackage("main") resolves to @omega.js/desktop package.json',
|
|
140
|
-
run: (ctx) => {
|
|
141
|
-
const pkg = Manager.getPackage('main');
|
|
142
|
-
ctx.expect(pkg.name).toBe('@omega.js/desktop');
|
|
143
|
-
ctx.expect(pkg).toHaveProperty('version');
|
|
144
|
-
ctx.expect(pkg).toHaveProperty('exports');
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'getRootPath("main") returns a non-empty string',
|
|
149
|
-
run: (ctx) => {
|
|
150
|
-
const root = Manager.getRootPath('main');
|
|
151
|
-
ctx.expect(typeof root).toBe('string');
|
|
152
|
-
ctx.expect(root.length).toBeGreaterThan(0);
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'getLiveReloadPort defaults to 35729',
|
|
157
|
-
run: (ctx) => {
|
|
158
|
-
const prev = process.env.OMEGA_LIVERELOAD_PORT;
|
|
159
|
-
delete process.env.OMEGA_LIVERELOAD_PORT;
|
|
160
|
-
try {
|
|
161
|
-
ctx.expect(Manager.getLiveReloadPort()).toBe(35729);
|
|
162
|
-
} finally {
|
|
163
|
-
if (prev !== undefined) process.env.OMEGA_LIVERELOAD_PORT = prev;
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'getWindowsSignStrategy defaults to self-hosted when no config',
|
|
169
|
-
run: (ctx) => {
|
|
170
|
-
// No EM_WIN_SIGN_STRATEGY env-var support anymore — config is the only source.
|
|
171
|
-
// Run from a cwd with no omega.json5 to confirm the default.
|
|
172
|
-
const fs = require('fs'); const os = require('os'); const path = require('path');
|
|
173
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-strategy-'));
|
|
174
|
-
const orig = process.cwd();
|
|
175
|
-
try {
|
|
176
|
-
process.chdir(tmp);
|
|
177
|
-
ctx.expect(Manager.getWindowsSignStrategy()).toBe('self-hosted');
|
|
178
|
-
} finally {
|
|
179
|
-
process.chdir(orig);
|
|
180
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: 'getWindowsSignStrategy reads config platforms.windows.signing.strategy',
|
|
186
|
-
run: (ctx) => {
|
|
187
|
-
const fs = require('fs'); const os = require('os'); const path = require('path');
|
|
188
|
-
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-strategy-'));
|
|
189
|
-
fs.mkdirSync(path.join(tmp, 'config'), { recursive: true });
|
|
190
|
-
fs.writeFileSync(path.join(tmp, 'config', 'omega.json5'),
|
|
191
|
-
`{ targets: { desktop: { type: 'desktop', platforms: { windows: { signing: { strategy: 'cloud' } } } } } }`);
|
|
192
|
-
const orig = process.cwd();
|
|
193
|
-
try {
|
|
194
|
-
process.chdir(tmp);
|
|
195
|
-
ctx.expect(Manager.getWindowsSignStrategy()).toBe('cloud');
|
|
196
|
-
} finally {
|
|
197
|
-
process.chdir(orig);
|
|
198
|
-
fs.rmSync(tmp, { recursive: true, force: true });
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
name: 'logger returns a named logger',
|
|
204
|
-
run: (ctx) => {
|
|
205
|
-
const m = new Manager();
|
|
206
|
-
const logger = m.logger('test-name');
|
|
207
|
-
ctx.expect(logger.name).toBe('test-name');
|
|
208
|
-
ctx.expect(typeof logger.log).toBe('function');
|
|
209
|
-
ctx.expect(typeof logger.error).toBe('function');
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
});
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
// Main-process tests for lib/client-bridge.js — unit-level coverage that doesn't hit Firebase.
|
|
2
|
-
//
|
|
3
|
-
// Real Firebase integration tests live in client-bridge.integration.test.js
|
|
4
|
-
// (gated on extended mode); the sign-in proof itself is #904's, through a
|
|
5
|
-
// persona the backend emulator seeds.
|
|
6
|
-
|
|
7
|
-
const defineCases = require('../../../vendor/devkit/test/define-cases.js');
|
|
8
|
-
|
|
9
|
-
module.exports = defineCases({
|
|
10
|
-
type: 'suite',
|
|
11
|
-
layer: 'main',
|
|
12
|
-
description: 'client-bridge (main, unit)',
|
|
13
|
-
cleanup: async (ctx) => {
|
|
14
|
-
await ctx.manager.omega._resetForTests();
|
|
15
|
-
},
|
|
16
|
-
tests: [
|
|
17
|
-
{
|
|
18
|
-
name: 'initialize ran during boot',
|
|
19
|
-
run: (ctx) => {
|
|
20
|
-
ctx.expect(ctx.manager.omega._initialized).toBe(true);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'IPC handlers are registered',
|
|
25
|
-
run: (ctx) => {
|
|
26
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:sync-request')).toBe(true);
|
|
27
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:sign-out')).toBe(true);
|
|
28
|
-
ctx.expect(ctx.manager.ipc.hasHandler('desktop:auth:get-user')).toBe(true);
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'getCurrentUser returns null when nothing is signed in',
|
|
33
|
-
run: (ctx) => {
|
|
34
|
-
// The harness boots without auth; either firebase isn't loaded (no cloud.config
|
|
35
|
-
// in default config) or it is and there's no user. Either way, currentUser is null.
|
|
36
|
-
ctx.expect(ctx.manager.omega.getCurrentUser()).toBeNull();
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'getIdToken returns null when nothing is signed in',
|
|
41
|
-
run: async (ctx) => {
|
|
42
|
-
// Same no-auth harness as getCurrentUser above — signed-in token
|
|
43
|
-
// round-trips are the integration suite's domain.
|
|
44
|
-
ctx.expect(await ctx.manager.omega.getIdToken()).toBeNull();
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'handleAuthToken returns no-op result when firebase not loaded',
|
|
49
|
-
run: async (ctx) => {
|
|
50
|
-
// Default config has empty cloud.config → firebase fails to init → _firebaseAuth=null.
|
|
51
|
-
if (ctx.manager.omega._firebaseAuth) {
|
|
52
|
-
ctx.skip('firebase did load (cloud.config was set) — covered by integration tests');
|
|
53
|
-
}
|
|
54
|
-
const r = await ctx.manager.omega.handleAuthToken('whatever');
|
|
55
|
-
ctx.expect(r.success).toBe(false);
|
|
56
|
-
ctx.expect(r.reason).toBe('firebase-not-loaded');
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'handleAuthToken with empty token returns no-token failure',
|
|
61
|
-
run: async (ctx) => {
|
|
62
|
-
// Stub _firebaseAuth so we hit the "no token" branch instead of "firebase-not-loaded."
|
|
63
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
64
|
-
ctx.manager.omega._firebaseAuth = { currentUser: null }; // truthy so we pass the firebase check
|
|
65
|
-
try {
|
|
66
|
-
const r = await ctx.manager.omega.handleAuthToken('');
|
|
67
|
-
ctx.expect(r.success).toBe(false);
|
|
68
|
-
ctx.expect(r.reason).toBe('no-token');
|
|
69
|
-
} finally {
|
|
70
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'sync-request: same UID → no sync needed',
|
|
76
|
-
run: async (ctx) => {
|
|
77
|
-
// Stub the auth so we control bgUid.
|
|
78
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
79
|
-
ctx.manager.omega._firebaseAuth = { currentUser: { uid: 'abc' } };
|
|
80
|
-
try {
|
|
81
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: 'abc' });
|
|
82
|
-
ctx.expect(result.needsSync).toBe(false);
|
|
83
|
-
} finally {
|
|
84
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'sync-request: main signed out, renderer signed in → tells renderer to sign out',
|
|
90
|
-
run: async (ctx) => {
|
|
91
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
92
|
-
ctx.manager.omega._firebaseAuth = { currentUser: null };
|
|
93
|
-
try {
|
|
94
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: 'someone' });
|
|
95
|
-
ctx.expect(result.needsSync).toBe(true);
|
|
96
|
-
ctx.expect(result.signOut).toBe(true);
|
|
97
|
-
} finally {
|
|
98
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'sync-request: firebase not loaded → no sync',
|
|
104
|
-
run: async (ctx) => {
|
|
105
|
-
const origAuth = ctx.manager.omega._firebaseAuth;
|
|
106
|
-
ctx.manager.omega._firebaseAuth = null;
|
|
107
|
-
try {
|
|
108
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sync-request', { contextUid: null });
|
|
109
|
-
ctx.expect(result.needsSync).toBe(false);
|
|
110
|
-
ctx.expect(result.reason).toBe('firebase-not-loaded');
|
|
111
|
-
} finally {
|
|
112
|
-
ctx.manager.omega._firebaseAuth = origAuth;
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'sign-out IPC succeeds when nothing is signed in',
|
|
118
|
-
run: async (ctx) => {
|
|
119
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:sign-out');
|
|
120
|
-
ctx.expect(result.success).toBe(true);
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'get-user IPC returns null when no current user',
|
|
125
|
-
run: async (ctx) => {
|
|
126
|
-
const result = await ctx.manager.ipc.invoke('desktop:auth:get-user');
|
|
127
|
-
ctx.expect(result).toBeNull();
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'onAuthChange returns an unsubscribe fn',
|
|
132
|
-
run: (ctx) => {
|
|
133
|
-
const fn = () => {};
|
|
134
|
-
const off = ctx.manager.omega.onAuthChange(fn);
|
|
135
|
-
ctx.expect(ctx.manager.omega._stateSubs.has(fn)).toBe(true);
|
|
136
|
-
off();
|
|
137
|
-
ctx.expect(ctx.manager.omega._stateSubs.has(fn)).toBe(false);
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: '_snapshotUser returns the public user shape (no token)',
|
|
142
|
-
run: (ctx) => {
|
|
143
|
-
const snap = ctx.manager.omega._snapshotUser({
|
|
144
|
-
uid: 'u1',
|
|
145
|
-
email: 'a@b.com',
|
|
146
|
-
displayName: 'Bob',
|
|
147
|
-
photoURL: 'http://x/p.png',
|
|
148
|
-
emailVerified: true,
|
|
149
|
-
// sensitive stuff that should NOT be exposed
|
|
150
|
-
stsTokenManager: { accessToken: 'SECRET' },
|
|
151
|
-
providerData: ['xxx'],
|
|
152
|
-
});
|
|
153
|
-
ctx.expect(snap).toEqual({
|
|
154
|
-
uid: 'u1',
|
|
155
|
-
email: 'a@b.com',
|
|
156
|
-
displayName: 'Bob',
|
|
157
|
-
photoURL: 'http://x/p.png',
|
|
158
|
-
emailVerified: true,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
// The emulator gate (#46). _getFirebaseAuth resolves firebase through the
|
|
164
|
-
// bridge's OWN seams (_firebase / _firebaseModule, filled by
|
|
165
|
-
// _tryLoadFirebase) — swapping those recording namespaces in drives the real
|
|
166
|
-
// method, no stubbing of the module under test. The manager is an input too:
|
|
167
|
-
// isTesting() is the whole gate.
|
|
168
|
-
name: 'auth emulator: a testing run connects, dev/production never do',
|
|
169
|
-
run: (ctx) => {
|
|
170
|
-
const bridge = ctx.manager.omega;
|
|
171
|
-
const saved = {
|
|
172
|
-
firebase: bridge._firebase,
|
|
173
|
-
module: bridge._firebaseModule,
|
|
174
|
-
auth: bridge._firebaseAuth,
|
|
175
|
-
manager: bridge._manager,
|
|
176
|
-
port: process.env.OMEGA_AUTH_PORT,
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// One recording firebase namespace pair, reused per run
|
|
180
|
-
const connects = [];
|
|
181
|
-
const authInstance = { __auth: true };
|
|
182
|
-
bridge._firebase = {
|
|
183
|
-
getApp: () => { throw new Error('no app'); },
|
|
184
|
-
initializeApp: () => ({ __app: true }),
|
|
185
|
-
};
|
|
186
|
-
bridge._firebaseModule = {
|
|
187
|
-
getAuth: () => authInstance,
|
|
188
|
-
connectAuthEmulator: (auth, url, opts) => connects.push({ auth, url, opts }),
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const run = (isTesting, dev) => {
|
|
192
|
-
bridge._firebaseAuth = null;
|
|
193
|
-
bridge._manager = {
|
|
194
|
-
config: { cloud: { config: { apiKey: 'AIza-test', projectId: 'demo-desktop' } }, ...(dev ? { dev } : {}) },
|
|
195
|
-
isTesting: () => isTesting,
|
|
196
|
-
};
|
|
197
|
-
return bridge._getFirebaseAuth(null);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
delete process.env.OMEGA_AUTH_PORT;
|
|
202
|
-
|
|
203
|
-
// production / dev shape — no emulator, ever
|
|
204
|
-
ctx.expect(run(false)).toBe(authInstance);
|
|
205
|
-
ctx.expect(connects.length).toBe(0);
|
|
206
|
-
|
|
207
|
-
// testing shape: the port comes from the map the bundle baked, which
|
|
208
|
-
// carries @omega.js/config's classic 9099 as its floor
|
|
209
|
-
// ([#834](https://github.com/Omega-JS-Stack/omega/issues/834)).
|
|
210
|
-
ctx.expect(run(true, { ports: { auth: 9099 } })).toBe(authInstance);
|
|
211
|
-
ctx.expect(connects.length).toBe(1);
|
|
212
|
-
ctx.expect(connects[0].auth).toBe(authInstance);
|
|
213
|
-
ctx.expect(connects[0].url).toBe('http://localhost:9099');
|
|
214
|
-
|
|
215
|
-
// a bumped port arrives on OMEGA_AUTH_PORT (N7)
|
|
216
|
-
process.env.OMEGA_AUTH_PORT = '9199';
|
|
217
|
-
run(true, { ports: { auth: 9099 } });
|
|
218
|
-
ctx.expect(connects.length).toBe(2);
|
|
219
|
-
ctx.expect(connects[1].url).toBe('http://localhost:9199');
|
|
220
|
-
|
|
221
|
-
// Neither channel is a broken artifact, and it says so by name
|
|
222
|
-
// rather than dialling a port nothing identity-checks (#834).
|
|
223
|
-
delete process.env.OMEGA_AUTH_PORT;
|
|
224
|
-
let threw;
|
|
225
|
-
try { run(true); } catch (e) { threw = e; }
|
|
226
|
-
ctx.expect(threw).toBeDefined();
|
|
227
|
-
ctx.expect(threw.message).toMatch(/dev port for `auth`/);
|
|
228
|
-
ctx.expect(threw.message).toMatch(/bundle task/);
|
|
229
|
-
ctx.expect(connects.length).toBe(2);
|
|
230
|
-
} finally {
|
|
231
|
-
bridge._firebase = saved.firebase;
|
|
232
|
-
bridge._firebaseModule = saved.module;
|
|
233
|
-
bridge._firebaseAuth = saved.auth;
|
|
234
|
-
bridge._manager = saved.manager;
|
|
235
|
-
if (saved.port === undefined) delete process.env.OMEGA_AUTH_PORT;
|
|
236
|
-
else process.env.OMEGA_AUTH_PORT = saved.port;
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: 'deep-link auth/token route is wired to handleAuthToken',
|
|
242
|
-
run: async (ctx) => {
|
|
243
|
-
// We've already tested the deep-link side in deep-link.test.js. Here we verify
|
|
244
|
-
// the integration is actually live: dispatching the route triggers our spy.
|
|
245
|
-
let received = null;
|
|
246
|
-
const orig = ctx.manager.omega.handleAuthToken;
|
|
247
|
-
ctx.manager.omega.handleAuthToken = async (token) => {
|
|
248
|
-
received = token;
|
|
249
|
-
return { success: true };
|
|
250
|
-
};
|
|
251
|
-
try {
|
|
252
|
-
ctx.manager.deepLink.dispatch('myapp://auth/token?authToken=BRIDGE-TEST-TOKEN');
|
|
253
|
-
// Built-in handler is sync up to the await — give it a tick.
|
|
254
|
-
await new Promise((r) => setImmediate(r));
|
|
255
|
-
ctx.expect(received).toBe('BRIDGE-TEST-TOKEN');
|
|
256
|
-
} finally {
|
|
257
|
-
ctx.manager.omega.handleAuthToken = orig;
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
});
|