Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Pin channels in Stable test fixtures (#7516)

Nick Gomezd27127295c25
diff --git a/packages/cli/src/commands/auth/validate-host.test.ts b/packages/cli/src/commands/auth/validate-host.test.ts
index 96b5143d6..0bcc5dfc9 100644
--- a/packages/cli/src/commands/auth/validate-host.test.ts
+++ b/packages/cli/src/commands/auth/validate-host.test.ts
@@ -21,6 +21,7 @@ let home: string;
beforeEach(() => {
home = mkdtempSync(join(tmpdir(), 'ok-validate-host-home-'));
+ vi.stubEnv('OK_CHANNEL', 'stable');
vi.stubEnv('HOME', home);
vi.stubEnv('USERPROFILE', home);
});
diff --git a/packages/cli/src/commands/channel-mcp-key.test.ts b/packages/cli/src/commands/channel-mcp-key.test.ts
index 0519ae129..32c55ff55 100644
--- a/packages/cli/src/commands/channel-mcp-key.test.ts
+++ b/packages/cli/src/commands/channel-mcp-key.test.ts
@@ -104,6 +104,7 @@ describe('per-channel MCP registration', () => {
let home: string;
beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
home = mkdtempSync(join(tmpdir(), 'ok-channel-key-'));
});
@@ -130,6 +131,7 @@ describe('per-channel MCP registration', () => {
'open-knowledge'
],
);
+ expect(stableEntry).toBeDefined();
vi.stubEnv('OK_CHANNEL', 'beta');
const servers = writeClaude();
diff --git a/packages/cli/src/commands/deinit.test.ts b/packages/cli/src/commands/deinit.test.ts
index 941bd5bfe..afb6caa4f 100644
--- a/packages/cli/src/commands/deinit.test.ts
+++ b/packages/cli/src/commands/deinit.test.ts
@@ -11,12 +11,21 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { Readable } from 'node:stream';
import { MCP_SERVER_NAME } from '@inkeep/open-knowledge-server';
-import { describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { deinitCommand, runDeinit } from './deinit.ts';
import { buildManagedServerEntry } from './editors.ts';
import { ensurePiBridge } from './pi-acp-bridge.ts';
-const OWN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+let ownEntry: ReturnType<typeof buildManagedServerEntry>;
+
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ ownEntry = buildManagedServerEntry({ mode: 'published' });
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
function write(path: string, content: string): void {
mkdirSync(dirname(path), { recursive: true });
@@ -34,7 +43,7 @@ function seedProject(home: string = seedHome()): string {
write(join(dir, '.okignore'), 'secret.md\n');
write(
join(dir, '.mcp.json'),
- `${JSON.stringify({ mcpServers: { mine: { command: 'x' }, [MCP_SERVER_NAME]: OWN_ENTRY } }, null, 2)}\n`,
+ `${JSON.stringify({ mcpServers: { mine: { command: 'x' }, [MCP_SERVER_NAME]: ownEntry } }, null, 2)}\n`,
);
write(join(dir, '.claude', 'skills', 'open-knowledge', 'SKILL.md'), '# ok\n');
write(join(dir, 'notes.md'), '# my notes\n');
@@ -368,7 +377,7 @@ test('keeps project state after incomplete config cleanup so a repaired config c
const first = await runDeinit(opts);
expect(first.status).toBe('failed');
expect(existsSync(join(project, '.ok', 'config.yml'))).toBe(true);
- write(configPath, JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: OWN_ENTRY } }));
+ write(configPath, JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: ownEntry } }));
const second = await runDeinit(opts);
expect(second.status).toBe('done');
expect(existsSync(join(project, '.ok'))).toBe(false);
diff --git a/packages/cli/src/commands/init.test.ts b/packages/cli/src/commands/init.test.ts
index 3430c45cb..8c1faeb6c 100644
--- a/packages/cli/src/commands/init.test.ts
+++ b/packages/cli/src/commands/init.test.ts
@@ -75,6 +75,14 @@ vi.mock('@inkeep/open-knowledge-server', async (importOriginal) => {
const NATIVE_TOML_AVAILABLE = createTomlConfigEngine().backend === 'native';
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
async function runInit(...args: Parameters<typeof runInitProduct>) {
const result = await runInitProduct(...args);
if (result.didGitInit || existsSync(join(result.projectRoot, '.git', 'config'))) {
diff --git a/packages/cli/src/commands/mcp-config-removal.test.ts b/packages/cli/src/commands/mcp-config-removal.test.ts
index 29d6c16a9..5f0f9e480 100644
--- a/packages/cli/src/commands/mcp-config-removal.test.ts
+++ b/packages/cli/src/commands/mcp-config-removal.test.ts
@@ -14,7 +14,7 @@ import {
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { MCP_SERVER_NAME } from '@inkeep/open-knowledge-server';
-import { describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { buildPiExtensionSource } from '../integrations/pi-extension.ts';
import {
createTomlConfigEngine,
@@ -32,7 +32,16 @@ function tmp(): string {
return realpathSync(mkdtempSync(join(tmpdir(), 'ok-mcp-remove-')));
}
-const OWN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+let ownEntry: ReturnType<typeof buildManagedServerEntry>;
+
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ ownEntry = buildManagedServerEntry({ mode: 'published' });
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
describe('removeOwnMcpEntry — JSON', () => {
test('removes only OK’s entry, preserving a sibling server + its comment', () => {
@@ -43,7 +52,7 @@ describe('removeOwnMcpEntry — JSON', () => {
// my mcp servers
"mcpServers": {
"other": { "command": "node", "args": ["server.js"] },
- "${MCP_SERVER_NAME}": ${JSON.stringify(OWN_ENTRY)}
+ "${MCP_SERVER_NAME}": ${JSON.stringify(ownEntry)}
}
}
`;
@@ -66,7 +75,7 @@ describe('removeOwnMcpEntry — JSON', () => {
const configPath = join(dir, 'config.json');
writeFileSync(
configPath,
- `${JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: OWN_ENTRY } }, null, 2)}\n`,
+ `${JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: ownEntry } }, null, 2)}\n`,
);
const outcome = removeOwnMcpEntry(EDITOR_TARGETS.claude, dir, undefined, configPath);
expect(outcome.kind).toBe('removed');
@@ -116,7 +125,7 @@ describe('removeOwnMcpEntry — JSON', () => {
const configPath = join(dir, 'config.json');
writeFileSync(
configPath,
- `${JSON.stringify({ mcpServers: { other: { command: 'x' }, [MCP_SERVER_NAME]: OWN_ENTRY } }, null, 2)}\n`,
+ `${JSON.stringify({ mcpServers: { other: { command: 'x' }, [MCP_SERVER_NAME]: ownEntry } }, null, 2)}\n`,
);
expect(removeOwnMcpEntry(EDITOR_TARGETS.claude, dir, undefined, configPath).kind).toBe(
'removed',
@@ -183,7 +192,7 @@ describe('removeOwnMcpEntry — JSON', () => {
const dir = tmp();
try {
const configPath = join(dir, 'bom.json');
- const raw = `\uFEFF${JSON.stringify({ mcpServers: { other: { command: 'x' }, [MCP_SERVER_NAME]: OWN_ENTRY } }, null, 2)}\n`;
+ const raw = `\uFEFF${JSON.stringify({ mcpServers: { other: { command: 'x' }, [MCP_SERVER_NAME]: ownEntry } }, null, 2)}\n`;
writeFileSync(configPath, raw);
expect(removeOwnMcpEntry(EDITOR_TARGETS.claude, dir, undefined, configPath).kind).toBe(
'removed',
@@ -203,7 +212,7 @@ describe('removeOwnMcpEntry — TOML (Codex)', () => {
const dir = tmp();
try {
const configPath = join(dir, 'config.toml');
- const chain = (OWN_ENTRY.args as string[])[2];
+ const chain = (ownEntry.args as string[])[2];
const raw = `# codex config\nmodel = "gpt-5"\n\n[mcp_servers.other]\ncommand = "node" # keep me\n\n[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "/bin/sh"\nargs = ["-l", "-c", ${JSON.stringify(chain)}]\n`;
writeFileSync(configPath, raw);
const outcome = removeOwnMcpEntry(EDITOR_TARGETS.codex, dir, undefined, configPath);
@@ -237,7 +246,7 @@ describe('removeOwnMcpEntry — TOML (Codex)', () => {
const dir = tmp();
try {
const configPath = join(dir, 'config.toml');
- const chain = (OWN_ENTRY.args as string[])[2];
+ const chain = (ownEntry.args as string[])[2];
const raw = `# codex\r\n[mcp_servers.other]\r\ncommand = "node"\r\n\r\n[mcp_servers.${MCP_SERVER_NAME}]\r\ncommand = "/bin/sh"\r\nargs = ["-l", "-c", ${JSON.stringify(chain)}]\r\n`;
writeFileSync(configPath, raw);
expect(removeOwnMcpEntry(EDITOR_TARGETS.codex, dir, undefined, configPath).kind).toBe(
@@ -270,7 +279,7 @@ describe('removeOwnMcpEntry — TOML (Codex)', () => {
const dir = tmp();
try {
const configPath = join(dir, 'config.toml');
- const chain = (OWN_ENTRY.args as string[])[2];
+ const chain = (ownEntry.args as string[])[2];
const raw = `[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "/bin/sh"\nargs = ["-l", "-c", ${JSON.stringify(chain)}]\n`;
writeFileSync(configPath, raw);
setTomlConfigEngineForTesting(createTomlConfigEngine(() => null));
@@ -516,13 +525,13 @@ describe('removeOwnMcpEntry — symlinks', () => {
try {
const configPath = join(dir, 'config');
const targetPath = join(dir, 'dotfiles-config');
- const chain = (OWN_ENTRY.args as string[])[2];
+ const chain = (ownEntry.args as string[])[2];
const raw =
editorId === 'codex'
? `# user configuration\n[mcp_servers.other]\ncommand = "node"\n\n[mcp_servers.${MCP_SERVER_NAME}]\ncommand = "/bin/sh"\nargs = ["-l", "-c", ${JSON.stringify(chain)}]\n`
: editorId === 'hermes'
- ? `# user configuration\nmcp_servers:\n other:\n command: node\n ${MCP_SERVER_NAME}: ${JSON.stringify(OWN_ENTRY)}\n`
- : `{\n // user configuration\n "mcpServers": {"other": {"command": "node"}, "${MCP_SERVER_NAME}": ${JSON.stringify(OWN_ENTRY)}}\n}\n`;
+ ? `# user configuration\nmcp_servers:\n other:\n command: node\n ${MCP_SERVER_NAME}: ${JSON.stringify(ownEntry)}\n`
+ : `{\n // user configuration\n "mcpServers": {"other": {"command": "node"}, "${MCP_SERVER_NAME}": ${JSON.stringify(ownEntry)}}\n}\n`;
writeFileSync(targetPath, raw, { mode: 0o640 });
symlinkSync('dotfiles-config', join(dir, 'intermediate'));
symlinkSync('intermediate', configPath);
diff --git a/packages/cli/src/commands/removal-plan.test.ts b/packages/cli/src/commands/removal-plan.test.ts
index 1072c863b..0cffe1069 100644
--- a/packages/cli/src/commands/removal-plan.test.ts
+++ b/packages/cli/src/commands/removal-plan.test.ts
@@ -14,7 +14,7 @@ import { tmpdir } from 'node:os';
import { dirname, join, relative } from 'node:path';
import { SHARED_OK_ENTRIES } from '@inkeep/open-knowledge-core';
import { MCP_SERVER_NAME } from '@inkeep/open-knowledge-server';
-import { afterEach, describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { DESKTOP_UPDATER_CACHE_DIR_NAME } from '../integrations/desktop-state.ts';
import { readPathInstallMarker } from '../integrations/path-shim.ts';
import {
@@ -42,7 +42,16 @@ import {
removalPlanToJson,
} from './removal-render.ts';
-const OWN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+let OWN_ENTRY: ReturnType<typeof buildManagedServerEntry>;
+
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ OWN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
function write(path: string, content: string): void {
mkdirSync(dirname(path), { recursive: true });
diff --git a/packages/cli/src/commands/repair-mcp-configs.test.ts b/packages/cli/src/commands/repair-mcp-configs.test.ts
index 5fce05702..a48bda07b 100644
--- a/packages/cli/src/commands/repair-mcp-configs.test.ts
+++ b/packages/cli/src/commands/repair-mcp-configs.test.ts
@@ -11,8 +11,8 @@ vi.mock('./init.ts', async (importOriginal) => {
return { ...actual, writeEditorMcpConfig: vi.fn(actual.writeEditorMcpConfig) };
});
-const CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published' });
-const WIN_CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });
+let CHAIN_ENTRY: ReturnType<typeof buildManagedServerEntry>;
+let WIN_CHAIN_ENTRY: ReturnType<typeof buildManagedServerEntry>;
const CMD_WORKAROUND = {
command: 'cmd',
args: ['/c', 'C:\\Users\\me\\AppData\\Roaming\\npm\\ok.cmd', 'mcp'],
@@ -36,6 +36,7 @@ describe('repairMcpConfigs', () => {
let logEvents: RepairLogEvent[];
beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
testDir = resolve(
tmpdir(),
`repair-mcp-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
@@ -45,10 +46,13 @@ describe('repairMcpConfigs', () => {
mkdirSync(join(fakeHome, '.claude'), { recursive: true });
mkdirSync(projectDir, { recursive: true });
Object.defineProperty(process, 'platform', { value: 'darwin', configurable: true });
+ CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+ WIN_CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published', platformName: 'win32' });
logEvents = [];
});
afterEach(() => {
+ vi.unstubAllEnvs();
Object.defineProperty(process, 'platform', { value: originalPlatform, configurable: true });
rmSync(testDir, { recursive: true, force: true });
});
diff --git a/packages/cli/src/config/loader.test.ts b/packages/cli/src/config/loader.test.ts
index 07724e359..3ec361abc 100644
--- a/packages/cli/src/config/loader.test.ts
+++ b/packages/cli/src/config/loader.test.ts
@@ -28,6 +28,7 @@ const { OK_DIR } = await import('../constants.ts');
const { createProjectConfigResolver, loadConfig } = await import('./loader');
beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
testDir = resolve(
tmpdir(),
`ok-config-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
@@ -37,6 +38,7 @@ beforeEach(() => {
});
afterEach(() => {
+ vi.unstubAllEnvs();
rmSync(testDir, { recursive: true, force: true });
});
diff --git a/packages/cli/src/integrations/project-integration-writers.test.ts b/packages/cli/src/integrations/project-integration-writers.test.ts
index 8533f7163..5ebbf1e7e 100644
--- a/packages/cli/src/integrations/project-integration-writers.test.ts
+++ b/packages/cli/src/integrations/project-integration-writers.test.ts
@@ -9,7 +9,7 @@ import {
} from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
-import { afterEach, beforeEach, describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { buildManagedServerEntry, EDITOR_TARGETS, type EditorId } from '../commands/editors.ts';
import {
applyProjectIntegrations,
@@ -19,21 +19,24 @@ import {
projectSkillWriter,
} from './project-integration-writers.ts';
-const OWN_MCP_ENTRY = buildManagedServerEntry({
- mode: 'published',
- platformName: process.platform,
-});
+let ownMcpEntry: ReturnType<typeof buildManagedServerEntry>;
let tmpRoot: string;
let projectDir: string;
beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ ownMcpEntry = buildManagedServerEntry({
+ mode: 'published',
+ platformName: process.platform,
+ });
tmpRoot = realpathSync(mkdtempSync(resolve(tmpdir(), 'ok-project-integration-writers-')));
projectDir = resolve(tmpRoot, 'proj');
mkdirSync(projectDir, { recursive: true });
});
afterEach(() => {
+ vi.unstubAllEnvs();
rmSync(tmpRoot, { recursive: true, force: true });
});
@@ -169,7 +172,7 @@ describe('projectSkillWriter', () => {
writeFileSync(
join(copilotHome, 'mcp-config.json'),
JSON.stringify({
- mcpServers: { 'open-knowledge': OWN_MCP_ENTRY },
+ mcpServers: { 'open-knowledge': ownMcpEntry },
}),
);
@@ -244,7 +247,7 @@ describe('projectSkillWriter', () => {
writeFileSync(
join(projectDir, '.mcp.json'),
JSON.stringify({
- mcpServers: { 'open-knowledge': { ...OWN_MCP_ENTRY, enabled: false } },
+ mcpServers: { 'open-knowledge': { ...ownMcpEntry, enabled: false } },
}),
);
@@ -275,7 +278,7 @@ describe('projectSkillWriter', () => {
writeFileSync(
join(projectDir, '.mcp.json'),
JSON.stringify({
- mcpServers: { 'open-knowledge': OWN_MCP_ENTRY },
+ mcpServers: { 'open-knowledge': ownMcpEntry },
}),
);
diff --git a/packages/core/src/config/errors.test.ts b/packages/core/src/config/errors.test.ts
index 10dfc5973..a6bd19800 100644
--- a/packages/core/src/config/errors.test.ts
+++ b/packages/core/src/config/errors.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import {
ConfigDiagnosticSchema,
ConfigDiagnosticsReportSchema,
@@ -145,6 +145,14 @@ describe('ConfigValidationErrorSchema', () => {
});
describe('humanFormat', () => {
+ beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
test('VALUE_FALLBACK describes recovered settings without rejecting the file or exposing its value', () => {
const diagnostic = {
code: 'VALUE_FALLBACK',
diff --git a/packages/core/src/config/write-config-patch.test.ts b/packages/core/src/config/write-config-patch.test.ts
index e5ba8db5b..c3507339e 100644
--- a/packages/core/src/config/write-config-patch.test.ts
+++ b/packages/core/src/config/write-config-patch.test.ts
@@ -9,17 +9,19 @@ import {
} from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-import { afterEach, beforeEach, describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { isKnownConfigError } from './errors.ts';
import { resolveConfigPath, writeConfigPatch } from './write-config-patch.ts';
let testDir: string;
beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
testDir = mkdtempSync(join(tmpdir(), 'ok-write-config-patch-'));
});
afterEach(() => {
+ vi.unstubAllEnvs();
if (existsSync(testDir)) rmSync(testDir, { recursive: true, force: true });
});
diff --git a/packages/core/src/constants/mcp-launcher.test.ts b/packages/core/src/constants/mcp-launcher.test.ts
index 92604fbda..6d5999412 100644
--- a/packages/core/src/constants/mcp-launcher.test.ts
+++ b/packages/core/src/constants/mcp-launcher.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import {
classifyMcpLauncherEntry,
DEFAULT_MCP_LAUNCHER_REVISION_CATALOG,
@@ -94,6 +94,14 @@ const SHAPES = [
] as const;
describe('classifyMcpLauncherEntry', () => {
+ beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
test('keeps the current Unix launcher and describes its recognized contract', () => {
expect(
classifyMcpLauncherEntry({
diff --git a/packages/core/src/constants/ok-dir.test.ts b/packages/core/src/constants/ok-dir.test.ts
index 89766be45..2f67e6b5c 100644
--- a/packages/core/src/constants/ok-dir.test.ts
+++ b/packages/core/src/constants/ok-dir.test.ts
@@ -1,5 +1,5 @@
import { posix } from 'node:path';
-import { afterEach, describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { OK_BIN_DIRNAME, OK_DIR, okUserHomeDisplayPath, posixOkManagedBinDir } from './ok-dir.ts';
describe('okUserHomeDisplayPath', () => {
@@ -22,6 +22,14 @@ describe('okUserHomeDisplayPath', () => {
});
describe('posixOkManagedBinDir', () => {
+ beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
test('is the OK dir plus the bin dirname, under the given home', () => {
expect(posixOkManagedBinDir('/Users/alice')).toBe(`/Users/alice/${OK_DIR}/${OK_BIN_DIRNAME}`);
expect(posixOkManagedBinDir('/Users/alice')).toBe('/Users/alice/.ok/bin');
diff --git a/packages/desktop/src/main/integrations-settings.test.ts b/packages/desktop/src/main/integrations-settings.test.ts
index 200c913d3..4798d3419 100644
--- a/packages/desktop/src/main/integrations-settings.test.ts
+++ b/packages/desktop/src/main/integrations-settings.test.ts
@@ -1,6 +1,6 @@
import { EMPTY_DETECTION_SNAPSHOT, EMPTY_PROBE_SNAPSHOT } from '@inkeep/open-knowledge-core';
import type { IpcMainInvokeEvent } from 'electron';
-import { describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { writeUserMcpConfigs } from '../../../cli/src/commands/init.ts';
import type {
AgentIntegrationsApplyRequest,
@@ -393,6 +393,14 @@ describe('ok:integrations:dispatch — status', () => {
});
describe('ok:integrations:dispatch — set editor', () => {
+ beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
test('enable writes the one editor and returns ok with a fresh snapshot', async () => {
const cli = makeCli();
const { set } = setup({ cli });
diff --git a/packages/desktop/src/main/mcp-wiring.test.ts b/packages/desktop/src/main/mcp-wiring.test.ts
index 9dfa6427f..d6e5b358f 100644
--- a/packages/desktop/src/main/mcp-wiring.test.ts
+++ b/packages/desktop/src/main/mcp-wiring.test.ts
@@ -17,7 +17,7 @@ import {
type EditorMcpTarget,
type McpEntryClassification,
} from '@inkeep/open-knowledge';
-import { afterEach, describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import {
classifyExistingMcpEntry as classifyWithOverridableEngine,
writeUserMcpConfigs,
@@ -66,6 +66,14 @@ function memoryFs(
const PACKAGED_EXE = '/Applications/OpenKnowledge.app/Contents/MacOS/OpenKnowledge';
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
function fakeTarget(id: McpWiringEditorId): EditorMcpTarget {
return {
id,
diff --git a/packages/desktop/src/main/project-integrations-settings.test.ts b/packages/desktop/src/main/project-integrations-settings.test.ts
index 2e3e957f8..fb3971278 100644
--- a/packages/desktop/src/main/project-integrations-settings.test.ts
+++ b/packages/desktop/src/main/project-integrations-settings.test.ts
@@ -11,7 +11,7 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import type { McpEntryClassification } from '@inkeep/open-knowledge';
import type { IpcMainInvokeEvent } from 'electron';
-import { describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { EDITOR_TARGETS } from '../../../cli/src/commands/editors.ts';
import { removeOwnMcpEntry } from '../../../cli/src/commands/mcp-config-removal.ts';
import { ensurePiBridge } from '../../../cli/src/commands/pi-acp-bridge.ts';
@@ -229,6 +229,14 @@ describe('registerProjectIntegrationsSettings — status', () => {
});
describe('registerProjectIntegrationsSettings — set', () => {
+ beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ });
+
+ afterEach(() => {
+ vi.unstubAllEnvs();
+ });
+
test('editor install writes the config and returns ok', async () => {
const cli = makeCli();
const { set } = register(cli);
diff --git a/packages/desktop/src/main/project-mcp-reclaim.test.ts b/packages/desktop/src/main/project-mcp-reclaim.test.ts
index 26b412aa8..72343f81c 100644
--- a/packages/desktop/src/main/project-mcp-reclaim.test.ts
+++ b/packages/desktop/src/main/project-mcp-reclaim.test.ts
@@ -4,7 +4,7 @@ import {
type McpDeclineReason,
type McpEntryClassification,
} from '@inkeep/open-knowledge';
-import { describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import type { McpWiringEditorId } from '../shared/ipc-channels.ts';
import {
checkAndRepairProjectMcpOnProjectOpen,
@@ -12,12 +12,21 @@ import {
} from './project-mcp-reclaim.ts';
const EXE = '/Applications/OpenKnowledge.app/Contents/MacOS/OpenKnowledge';
-const CHAIN_ENTRY = buildManagedServerEntry({ mode: 'published' });
+let chainEntry: ReturnType<typeof buildManagedServerEntry>;
const KNOWN_OLDER_ENTRY = {
command: '/bin/sh',
args: ['-l', '-c', '# ok-mcp-v1\nexit 127'],
};
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+ chainEntry = buildManagedServerEntry({ mode: 'published' });
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
function fakeTarget(id: McpWiringEditorId, projectConfigPath?: string): EditorMcpTarget {
return {
id,
@@ -26,7 +35,7 @@ function fakeTarget(id: McpWiringEditorId, projectConfigPath?: string): EditorMc
topLevelKey: 'mcpServers',
serverName: () => 'open-knowledge',
configPath: () => `/home/${id}/config.json`,
- buildEntry: () => CHAIN_ENTRY,
+ buildEntry: () => chainEntry,
scope: 'global',
...(projectConfigPath ? { projectConfigPath: () => projectConfigPath } : {}),
};
@@ -187,7 +196,7 @@ describe('checkAndRepairProjectMcpOnProjectOpen', () => {
const { cli, writes } = buildCli({
claude: {
target: fakeTarget('claude' as McpWiringEditorId, '/p/.mcp.json'),
- classification: { kind: 'present', entry: CHAIN_ENTRY },
+ classification: { kind: 'present', entry: chainEntry },
},
});
const r = await checkAndRepairProjectMcpOnProjectOpen({
@@ -208,7 +217,7 @@ describe('checkAndRepairProjectMcpOnProjectOpen', () => {
target: fakeTarget('claude' as McpWiringEditorId, '/p/.mcp.json'),
classification: {
kind: 'present',
- entry: { ...CHAIN_ENTRY, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
+ entry: { ...chainEntry, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
},
},
});
@@ -256,7 +265,7 @@ describe('checkAndRepairProjectMcpOnProjectOpen', () => {
target: fakeTarget('claude' as McpWiringEditorId, '/p/.mcp.json'),
classification: {
kind: 'present',
- entry: { ...CHAIN_ENTRY, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
+ entry: { ...chainEntry, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
},
writeOutcome: { action: 'declined', reason: 'no-native-writer' },
},
@@ -281,7 +290,7 @@ describe('checkAndRepairProjectMcpOnProjectOpen', () => {
target: fakeTarget('claude' as McpWiringEditorId, '/p/.mcp.json'),
classification: {
kind: 'present',
- entry: { ...CHAIN_ENTRY, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
+ entry: { ...chainEntry, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
},
writeOutcome: { action: 'failed', error: 'EACCES' },
},
@@ -305,7 +314,7 @@ describe('checkAndRepairProjectMcpOnProjectOpen', () => {
target: fakeTarget('claude' as McpWiringEditorId, '/p/.mcp.json'),
classification: {
kind: 'present',
- entry: { ...CHAIN_ENTRY, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
+ entry: { ...chainEntry, env: { NODE_OPTIONS: '--require ./payload.cjs' } },
},
writeOutcome: { action: 'unchanged' },
},
diff --git a/packages/server/src/share/git-context.test.ts b/packages/server/src/share/git-context.test.ts
index f0a89d025..0a7105248 100644
--- a/packages/server/src/share/git-context.test.ts
+++ b/packages/server/src/share/git-context.test.ts
@@ -1,7 +1,7 @@
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, relative, resolve } from 'node:path';
-import { afterEach, beforeEach, describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import {
branchExistsOnOrigin,
createSyncCredentialConfigResolver,
@@ -61,6 +61,14 @@ function seedRepo(
const home = useIsolatedHome();
+beforeEach(() => {
+ vi.stubEnv('OK_CHANNEL', 'stable');
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
const CANONICAL_HEAD = 'ref: refs/heads/main\n';
const OID_A = 'a'.repeat(40);
const OID_B = 'b'.repeat(40);