@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
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
google: { id: '' },
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
-
// Empty config →
|
|
32
|
+
// Empty config → lib/auth.js skips Firebase init (no hang on a fake projectId).
|
|
33
33
|
cloud: { provider: 'firebase', config: {} },
|
|
34
34
|
targets: {
|
|
35
35
|
desktop: {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
// Minimal main-window renderer entry for the boot-layer self-test fixture.
|
|
2
|
-
|
|
2
|
+
import omega from '@omega.js/desktop/renderer';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
manager.initialize();
|
|
4
|
+
omega.initialize();
|
|
6
5
|
|
|
7
6
|
// #925 pins that this renderer answers the lane's environment and not the word
|
|
8
|
-
// baked into the bundle, so the boot inspect needs a handle on the
|
|
7
|
+
// baked into the bundle, so the boot inspect needs a handle on the instance the
|
|
9
8
|
// answer is given on.
|
|
10
|
-
window.
|
|
9
|
+
window.__omegaInstance = omega;
|
|
11
10
|
|
|
12
|
-
// #111
|
|
13
|
-
// `__main_assets__` alias
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
window.__omegaAppShell = require('__main_assets__/js/core/app-shell.js').default;
|
|
17
|
-
window.__omegaAppShell();
|
|
11
|
+
// #111 pins that a vendored core module resolves through the renderer's
|
|
12
|
+
// `__main_assets__` alias: an alias that does not resolve fails this fixture's
|
|
13
|
+
// build, and the boot inspect reads the export it bound.
|
|
14
|
+
window.__omegaCreateShell = require('__main_assets__/js/core/app-shell.js').createShell;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
// Minimal main entry for @omega.js/desktop's boot-layer self-test fixture. Mirrors a real consumer:
|
|
2
2
|
// one-line bootstrap, then create the main window once initialize() resolves. The boot
|
|
3
|
-
// harness (src/test/harness/boot-entry.js) inspects the live
|
|
4
|
-
const
|
|
3
|
+
// harness (src/test/harness/boot-entry.js) inspects the live instance after this runs.
|
|
4
|
+
const omega = require('@omega.js/desktop/main');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
manager.initialize()
|
|
6
|
+
omega.initialize()
|
|
9
7
|
.then(() => {
|
|
10
|
-
const { windows, logger } =
|
|
8
|
+
const { windows, logger } = omega;
|
|
11
9
|
|
|
12
|
-
// Force show:false
|
|
10
|
+
// Force show:false: the boot harness runs headless and only asserts the window
|
|
13
11
|
// EXISTS + loaded the built view, never that it's visible on screen.
|
|
14
12
|
windows.create('main', { show: false });
|
|
15
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Boot harness
|
|
1
|
+
// Boot harness: invoked from @omega.js/desktop's main.js (utils/boot-harness.js) after omega.initialize() resolves
|
|
2
2
|
// when OMEGA_TEST_BOOT=1. Reads the spec file pointed to by OMEGA_TEST_BOOT_SPEC,
|
|
3
|
-
// runs each `inspect` against the live
|
|
3
|
+
// runs each `inspect` against the live instance, emits results, and quits.
|
|
4
4
|
//
|
|
5
5
|
// Why call from main.js instead of preloading via electron's --require?
|
|
6
6
|
// Because Electron rejects unknown CLI flags, we can't sneak args/preload modules in.
|
|
@@ -11,29 +11,31 @@
|
|
|
11
11
|
// a project view (`view: '<name>'`), each in a real window of this booted app. See
|
|
12
12
|
// runViewSuite() below.
|
|
13
13
|
//
|
|
14
|
-
// Protocol matches main-entry.js
|
|
14
|
+
// Protocol matches main-entry.js, emit `__OMEGA_TEST__` JSON lines on stdout.
|
|
15
15
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
|
+
const { TEST_EVENT_PREFIX } = require('../../utils/test-events.js');
|
|
19
|
+
|
|
18
20
|
// Belt-and-suspenders for a view suite that never emits `end` (a page that died mid-run).
|
|
19
21
|
// Same 60s ceiling the harness-page renderer lane uses (harness/main-entry.js).
|
|
20
22
|
const VIEW_SUITE_TIMEOUT = 60000;
|
|
21
23
|
|
|
22
24
|
function emit(obj) {
|
|
23
|
-
process.stdout.write(
|
|
25
|
+
process.stdout.write(`${TEST_EVENT_PREFIX}${JSON.stringify(obj)}\n`);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
async function run(
|
|
28
|
+
async function run(omega) {
|
|
27
29
|
const { app } = require('electron');
|
|
28
30
|
const path = require('path');
|
|
29
31
|
|
|
30
|
-
// Give the consumer's `
|
|
32
|
+
// Give the consumer's `omega.initialize().then(() => { ... })` callback time
|
|
31
33
|
// to surface windows / wire up handlers / etc. The harness runs from setImmediate
|
|
32
34
|
// already (which flushes microtasks once), but `windows.create()` is async, so
|
|
33
35
|
// we additionally poll for the main window for up to 3s. Apps that intentionally
|
|
34
36
|
// launch hidden never create a main window — those tests should `if (!win) return`
|
|
35
37
|
// when inspecting window state.
|
|
36
|
-
await waitForMainWindow(
|
|
38
|
+
await waitForMainWindow(omega, 3000);
|
|
37
39
|
|
|
38
40
|
const specPath = process.env.OMEGA_TEST_BOOT_SPEC;
|
|
39
41
|
if (!specPath) {
|
|
@@ -74,7 +76,7 @@ async function run(manager) {
|
|
|
74
76
|
description: t.description,
|
|
75
77
|
timeout: t.timeout || 15000,
|
|
76
78
|
inspect: new Function('args', 'require', 'process', 'Buffer',
|
|
77
|
-
`return (async function ({
|
|
79
|
+
`return (async function ({ omega, expect, projectRoot, appRoot, frameworkDistRoot, distSnapshotBefore }) {\n${t.inspectSource}\n})(args)`,
|
|
78
80
|
),
|
|
79
81
|
}));
|
|
80
82
|
|
|
@@ -88,7 +90,7 @@ async function run(manager) {
|
|
|
88
90
|
const start = Date.now();
|
|
89
91
|
try {
|
|
90
92
|
await Promise.race([
|
|
91
|
-
t.inspect(Object.assign({
|
|
93
|
+
t.inspect(Object.assign({ omega, expect }, args), require, process, Buffer),
|
|
92
94
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Boot test timeout')), t.timeout)),
|
|
93
95
|
]);
|
|
94
96
|
const duration = Date.now() - start;
|
|
@@ -109,7 +111,7 @@ async function run(manager) {
|
|
|
109
111
|
// remaining suites unreported. This harness exits through app.exit() below regardless.
|
|
110
112
|
if (viewSuites.length > 0) app.removeAllListeners('window-all-closed');
|
|
111
113
|
for (let i = 0; i < viewSuites.length; i += 1) {
|
|
112
|
-
const counts = await runViewSuite(viewSuites[i], i,
|
|
114
|
+
const counts = await runViewSuite(viewSuites[i], i, omega, spec);
|
|
113
115
|
passed += counts.passed;
|
|
114
116
|
failed += counts.failed;
|
|
115
117
|
skipped += counts.skipped;
|
|
@@ -127,7 +129,7 @@ async function run(manager) {
|
|
|
127
129
|
// evaluated inside the page, with a shim standing in for the preload bridge it normally
|
|
128
130
|
// talks to. There is exactly one suite loop and one `expect` in this framework, and this is
|
|
129
131
|
// not a second copy of either.
|
|
130
|
-
async function runViewSuite(suite, index,
|
|
132
|
+
async function runViewSuite(suite, index, omega, spec) {
|
|
131
133
|
const fs = require('fs');
|
|
132
134
|
const path = require('path');
|
|
133
135
|
|
|
@@ -145,7 +147,7 @@ async function runViewSuite(suite, index, manager, spec) {
|
|
|
145
147
|
return counts;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
const win = await
|
|
150
|
+
const win = await omega.windows.create(`omega-test-view-${index}`, {
|
|
149
151
|
view: suite.view,
|
|
150
152
|
show: false,
|
|
151
153
|
persistBounds: false,
|
|
@@ -171,11 +173,11 @@ async function runViewSuite(suite, index, manager, spec) {
|
|
|
171
173
|
// surface talking to main over IPC; here the page just queues events for the poll
|
|
172
174
|
// below, since main is right here.
|
|
173
175
|
await win.webContents.executeJavaScript(`
|
|
174
|
-
window.
|
|
175
|
-
window.
|
|
176
|
+
window.__omegaTestQueue = [];
|
|
177
|
+
window.__omegaTest = {
|
|
176
178
|
ready() {},
|
|
177
|
-
emit(evt) { window.
|
|
178
|
-
onSuites(handler) { window.
|
|
179
|
+
emit(evt) { window.__omegaTestQueue.push(evt); },
|
|
180
|
+
onSuites(handler) { window.__omegaTestDeliver = handler; },
|
|
179
181
|
};
|
|
180
182
|
null;
|
|
181
183
|
`);
|
|
@@ -187,7 +189,7 @@ async function runViewSuite(suite, index, manager, spec) {
|
|
|
187
189
|
|
|
188
190
|
// 3. Deliver this window's one suite. One suite per window, so the entry's `end` event
|
|
189
191
|
// ends this window's run.
|
|
190
|
-
await win.webContents.executeJavaScript(`window.
|
|
192
|
+
await win.webContents.executeJavaScript(`window.__omegaTestDeliver(${JSON.stringify([suite])}); null;`);
|
|
191
193
|
|
|
192
194
|
// 4. Drain the queue until the run ends. Every event is forwarded verbatim, so the
|
|
193
195
|
// parent renders a view suite exactly like a harness-page one.
|
|
@@ -195,7 +197,7 @@ async function runViewSuite(suite, index, manager, spec) {
|
|
|
195
197
|
let ended = false;
|
|
196
198
|
while (!ended && Date.now() < deadline) {
|
|
197
199
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
198
|
-
const events = await win.webContents.executeJavaScript('window.
|
|
200
|
+
const events = await win.webContents.executeJavaScript('window.__omegaTestQueue.splice(0)');
|
|
199
201
|
for (const evt of events) {
|
|
200
202
|
emit(evt);
|
|
201
203
|
if (evt.event === 'end') {
|
|
@@ -226,10 +228,10 @@ async function runViewSuite(suite, index, manager, spec) {
|
|
|
226
228
|
|
|
227
229
|
// Poll for the main window for up to `timeoutMs`. Resolves when it shows up, or after
|
|
228
230
|
// the timeout (no error — agent/hidden apps never create one and that's fine).
|
|
229
|
-
async function waitForMainWindow(
|
|
231
|
+
async function waitForMainWindow(omega, timeoutMs) {
|
|
230
232
|
const deadline = Date.now() + timeoutMs;
|
|
231
233
|
while (Date.now() < deadline) {
|
|
232
|
-
if (
|
|
234
|
+
if (omega.windows.get('main')) return;
|
|
233
235
|
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
234
236
|
}
|
|
235
237
|
}
|
|
@@ -13,15 +13,16 @@
|
|
|
13
13
|
// exits 0 on success / 1 on any failure.
|
|
14
14
|
|
|
15
15
|
const path = require('path');
|
|
16
|
+
const { TEST_EVENT_PREFIX } = require('../../utils/test-events.js');
|
|
16
17
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
|
17
18
|
|
|
18
19
|
// macOS: suppress app activation BEFORE ready — launching a regular-policy app
|
|
19
20
|
// steals keyboard focus app-wide even when no window is ever focused. This file
|
|
20
|
-
// only initializes its
|
|
21
|
+
// only initializes its instance after whenReady (too late: activation fires when
|
|
21
22
|
// the app finishes launching), so flip the accessory policy here at require time.
|
|
22
23
|
// This process is always a test run (runners/electron.js spawns it naming
|
|
23
24
|
// OMEGA_ENVIRONMENT=testing, the one environment input), so
|
|
24
|
-
// the shared predicate needs no
|
|
25
|
+
// the shared predicate needs no instance. OMEGA_TEST_SHOW=1 opts back into normal
|
|
25
26
|
// activation along with visible windows.
|
|
26
27
|
if (process.platform === 'darwin' && require('../../utils/test-stealth.js')()) {
|
|
27
28
|
app.dock.hide();
|
|
@@ -31,7 +32,7 @@ if (process.platform === 'darwin' && require('../../utils/test-stealth.js')()) {
|
|
|
31
32
|
// the harness Electron (e.g. playwright-core connectOverCDP). Port 0 = an
|
|
32
33
|
// OS-assigned loopback-only port; Chromium writes the resolved port to
|
|
33
34
|
// DevToolsActivePort inside the userData dir that's CURRENT when the DevTools
|
|
34
|
-
// server starts
|
|
35
|
+
// server starts, captured here at require time, because omega.initialize()
|
|
35
36
|
// re-paths userData later (post-ready in this harness). runSuites() resolves
|
|
36
37
|
// the port from that file and publishes it as process.env.OMEGA_CDP_PORT.
|
|
37
38
|
if (!app.commandLine.hasSwitch('remote-debugging-port')) {
|
|
@@ -73,7 +74,7 @@ const filter = (() => {
|
|
|
73
74
|
})();
|
|
74
75
|
|
|
75
76
|
function emit(obj) {
|
|
76
|
-
process.stdout.write(
|
|
77
|
+
process.stdout.write(`${TEST_EVENT_PREFIX}${JSON.stringify(obj)}\n`);
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
class SkipError extends Error {
|
|
@@ -98,8 +99,8 @@ async function runSuites() {
|
|
|
98
99
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
const
|
|
102
|
+
// The ONE main-process instance, the same object a consumer's main.js requires
|
|
103
|
+
const omega = require('../../main.js');
|
|
103
104
|
|
|
104
105
|
// Test mode: load default config from @omega.js/desktop defaults (since the harness CWD won't have
|
|
105
106
|
// one), resolved for the desktop target via @omega.js/config, and skip window creation
|
|
@@ -109,7 +110,7 @@ async function runSuites() {
|
|
|
109
110
|
const { loadConfig } = require('../../vendor/config/index.js');
|
|
110
111
|
const defaultConfig = loadConfig(path.join(__dirname, '..', '..', 'defaults'), 'desktop').config;
|
|
111
112
|
|
|
112
|
-
await
|
|
113
|
+
await omega.initialize(defaultConfig, { skipWindowCreation: true });
|
|
113
114
|
|
|
114
115
|
// Consumer-scheme containment. Main-layer suites exercise consumer code that
|
|
115
116
|
// loads `<brand.id>://` URLs (tab managers, internal pages), but the consumer's
|
|
@@ -151,7 +152,7 @@ async function runSuites() {
|
|
|
151
152
|
expect: require('../assert.js'),
|
|
152
153
|
state,
|
|
153
154
|
layer: 'main',
|
|
154
|
-
|
|
155
|
+
omega,
|
|
155
156
|
skip(reason) { throw new SkipError(reason); },
|
|
156
157
|
});
|
|
157
158
|
|
|
@@ -200,7 +201,7 @@ async function runSuites() {
|
|
|
200
201
|
// After main suites finish, optionally run renderer suites in a hidden BrowserWindow.
|
|
201
202
|
if (rendererSuiteFiles.length > 0) {
|
|
202
203
|
try {
|
|
203
|
-
const r = await runRendererSuites(rendererSuiteFiles,
|
|
204
|
+
const r = await runRendererSuites(rendererSuiteFiles, omega);
|
|
204
205
|
passed += r.passed;
|
|
205
206
|
failed += r.failed;
|
|
206
207
|
skipped += r.skipped;
|
|
@@ -217,7 +218,7 @@ async function runSuites() {
|
|
|
217
218
|
// Spawn a hidden BrowserWindow and run each renderer suite inside it. Each suite file is
|
|
218
219
|
// loaded via require() in main, then its tests are serialized to { name, runSource } and
|
|
219
220
|
// shipped over IPC for the renderer to reconstruct + execute.
|
|
220
|
-
async function runRendererSuites(files,
|
|
221
|
+
async function runRendererSuites(files, omega) {
|
|
221
222
|
// Serialize suites for transport. We can't ship functions directly via IPC, so we extract
|
|
222
223
|
// the function body of each test's `run` and ship that as a string. The renderer rebuilds
|
|
223
224
|
// it with `new Function('ctx', body)`.
|
|
@@ -262,9 +263,9 @@ async function runRendererSuites(files, manager) {
|
|
|
262
263
|
|
|
263
264
|
const harnessDir = __dirname;
|
|
264
265
|
// Tell the renderer-preload (running in the BrowserWindow's preload) where to
|
|
265
|
-
// require() the renderer
|
|
266
|
+
// require() the renderer instance from. We resolve by absolute path because the
|
|
266
267
|
// preload runs with the renderer's module resolution scope, not main's.
|
|
267
|
-
process.env.
|
|
268
|
+
process.env.OMEGA_TEST_RENDERER_PATH = path.resolve(__dirname, '..', '..', 'renderer.js');
|
|
268
269
|
|
|
269
270
|
// Register test-only IPC channels so renderer-layer tests can verify round-trip
|
|
270
271
|
// behavior end-to-end (renderer.invoke → main handler → response). Idempotent:
|
|
@@ -273,15 +274,15 @@ async function runRendererSuites(files, manager) {
|
|
|
273
274
|
ipcMain.handle('desktop:__test:echo', (_evt, payload) => ({ echoed: payload, ts: Date.now() }));
|
|
274
275
|
// Forwarded log capture — renderer logger.log(...) sends 'desktop:log:forward'; we
|
|
275
276
|
// accumulate the most recent payload so the renderer test can verify it landed.
|
|
276
|
-
global.
|
|
277
|
+
global.__omegaTestLastForwardedLog = null;
|
|
277
278
|
ipcMain.removeAllListeners('desktop:__test:forwarded-log-tap');
|
|
278
279
|
ipcMain.on('desktop:log:forward', (_evt, payload) => {
|
|
279
|
-
global.
|
|
280
|
+
global.__omegaTestLastForwardedLog = payload;
|
|
280
281
|
});
|
|
281
282
|
// Test-only handler the renderer can call to read back the most recently
|
|
282
283
|
// forwarded log payload. Returns null if none yet.
|
|
283
284
|
try { ipcMain.removeHandler('desktop:__test:read-last-log'); } catch (_) { /* ignore */ }
|
|
284
|
-
ipcMain.handle('desktop:__test:read-last-log', () => global.
|
|
285
|
+
ipcMain.handle('desktop:__test:read-last-log', () => global.__omegaTestLastForwardedLog);
|
|
285
286
|
// Analytics sender tap ([#411](https://github.com/Omega-JS-Stack/omega/issues/411)):
|
|
286
287
|
// renderer-originated omega.analytics() calls forward over IPC and must fire
|
|
287
288
|
// through main's ONE sender, so a renderer suite needs to read back what that
|
|
@@ -296,17 +297,17 @@ async function runRendererSuites(files, manager) {
|
|
|
296
297
|
// identity fields), so a suite asserts on `client_id` as GA would receive it
|
|
297
298
|
// rather than on a field the tap made up.
|
|
298
299
|
const analyticsCore = require('../../vendor/analytics/core.js');
|
|
299
|
-
global.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
global.
|
|
300
|
+
global.__omegaTestAnalyticsSends = [];
|
|
301
|
+
omega.analytics.shutdown();
|
|
302
|
+
omega.analytics._send = (descriptor) => {
|
|
303
|
+
global.__omegaTestAnalyticsSends.push({
|
|
303
304
|
provider: descriptor.provider,
|
|
304
305
|
name: descriptor.name,
|
|
305
306
|
payload: descriptor.payload,
|
|
306
307
|
body: analyticsCore.buildPayload({
|
|
307
|
-
clientId:
|
|
308
|
-
userId:
|
|
309
|
-
userProperties:
|
|
308
|
+
clientId: omega.analytics._clientId,
|
|
309
|
+
userId: omega.analytics._userId,
|
|
310
|
+
userProperties: omega.analytics._userProperties,
|
|
310
311
|
eventName: descriptor.name,
|
|
311
312
|
params: descriptor.payload,
|
|
312
313
|
}),
|
|
@@ -314,10 +315,10 @@ async function runRendererSuites(files, manager) {
|
|
|
314
315
|
return true;
|
|
315
316
|
};
|
|
316
317
|
process.env.GOOGLE_ANALYTICS_SECRET = 'harness-secret';
|
|
317
|
-
|
|
318
|
-
|
|
318
|
+
omega.config.analytics = { providers: { google: { id: 'G-HARNESS1' } } };
|
|
319
|
+
omega.analytics.initialize(omega);
|
|
319
320
|
try { ipcMain.removeHandler('desktop:__test:read-analytics-sends'); } catch (_) { /* ignore */ }
|
|
320
|
-
ipcMain.handle('desktop:__test:read-analytics-sends', () => global.
|
|
321
|
+
ipcMain.handle('desktop:__test:read-analytics-sends', () => global.__omegaTestAnalyticsSends);
|
|
321
322
|
const win = new BrowserWindow({
|
|
322
323
|
show: false,
|
|
323
324
|
width: 800,
|
|
@@ -337,16 +338,16 @@ async function runRendererSuites(files, manager) {
|
|
|
337
338
|
if (resolved) return;
|
|
338
339
|
resolved = true;
|
|
339
340
|
try { win.destroy(); } catch (_e) { /* noop */ }
|
|
340
|
-
ipcMain.removeAllListeners('
|
|
341
|
-
ipcMain.removeAllListeners('
|
|
341
|
+
ipcMain.removeAllListeners('__omegaTest:ready');
|
|
342
|
+
ipcMain.removeAllListeners('__omegaTest:result');
|
|
342
343
|
if (err) reject(err); else resolve(val);
|
|
343
344
|
};
|
|
344
345
|
|
|
345
|
-
ipcMain.on('
|
|
346
|
-
win.webContents.send('
|
|
346
|
+
ipcMain.on('__omegaTest:ready', () => {
|
|
347
|
+
win.webContents.send('__omegaTest:suites', suites);
|
|
347
348
|
});
|
|
348
349
|
|
|
349
|
-
ipcMain.on('
|
|
350
|
+
ipcMain.on('__omegaTest:result', (_e, evt) => {
|
|
350
351
|
// Forward verbatim to stdout — same envelope as main-process events.
|
|
351
352
|
emit(evt);
|
|
352
353
|
if (evt.event === 'result') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Renderer test-harness entry. Runs inside the hidden BrowserWindow.
|
|
2
2
|
//
|
|
3
3
|
// Lifecycle:
|
|
4
|
-
// 1. window load →
|
|
5
|
-
// 2. main sends suites via
|
|
4
|
+
// 1. window load → __omegaTest.ready()
|
|
5
|
+
// 2. main sends suites via __omegaTest:suites
|
|
6
6
|
// 3. renderer reconstructs each test fn via new Function('ctx', body), runs it sequentially
|
|
7
7
|
// 4. emits { event, ... } for each result; emits { event: 'end' } when done
|
|
8
8
|
//
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
function emit(evt) {
|
|
27
|
-
try { window.
|
|
27
|
+
try { window.__omegaTest.emit(evt); } catch (e) { /* harness gone */ }
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Tiny inline expect — mirrors src/test/assert.js minimal surface used by tests.
|
|
@@ -162,12 +162,12 @@
|
|
|
162
162
|
emit({ event: 'end', passed, failed, skipped });
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
window.
|
|
165
|
+
window.__omegaTest.onSuites((suites) => {
|
|
166
166
|
runAll(suites).catch((e) => {
|
|
167
167
|
emit({ event: 'fatal', message: e.message, stack: e.stack });
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
// Signal ready as soon as the page is parsed.
|
|
172
|
-
window.
|
|
172
|
+
window.__omegaTest.ready();
|
|
173
173
|
})();
|