AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
test(desktop): preserve macOS main and Helper naming invariant (#776)
tianma-iff2eec174c8a9
diff --git a/scripts/build-native-update-fixtures.mjs b/scripts/build-native-update-fixtures.mjsindex 60b85ace..c06af0ef 100644--- a/scripts/build-native-update-fixtures.mjs+++ b/scripts/build-native-update-fixtures.mjs@@ -1,4 +1,4 @@-import { macAppBundle } from "./native-update-macos.mjs";+import { macAppBundle, assertMacFixtureRuntime, MAC_UPDATE_FIXTURE_NAME } from "./native-update-macos.mjs";import { createRequire } from "node:module";import { generateKeyPairSync, createHash } from "node:crypto";import { readFileSync, writeFileSync, mkdirSync, copyFileSync, rmSync } from "node:fs";@@ -48,7 +48,9 @@ try {const directory = join(output, version);const config = {extends: "./electron-builder.yml", appId: "org.edgeever.update-verifier",- productName: "EdgeEver Update Verification", executableName: "EdgeEverUpdateVerifier",+ // The product resolves its background Helper from the executable name.+ productName: process.platform === "darwin" ? MAC_UPDATE_FIXTURE_NAME : "EdgeEver Update Verification",+ executableName: MAC_UPDATE_FIXTURE_NAME,directories: { output: directory },mac: { notarize: false },// Keep the test installer isolated from production protocol associations.@@ -57,6 +59,9 @@ try {writeFileSync(configPath, JSON.stringify(config));const target = process.platform === "darwin" ? ["--mac", "zip"] : process.platform === "win32" ? ["--win", "nsis"] : ["--linux", "AppImage"];run(process.execPath, [builderCli, "--projectDir", desktop, "--config", configPath, "--publish", "never", ...target, `--${process.arch}`], desktop);+ if (process.platform === "darwin") {+ assertMacFixtureRuntime(macAppBundle(join(directory, process.arch === "arm64" ? "mac-arm64" : "mac")));+ }const payload = process.platform === "darwin"? join(macAppBundle(join(directory, process.arch === "arm64" ? "mac-arm64" : "mac")), "Contents/Resources/app.asar"): process.platform === "win32" ? join(directory, "win-unpacked/resources/app.asar")diff --git a/scripts/native-update-instrumentation.test.mjs b/scripts/native-update-instrumentation.test.mjsindex 2377a2c6..091b77c2 100644--- a/scripts/native-update-instrumentation.test.mjs+++ b/scripts/native-update-instrumentation.test.mjs@@ -1,10 +1,11 @@-import { readFileSync, mkdtempSync, writeFileSync, rmSync, mkdirSync } from "node:fs";+import { readFileSync, mkdtempSync, writeFileSync, rmSync, mkdirSync, chmodSync } from "node:fs";import { join } from "node:path";import { tmpdir } from "node:os";import { spawnSync } from "node:child_process";import { Script, runInNewContext } from "node:vm";import { expect, test } from "bun:test";-import { macAppBundle } from "./native-update-macos.mjs";+import { macAppBundle, MAC_UPDATE_FIXTURE_NAME } from "./native-update-macos.mjs";+import { backgroundNodeExecutable } from "../apps/desktop/src/main/background-node.mjs";import { instrumentNativeUpdateMain } from "./native-update-instrumentation.mjs";const main = readFileSync(new URL("../apps/desktop/src/main/index.mjs", import.meta.url), "utf8");@@ -67,3 +68,22 @@ test("macOS fixture bundle discovery honors executableName and rejects ambiguityexpect(() => macAppBundle(directory)).toThrow("exactly one");} finally { rmSync(directory, { recursive: true, force: true }); }});++test("macOS fixture identity satisfies the actual product background Helper lookup", () => {+ const directory = mkdtempSync(join(tmpdir(), "edgeever-helper-invariant-"));+ try {+ const contents = join(directory, MAC_UPDATE_FIXTURE_NAME + ".app", "Contents");+ const executable = join(contents, "MacOS", MAC_UPDATE_FIXTURE_NAME);+ const helperName = MAC_UPDATE_FIXTURE_NAME + " Helper";+ const helper = join(contents, "Frameworks", helperName + ".app", "Contents", "MacOS", helperName);+ mkdirSync(join(contents, "MacOS"), { recursive: true });+ mkdirSync(join(contents, "Frameworks", helperName + ".app", "Contents", "MacOS"), { recursive: true });+ writeFileSync(helper, "fixture");+ chmodSync(helper, 0o755);+ expect(backgroundNodeExecutable(executable, "darwin")).toBe(helper);+ const builder = readFileSync(new URL("./build-native-update-fixtures.mjs", import.meta.url), "utf8");+ expect(builder).toContain('productName: process.platform === "darwin" ? MAC_UPDATE_FIXTURE_NAME');+ expect(builder).toContain('executableName: MAC_UPDATE_FIXTURE_NAME');+ expect(builder).toContain('assertMacFixtureRuntime(macAppBundle(');+ } finally { rmSync(directory, { recursive: true, force: true }); }+});diff --git a/scripts/native-update-macos.mjs b/scripts/native-update-macos.mjsindex 5bfc1030..b3bcc26f 100644--- a/scripts/native-update-macos.mjs+++ b/scripts/native-update-macos.mjs@@ -1,3 +1,4 @@+import { backgroundNodeExecutable } from "../apps/desktop/src/main/background-node.mjs";import { readdirSync, statSync } from "node:fs";import { join } from "node:path";import { spawnSync } from "node:child_process";@@ -13,3 +14,8 @@ export const macAppExecutable = (bundle) => {if (metadata.status !== 0) throw new Error("Cannot read the signed fixture's CFBundleExecutable");return join(bundle, "Contents/MacOS", metadata.stdout.trim());};++export const MAC_UPDATE_FIXTURE_NAME = "EdgeEverUpdateVerifier";++export const assertMacFixtureRuntime = (bundle) =>+ backgroundNodeExecutable(macAppExecutable(bundle), "darwin");diff --git a/scripts/verify-native-desktop-update.mjs b/scripts/verify-native-desktop-update.mjsindex 74eaa029..583b15a6 100644--- a/scripts/verify-native-desktop-update.mjs+++ b/scripts/verify-native-desktop-update.mjs@@ -160,7 +160,11 @@ try {};try {launch();- await until(() => events().some((entry) => entry.event === "ready" && entry.version === intermediateVersion), "intermediate package downloaded");+ await until(() => {+ const failure = readEvents(join(profile, "logs/desktop.log")).find((entry) => entry.event === "main.startup-failed");+ if (failure) throw new Error(`Fixture startup failed: ${failure.message}`);+ return events().some((entry) => entry.event === "ready" && entry.version === intermediateVersion);+ }, "intermediate package downloaded");feedVersion = latestVersion;if (scenario === "reject-corrupt-update") {if (process.platform === "win32") corruptSignature = true;