test: move channel contract fixtures into test helpers

This commit is contained in:
Peter Steinberger
2026-04-06 18:03:18 +01:00
parent bb29c8696a
commit 24492b51c9
11 changed files with 43 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
import { describe } from "vitest";
import { getActionContractRegistry } from "../../../../test/helpers/channels/registry-actions.js";
import { installChannelActionsContractSuite } from "../../../../test/helpers/channels/registry-contract-suites.js";
import { getActionContractRegistry } from "./registry-actions.js";
for (const entry of getActionContractRegistry()) {
describe(`${entry.id} actions contract`, () => {

View File

@@ -1,6 +1,6 @@
import { describe } from "vitest";
import { installChannelPluginContractSuite } from "../../../../test/helpers/channels/registry-contract-suites.js";
import { getPluginContractRegistry } from "./registry-plugin.js";
import { getPluginContractRegistry } from "../../../../test/helpers/channels/registry-plugin.js";
for (const entry of getPluginContractRegistry()) {
describe(`${entry.id} plugin contract`, () => {

View File

@@ -1,6 +1,6 @@
import { describe } from "vitest";
import { installChannelSetupContractSuite } from "../../../../test/helpers/channels/registry-contract-suites.js";
import { getSetupContractRegistry } from "./registry-setup-status.js";
import { getSetupContractRegistry } from "../../../../test/helpers/channels/registry-setup-status.js";
for (const entry of getSetupContractRegistry()) {
describe(`${entry.id} setup contract`, () => {

View File

@@ -1,6 +1,6 @@
import { describe } from "vitest";
import { installChannelStatusContractSuite } from "../../../../test/helpers/channels/registry-contract-suites.js";
import { getStatusContractRegistry } from "./registry-setup-status.js";
import { getStatusContractRegistry } from "../../../../test/helpers/channels/registry-setup-status.js";
for (const entry of getStatusContractRegistry()) {
describe(`${entry.id} status contract`, () => {

View File

@@ -1,10 +1,18 @@
import { vi } from "vitest";
import { CronService } from "./service.js";
import {
createDefaultIsolatedRunner,
noopLogger,
setupCronRegressionFixtures,
} from "./service.regression-fixtures.js";
createAbortAwareIsolatedRunner,
createDueIsolatedJob,
createIsolatedRegressionJob,
createRunningCronServiceState,
createDeferred,
topOfHourOffsetMs,
writeCronJobs,
writeCronStoreSnapshot,
} from "../../test/helpers/cron/service-regression-fixtures.js";
import { CronService } from "./service.js";
export type CronServiceOptions = ConstructorParameters<typeof CronService>[0];
@@ -21,7 +29,7 @@ export {
topOfHourOffsetMs,
writeCronJobs,
writeCronStoreSnapshot,
} from "./service.regression-fixtures.js";
};
export async function startCronForStore(params: {
storePath: string;

View File

@@ -1,11 +1,5 @@
import fs from "node:fs/promises";
import { describe, expect, it, vi } from "vitest";
import {
clearCommandLane,
setCommandLaneConcurrency,
waitForActiveTasks,
} from "../../process/command-queue.js";
import { CommandLane } from "../../process/lanes.js";
import {
createAbortAwareIsolatedRunner,
createDeferred,
@@ -15,7 +9,13 @@ import {
noopLogger,
setupCronRegressionFixtures,
writeCronJobs,
} from "../service.regression-fixtures.js";
} from "../../../test/helpers/cron/service-regression-fixtures.js";
import {
clearCommandLane,
setCommandLaneConcurrency,
waitForActiveTasks,
} from "../../process/command-queue.js";
import { CommandLane } from "../../process/lanes.js";
import { enqueueRun, run } from "./ops.js";
import type { CronEvent } from "./state.js";
import { createCronServiceState } from "./state.js";

View File

@@ -1,7 +1,5 @@
import fs from "node:fs/promises";
import { describe, expect, it, vi } from "vitest";
import type { HeartbeatRunResult } from "../../infra/heartbeat-wake.js";
import * as schedule from "../schedule.js";
import {
createAbortAwareIsolatedRunner,
createDefaultIsolatedRunner,
@@ -12,7 +10,9 @@ import {
noopLogger,
setupCronRegressionFixtures,
writeCronJobs,
} from "../service.regression-fixtures.js";
} from "../../../test/helpers/cron/service-regression-fixtures.js";
import type { HeartbeatRunResult } from "../../infra/heartbeat-wake.js";
import * as schedule from "../schedule.js";
import type { CronJob } from "../types.js";
import { computeJobNextRunAtMs } from "./jobs.js";
import { createCronServiceState, type CronEvent } from "./state.js";

View File

@@ -1,6 +1,6 @@
import type { OpenClawConfig } from "../../../config/config.js";
import { requireBundledChannelPlugin } from "../bundled.js";
import type { ChannelPlugin } from "../types.js";
import { requireBundledChannelPlugin } from "../../../src/channels/plugins/bundled.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
type ActionsContractEntry = {
id: string;

View File

@@ -1,5 +1,5 @@
import { listBundledChannelPlugins } from "../bundled.js";
import type { ChannelPlugin } from "../types.js";
import { listBundledChannelPlugins } from "../../../src/channels/plugins/bundled.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.js";
type PluginContractEntry = {
id: string;

View File

@@ -1,7 +1,7 @@
import { expect } from "vitest";
import type { OpenClawConfig } from "../../../config/config.js";
import { requireBundledChannelPlugin } from "../bundled.js";
import type { ChannelPlugin } from "../types.js";
import { requireBundledChannelPlugin } from "../../../src/channels/plugins/bundled.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
type SetupContractEntry = {
id: string;

View File

@@ -3,13 +3,16 @@ import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest";
import { clearAllBootstrapSnapshots } from "../agents/bootstrap-cache.js";
import { clearSessionStoreCacheForTest } from "../config/sessions/store.js";
import { resetAgentRunContextForTest } from "../infra/agent-events.js";
import { resetCommandQueueStateForTest, waitForActiveTasks } from "../process/command-queue.js";
import { useFrozenTime, useRealTime } from "../test-utils/frozen-time.js";
import { createCronServiceState, type CronServiceDeps } from "./service/state.js";
import type { CronJob, CronJobState } from "./types.js";
import { clearAllBootstrapSnapshots } from "../../../src/agents/bootstrap-cache.js";
import { clearSessionStoreCacheForTest } from "../../../src/config/sessions/store.js";
import { createCronServiceState, type CronServiceDeps } from "../../../src/cron/service/state.js";
import type { CronJob, CronJobState } from "../../../src/cron/types.js";
import { resetAgentRunContextForTest } from "../../../src/infra/agent-events.js";
import {
resetCommandQueueStateForTest,
waitForActiveTasks,
} from "../../../src/process/command-queue.js";
import { useFrozenTime, useRealTime } from "../../../src/test-utils/frozen-time.js";
const TOP_OF_HOUR_STAGGER_MS = 5 * 60 * 1_000;