mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-04 02:00:10 +00:00
fix(ci): restore core lint line limits (#158625)
* fix(ci): restore core lint line limits Share the kernel test environment with fresh per-case copies and remove a redundant session publication map alias. Preserve all assertions, environment values, publication ordering, and stored state contracts. * test(gateway): keep health monitor fixtures within lint limits
This commit is contained in:
parent
2c914a1ddb
commit
8f22acdd74
4 changed files with 57 additions and 94 deletions
|
|
@ -557,11 +557,10 @@ export function publishSessionSharingEntryChange(
|
|||
publishTrackedCacheUpdate(
|
||||
database,
|
||||
() => {
|
||||
const entries = state.entries;
|
||||
if (current !== undefined) {
|
||||
entries.set(update.sessionKey, current);
|
||||
state.entries.set(update.sessionKey, current);
|
||||
} else {
|
||||
entries.delete(update.sessionKey);
|
||||
state.entries.delete(update.sessionKey);
|
||||
}
|
||||
},
|
||||
() => stageIncognitoSharingPublication(database.db, update.sessionKey),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { vi } from "vitest";
|
||||
import type { ChannelId, ChannelAccountSnapshot } from "../channels/plugins/types.public.js";
|
||||
import type { ChannelRuntimeSnapshot } from "./server-channel-runtime.types.js";
|
||||
import type { ChannelManager } from "./server-channels.js";
|
||||
|
||||
export function createMockChannelManager(overrides?: Partial<ChannelManager>): ChannelManager {
|
||||
|
|
@ -23,3 +25,32 @@ export function createMockChannelManager(overrides?: Partial<ChannelManager>): C
|
|||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function snapshotWith(
|
||||
accounts: Record<string, Record<string, Partial<ChannelAccountSnapshot>>>,
|
||||
): ChannelRuntimeSnapshot {
|
||||
const channels: ChannelRuntimeSnapshot["channels"] = {};
|
||||
const channelAccounts: ChannelRuntimeSnapshot["channelAccounts"] = {};
|
||||
for (const [channelId, accts] of Object.entries(accounts)) {
|
||||
const resolved: Record<string, ChannelAccountSnapshot> = {};
|
||||
for (const [accountId, partial] of Object.entries(accts)) {
|
||||
resolved[accountId] = { accountId, ...partial };
|
||||
}
|
||||
channelAccounts[channelId as ChannelId] = resolved;
|
||||
const firstId = Object.keys(accts)[0];
|
||||
if (firstId) {
|
||||
channels[channelId as ChannelId] = resolved[firstId];
|
||||
}
|
||||
}
|
||||
return { channels, channelAccounts };
|
||||
}
|
||||
|
||||
export function createSnapshotManager(
|
||||
accounts: Record<string, Record<string, Partial<ChannelAccountSnapshot>>>,
|
||||
overrides?: Partial<ChannelManager>,
|
||||
): ChannelManager {
|
||||
return createMockChannelManager({
|
||||
getRuntimeSnapshot: vi.fn(() => snapshotWith(accounts)),
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,43 +10,17 @@ import {
|
|||
createTestGatewayScheduler,
|
||||
} from "../test-utils/gateway-scheduler-clock.js";
|
||||
import { startChannelHealthMonitor } from "./channel-health-monitor.js";
|
||||
import { createMockChannelManager } from "./channel-health-monitor.test-support.js";
|
||||
import type { ChannelRuntimeSnapshot } from "./server-channel-runtime.types.js";
|
||||
import {
|
||||
createMockChannelManager,
|
||||
createSnapshotManager,
|
||||
snapshotWith,
|
||||
} from "./channel-health-monitor.test-support.js";
|
||||
import type { ChannelManager } from "./server-channels.js";
|
||||
|
||||
function snapshotWith(
|
||||
accounts: Record<string, Record<string, Partial<ChannelAccountSnapshot>>>,
|
||||
): ChannelRuntimeSnapshot {
|
||||
const channels: ChannelRuntimeSnapshot["channels"] = {};
|
||||
const channelAccounts: ChannelRuntimeSnapshot["channelAccounts"] = {};
|
||||
for (const [channelId, accts] of Object.entries(accounts)) {
|
||||
const resolved: Record<string, ChannelAccountSnapshot> = {};
|
||||
for (const [accountId, partial] of Object.entries(accts)) {
|
||||
resolved[accountId] = { accountId, ...partial };
|
||||
}
|
||||
channelAccounts[channelId as ChannelId] = resolved;
|
||||
const firstId = Object.keys(accts)[0];
|
||||
if (firstId) {
|
||||
channels[channelId as ChannelId] = resolved[firstId];
|
||||
}
|
||||
}
|
||||
return { channels, channelAccounts };
|
||||
}
|
||||
|
||||
const DEFAULT_CHECK_INTERVAL_MS = 5_000;
|
||||
let clock: ReturnType<typeof createGatewaySchedulerClock>;
|
||||
let scheduler: ReturnType<typeof createTestGatewayScheduler>;
|
||||
|
||||
function createSnapshotManager(
|
||||
accounts: Record<string, Record<string, Partial<ChannelAccountSnapshot>>>,
|
||||
overrides?: Partial<ChannelManager>,
|
||||
): ChannelManager {
|
||||
return createMockChannelManager({
|
||||
getRuntimeSnapshot: vi.fn(() => snapshotWith(accounts)),
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
function startDefaultMonitor(
|
||||
manager: ChannelManager,
|
||||
overrides: Partial<Omit<Parameters<typeof startChannelHealthMonitor>[0], "channelManager">> = {},
|
||||
|
|
|
|||
|
|
@ -38,6 +38,19 @@ import type { GatewayHostLifecycle, GatewayServer } from "./server-public.js";
|
|||
import { createMaintenanceHandles } from "./server-runtime-services.test-harness.js";
|
||||
import { expectCoreAgentDatabaseReadiness } from "./server-startup-readiness.test-support.js";
|
||||
|
||||
const KERNEL_TEST_ENV = {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
|
||||
VITEST: "1",
|
||||
};
|
||||
|
||||
describe("createGatewayKernel", () => {
|
||||
it.each([false, true])(
|
||||
"starts recovered channels only before close (closing=%s)",
|
||||
|
|
@ -47,16 +60,9 @@ describe("createGatewayKernel", () => {
|
|||
label: "gateway-kernel-breaker-recovery-close",
|
||||
layout: "home",
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
...KERNEL_TEST_ENV,
|
||||
OPENCLAW_SKIP_CHANNELS: undefined,
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: undefined,
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
|
||||
VITEST: "1",
|
||||
},
|
||||
});
|
||||
const originalPluginRegistry = captureActivePluginRegistrySnapshot();
|
||||
|
|
@ -156,18 +162,7 @@ describe("createGatewayKernel", () => {
|
|||
const state = await createOpenClawTestState({
|
||||
label: `gateway-kernel-${entry}-close-readiness`,
|
||||
layout: "home",
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
|
||||
VITEST: "1",
|
||||
},
|
||||
env: { ...KERNEL_TEST_ENV },
|
||||
});
|
||||
const token = "gateway-kernel-close-readiness-token";
|
||||
const bootId = `gateway-kernel-${entry}-close`;
|
||||
|
|
@ -385,16 +380,8 @@ describe("createGatewayKernel", () => {
|
|||
label: "gateway-kernel-reload-candidate",
|
||||
layout: "home",
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
...KERNEL_TEST_ENV,
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "0",
|
||||
VITEST: "1",
|
||||
},
|
||||
});
|
||||
const previousOverrides = getConfigOverrides();
|
||||
|
|
@ -549,16 +536,8 @@ describe("createGatewayKernel", () => {
|
|||
label: "gateway-kernel-deferred-readiness",
|
||||
layout: "home",
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
...KERNEL_TEST_ENV,
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "0",
|
||||
VITEST: "1",
|
||||
},
|
||||
});
|
||||
const token = "gateway-kernel-deferred-readiness-token";
|
||||
|
|
@ -786,16 +765,7 @@ describe("createGatewayKernel", () => {
|
|||
env: {
|
||||
OPENCLAW_DIAGNOSTICS: "1",
|
||||
OPENCLAW_DIAGNOSTICS_TIMELINE_PATH: undefined,
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
|
||||
VITEST: "1",
|
||||
...KERNEL_TEST_ENV,
|
||||
},
|
||||
});
|
||||
const originalPluginRegistry = captureActivePluginRegistrySnapshot();
|
||||
|
|
@ -987,18 +957,7 @@ describe("createGatewayKernel", () => {
|
|||
const state = await createOpenClawTestState({
|
||||
label: "gateway-kernel-tls-failure",
|
||||
layout: "home",
|
||||
env: {
|
||||
OPENCLAW_GATEWAY_PASSWORD: undefined,
|
||||
OPENCLAW_GATEWAY_TOKEN: undefined,
|
||||
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
|
||||
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
||||
OPENCLAW_SKIP_CHANNELS: "1",
|
||||
OPENCLAW_SKIP_CRON: "1",
|
||||
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
|
||||
OPENCLAW_SKIP_PROVIDERS: "1",
|
||||
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
|
||||
VITEST: "1",
|
||||
},
|
||||
env: { ...KERNEL_TEST_ENV },
|
||||
});
|
||||
const token = "gateway-kernel-tls-failure-token";
|
||||
await state.writeConfig({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue