Skip to content

Commit 307147c

Browse files
committed
test: make cron config fixture section-aware
Use the shared config stub and assert that the shutdown regression reads only the cron section. Refs #248
1 parent a8aa84d commit 307147c

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

packages/agent-core-v2/test/features/cron/sessionCron.test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AgentRuntimeSet } from '#/agent/runtime/agentRuntimeSet';
99
import { IAgentToolRegistryService } from '#/agent/toolRegistry/toolRegistry';
1010
import { IConfigService } from '#/app/config/config';
1111
import { ITelemetryService } from '#/app/telemetry/telemetry';
12-
import { DEFAULT_CRON_CONFIG } from '#/features/cron/configSection';
12+
import { CRON_SECTION, DEFAULT_CRON_CONFIG } from '#/features/cron/configSection';
1313
import { AgentCron, cronAgentRuntimeProvider } from '#/features/cron/cronAgentRuntime';
1414
import { CronCursor, type CronModelState } from '#/features/cron/cronOps';
1515
import { IEventDispatcher } from '#/state/eventDispatcher';
@@ -22,6 +22,7 @@ import {
2222
type TestAgentContext,
2323
type TestAgentOptions,
2424
} from '../../harness';
25+
import { StubConfigService } from '../../kosong/stubs';
2526

2627
async function bootCronContext(options: TestAgentOptions = {}): Promise<TestAgentContext> {
2728
const ctx = createTestAgent(options);
@@ -40,19 +41,23 @@ describe('session cron wire persistence', () => {
4041
const injectStarted = new Promise<void>((resolve) => { markInjectStarted = resolve; });
4142
let closed = false;
4243
let postCloseReads = 0;
44+
const configReads: string[] = [];
4345
const recordRead = (): void => {
4446
if (closed) postCloseReads += 1;
4547
};
48+
class TrackedConfigService extends StubConfigService {
49+
override get<T = unknown>(domain: string): T {
50+
configReads.push(domain);
51+
recordRead();
52+
return super.get<T>(domain);
53+
}
54+
}
4655
const disposables = new DisposableStore();
4756
const services = createServices(disposables, {
4857
additionalServices: (reg) => {
49-
reg.definePartialInstance(IConfigService, {
50-
ready: Promise.resolve(),
51-
get: <T>() => {
52-
recordRead();
53-
return { ...DEFAULT_CRON_CONFIG, noJitter: true, manualTick: true } as T;
54-
},
55-
});
58+
reg.defineInstance(IConfigService, new TrackedConfigService({
59+
[CRON_SECTION]: { ...DEFAULT_CRON_CONFIG, noJitter: true, manualTick: true },
60+
}));
5661
reg.defineInstance(IAgentLoopService, stubLoopWithHooks());
5762
reg.definePartialInstance(IAgentPromptService, {
5863
inject: () => {
@@ -104,6 +109,7 @@ describe('session cron wire persistence', () => {
104109

105110
await expect(ticking).resolves.toBeUndefined();
106111
expect(postCloseReads).toBe(0);
112+
expect(new Set(configReads)).toEqual(new Set([CRON_SECTION]));
107113
} finally {
108114
await runtimes.close();
109115
disposables.dispose();

0 commit comments

Comments
 (0)