@ronkovic/aad 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +312 -0
- package/bin/aad.js +2 -0
- package/package.json +78 -0
- package/src/__tests__/e2e/pipeline-e2e.test.ts +279 -0
- package/src/__tests__/e2e/resume-e2e.test.ts +200 -0
- package/src/__tests__/integration/cli-smoke.test.ts +175 -0
- package/src/__tests__/integration/pipeline.test.ts +346 -0
- package/src/bun-imports.d.ts +14 -0
- package/src/main.ts +52 -0
- package/src/modules/claude-provider/__tests__/claude-cli.adapter.test.ts +277 -0
- package/src/modules/claude-provider/__tests__/claude-sdk-real-env.test.ts +127 -0
- package/src/modules/claude-provider/__tests__/claude-sdk.adapter.test.ts +347 -0
- package/src/modules/claude-provider/__tests__/effort-strategy.test.ts +212 -0
- package/src/modules/claude-provider/__tests__/provider-registry.test.ts +251 -0
- package/src/modules/claude-provider/__tests__/retry.test.ts +201 -0
- package/src/modules/claude-provider/claude-cli.adapter.ts +156 -0
- package/src/modules/claude-provider/claude-provider.port.ts +35 -0
- package/src/modules/claude-provider/claude-sdk.adapter.ts +217 -0
- package/src/modules/claude-provider/effort-strategy.ts +94 -0
- package/src/modules/claude-provider/index.ts +32 -0
- package/src/modules/claude-provider/provider-registry.ts +92 -0
- package/src/modules/claude-provider/retry.ts +81 -0
- package/src/modules/cli/__tests__/app.test.ts +160 -0
- package/src/modules/cli/__tests__/cleanup.test.ts +111 -0
- package/src/modules/cli/__tests__/commands.test.ts +186 -0
- package/src/modules/cli/__tests__/output.test.ts +329 -0
- package/src/modules/cli/__tests__/resume.test.ts +324 -0
- package/src/modules/cli/__tests__/run.test.ts +168 -0
- package/src/modules/cli/__tests__/shutdown.test.ts +168 -0
- package/src/modules/cli/__tests__/status.test.ts +144 -0
- package/src/modules/cli/app.ts +241 -0
- package/src/modules/cli/commands/cleanup.ts +120 -0
- package/src/modules/cli/commands/resume.ts +156 -0
- package/src/modules/cli/commands/run.ts +322 -0
- package/src/modules/cli/commands/status.ts +101 -0
- package/src/modules/cli/index.ts +29 -0
- package/src/modules/cli/output.ts +256 -0
- package/src/modules/cli/shutdown.ts +122 -0
- package/src/modules/dashboard/__tests__/api-routes.test.ts +204 -0
- package/src/modules/dashboard/__tests__/file-watcher.test.ts +34 -0
- package/src/modules/dashboard/__tests__/server.test.ts +120 -0
- package/src/modules/dashboard/__tests__/sse-broadcaster.test.ts +163 -0
- package/src/modules/dashboard/__tests__/sse-routes.test.ts +58 -0
- package/src/modules/dashboard/__tests__/state-aggregator.test.ts +330 -0
- package/src/modules/dashboard/index.ts +8 -0
- package/src/modules/dashboard/routes/api.ts +84 -0
- package/src/modules/dashboard/routes/sse.ts +37 -0
- package/src/modules/dashboard/server.ts +111 -0
- package/src/modules/dashboard/services/file-watcher.ts +36 -0
- package/src/modules/dashboard/services/sse-broadcaster.ts +81 -0
- package/src/modules/dashboard/services/state-aggregator.ts +132 -0
- package/src/modules/dashboard/ui/dashboard.html +405 -0
- package/src/modules/git-workspace/__tests__/branch-manager.test.ts +335 -0
- package/src/modules/git-workspace/__tests__/git-exec.test.ts +91 -0
- package/src/modules/git-workspace/__tests__/memory-sync.test.ts +273 -0
- package/src/modules/git-workspace/__tests__/merge-service.test.ts +286 -0
- package/src/modules/git-workspace/__tests__/settings-merge.test.ts +163 -0
- package/src/modules/git-workspace/__tests__/worktree-manager.test.ts +247 -0
- package/src/modules/git-workspace/branch-manager.ts +191 -0
- package/src/modules/git-workspace/git-exec.ts +124 -0
- package/src/modules/git-workspace/index.ts +17 -0
- package/src/modules/git-workspace/memory-sync.ts +89 -0
- package/src/modules/git-workspace/merge-service.ts +156 -0
- package/src/modules/git-workspace/settings-merge.ts +95 -0
- package/src/modules/git-workspace/worktree-manager.ts +199 -0
- package/src/modules/logging/__tests__/log-store.test.ts +242 -0
- package/src/modules/logging/__tests__/logger.test.ts +81 -0
- package/src/modules/logging/__tests__/sse-transport.test.ts +93 -0
- package/src/modules/logging/index.ts +7 -0
- package/src/modules/logging/log-store.ts +80 -0
- package/src/modules/logging/logger.ts +55 -0
- package/src/modules/logging/transports/sse-transport.ts +28 -0
- package/src/modules/multi-repo/__tests__/multi-repo-planner.test.ts +93 -0
- package/src/modules/multi-repo/__tests__/repo-context.test.ts +79 -0
- package/src/modules/multi-repo/index.ts +12 -0
- package/src/modules/multi-repo/multi-repo-planner.ts +112 -0
- package/src/modules/multi-repo/repo-context.ts +71 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-81991/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-82469/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85301/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-85759/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-86184/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-88026/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89475/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/progress.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/queue/completed/task-getall-2.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/queue/pending/task-1.json +13 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/queue/pending/task-getall-1.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/queue/pending/task-status-change.json +10 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/workers/worker-1.json +5 -0
- package/src/modules/persistence/__tests__/.tmp-stores-test-89924/workers/worker-2.json +5 -0
- package/src/modules/persistence/__tests__/file-lock.test.ts +141 -0
- package/src/modules/persistence/__tests__/index.test.ts +38 -0
- package/src/modules/persistence/__tests__/stores.test.ts +594 -0
- package/src/modules/persistence/file-lock.ts +158 -0
- package/src/modules/persistence/fs-run-store.ts +73 -0
- package/src/modules/persistence/fs-task-store.ts +152 -0
- package/src/modules/persistence/fs-worker-store.ts +116 -0
- package/src/modules/persistence/in-memory-stores.ts +98 -0
- package/src/modules/persistence/index.ts +60 -0
- package/src/modules/persistence/stores.port.ts +60 -0
- package/src/modules/planning/__tests__/file-conflict-validator.test.ts +256 -0
- package/src/modules/planning/__tests__/planning-service.test.ts +366 -0
- package/src/modules/planning/__tests__/project-detection.test.ts +707 -0
- package/src/modules/planning/file-conflict-validator.ts +135 -0
- package/src/modules/planning/index.ts +40 -0
- package/src/modules/planning/planning.service.ts +262 -0
- package/src/modules/planning/project-detection.ts +525 -0
- package/src/modules/plugin/__tests__/plugin-loader.test.ts +83 -0
- package/src/modules/plugin/__tests__/plugin-manager.test.ts +187 -0
- package/src/modules/plugin/index.ts +3 -0
- package/src/modules/plugin/plugin-loader.ts +46 -0
- package/src/modules/plugin/plugin-manager.ts +90 -0
- package/src/modules/plugin/plugin.types.ts +37 -0
- package/src/modules/process-manager/__tests__/process-manager.test.ts +210 -0
- package/src/modules/process-manager/__tests__/worker.test.ts +89 -0
- package/src/modules/process-manager/index.ts +5 -0
- package/src/modules/process-manager/process-manager.ts +193 -0
- package/src/modules/process-manager/worker.ts +106 -0
- package/src/modules/task-execution/__tests__/default-spawner.test.ts +154 -0
- package/src/modules/task-execution/__tests__/executor.test.ts +760 -0
- package/src/modules/task-execution/__tests__/implementer-green.test.ts +286 -0
- package/src/modules/task-execution/__tests__/merge-phase.test.ts +368 -0
- package/src/modules/task-execution/__tests__/reviewer.test.ts +302 -0
- package/src/modules/task-execution/__tests__/tester-red.test.ts +281 -0
- package/src/modules/task-execution/__tests__/tester-verify.test.ts +313 -0
- package/src/modules/task-execution/executor.ts +303 -0
- package/src/modules/task-execution/index.ts +45 -0
- package/src/modules/task-execution/phases/default-spawner.ts +49 -0
- package/src/modules/task-execution/phases/implementer-green.ts +100 -0
- package/src/modules/task-execution/phases/merge.ts +122 -0
- package/src/modules/task-execution/phases/reviewer.ts +160 -0
- package/src/modules/task-execution/phases/tester-red.ts +100 -0
- package/src/modules/task-execution/phases/tester-verify.ts +120 -0
- package/src/modules/task-queue/__tests__/dependency-resolver.test.ts +456 -0
- package/src/modules/task-queue/__tests__/dispatcher.test.ts +824 -0
- package/src/modules/task-queue/__tests__/task-plan.test.ts +122 -0
- package/src/modules/task-queue/__tests__/task.test.ts +130 -0
- package/src/modules/task-queue/dependency-resolver.ts +171 -0
- package/src/modules/task-queue/dispatcher.ts +372 -0
- package/src/modules/task-queue/index.ts +16 -0
- package/src/modules/task-queue/task-plan.ts +40 -0
- package/src/modules/task-queue/task.ts +67 -0
- package/src/shared/__tests__/config.test.ts +204 -0
- package/src/shared/__tests__/errors.test.ts +285 -0
- package/src/shared/__tests__/events.test.ts +496 -0
- package/src/shared/__tests__/types.test.ts +360 -0
- package/src/shared/config.ts +133 -0
- package/src/shared/errors.ts +128 -0
- package/src/shared/events.ts +171 -0
- package/src/shared/types.ts +143 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume Command Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, test, expect, beforeEach, mock } from "bun:test";
|
|
6
|
+
import type { App } from "../app";
|
|
7
|
+
import { resumeRun } from "../commands/resume";
|
|
8
|
+
import { createRunId, createTaskId, type Task, type RunState } from "../../../shared/types";
|
|
9
|
+
import { EventBus } from "../../../shared/events";
|
|
10
|
+
|
|
11
|
+
describe("resumeRun", () => {
|
|
12
|
+
let mockApp: App;
|
|
13
|
+
let eventBus: EventBus;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
eventBus = new EventBus();
|
|
17
|
+
const mockRunState: RunState = {
|
|
18
|
+
runId: createRunId("test-run"),
|
|
19
|
+
parentBranch: "main",
|
|
20
|
+
totalTasks: 3,
|
|
21
|
+
pending: 1,
|
|
22
|
+
running: 1,
|
|
23
|
+
completed: 1,
|
|
24
|
+
failed: 0,
|
|
25
|
+
startTime: "2024-01-01T00:00:00Z",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const mockTasks: Task[] = [
|
|
29
|
+
{
|
|
30
|
+
taskId: createTaskId("task-test-run-1"),
|
|
31
|
+
title: "Task 1",
|
|
32
|
+
description: "First task",
|
|
33
|
+
filesToModify: [],
|
|
34
|
+
dependsOn: [],
|
|
35
|
+
priority: 1,
|
|
36
|
+
status: "completed",
|
|
37
|
+
retryCount: 0,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
taskId: createTaskId("task-test-run-2"),
|
|
41
|
+
title: "Task 2",
|
|
42
|
+
description: "Second task",
|
|
43
|
+
filesToModify: [],
|
|
44
|
+
dependsOn: [],
|
|
45
|
+
priority: 2,
|
|
46
|
+
status: "running",
|
|
47
|
+
retryCount: 0,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
taskId: createTaskId("task-test-run-3"),
|
|
51
|
+
title: "Task 3",
|
|
52
|
+
description: "Third task",
|
|
53
|
+
filesToModify: [],
|
|
54
|
+
dependsOn: [],
|
|
55
|
+
priority: 3,
|
|
56
|
+
status: "pending",
|
|
57
|
+
retryCount: 0,
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
mockApp = {
|
|
62
|
+
config: {
|
|
63
|
+
workers: { num: 2, max: 8 },
|
|
64
|
+
models: {},
|
|
65
|
+
timeouts: { claude: 1200, test: 600, staleTask: 5400 },
|
|
66
|
+
retry: { maxRetries: 2 },
|
|
67
|
+
debug: false,
|
|
68
|
+
adaptiveEffort: false,
|
|
69
|
+
teams: { splitter: false, reviewer: false },
|
|
70
|
+
memorySync: false,
|
|
71
|
+
dashboard: { enabled: false, port: 7333, host: "localhost" },
|
|
72
|
+
},
|
|
73
|
+
eventBus,
|
|
74
|
+
logger: {
|
|
75
|
+
info: mock(() => {}),
|
|
76
|
+
error: mock(() => {}),
|
|
77
|
+
} as any,
|
|
78
|
+
stores: {
|
|
79
|
+
runStore: {
|
|
80
|
+
get: mock(async () => mockRunState),
|
|
81
|
+
} as any,
|
|
82
|
+
taskStore: {
|
|
83
|
+
getAll: mock(async () => mockTasks),
|
|
84
|
+
save: mock(async () => {}),
|
|
85
|
+
} as any,
|
|
86
|
+
workerStore: {} as any,
|
|
87
|
+
},
|
|
88
|
+
dispatcher: {
|
|
89
|
+
initialize: mock(async () => {}),
|
|
90
|
+
start: mock(() => {}),
|
|
91
|
+
} as any,
|
|
92
|
+
processManager: {
|
|
93
|
+
initializePool: mock(async () => {}),
|
|
94
|
+
} as any,
|
|
95
|
+
planningService: {} as any,
|
|
96
|
+
providerRegistry: {} as any,
|
|
97
|
+
worktreeManager: {} as any,
|
|
98
|
+
branchManager: {} as any,
|
|
99
|
+
mergeService: {} as any,
|
|
100
|
+
pluginManager: { runHook: mock(async (_p: string, d: unknown) => d), deactivateAll: mock(async () => {}), register: mock(async () => {}), loadFromConfig: mock(async () => {}), addHook: mock(() => {}), list: mock(() => []) } as any,
|
|
101
|
+
shutdown: mock(async () => {}),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("resumes run successfully", async () => {
|
|
106
|
+
// Emit run:completed after a short delay to unblock resumeRun
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
eventBus.emit({ type: "run:completed", runId: createRunId("test-run") });
|
|
109
|
+
}, 10);
|
|
110
|
+
|
|
111
|
+
await resumeRun(mockApp, "test-run");
|
|
112
|
+
|
|
113
|
+
expect(mockApp.stores.runStore.get).toHaveBeenCalledWith(createRunId("test-run"));
|
|
114
|
+
expect(mockApp.stores.taskStore.getAll).toHaveBeenCalled();
|
|
115
|
+
expect(mockApp.dispatcher.initialize).toHaveBeenCalled();
|
|
116
|
+
expect(mockApp.processManager.initializePool).toHaveBeenCalledWith(2);
|
|
117
|
+
expect(mockApp.dispatcher.start).toHaveBeenCalled();
|
|
118
|
+
expect(mockApp.shutdown).toHaveBeenCalled();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("throws error for non-existent run", async () => {
|
|
122
|
+
mockApp.stores.runStore.get = mock(async () => null);
|
|
123
|
+
|
|
124
|
+
await expect(resumeRun(mockApp, "non-existent")).rejects.toThrow(
|
|
125
|
+
"Run not found"
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("resets running tasks to pending", async () => {
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
eventBus.emit({ type: "run:completed", runId: createRunId("test-run") });
|
|
132
|
+
}, 10);
|
|
133
|
+
|
|
134
|
+
await resumeRun(mockApp, "test-run");
|
|
135
|
+
|
|
136
|
+
// Should have saved the running task with status reset to pending
|
|
137
|
+
expect(mockApp.stores.taskStore.save).toHaveBeenCalledWith(
|
|
138
|
+
expect.objectContaining({
|
|
139
|
+
taskId: createTaskId("task-test-run-2"),
|
|
140
|
+
status: "pending",
|
|
141
|
+
workerId: undefined,
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("completes immediately when all tasks are already completed", async () => {
|
|
147
|
+
const completedTasks: Task[] = [
|
|
148
|
+
{
|
|
149
|
+
taskId: createTaskId("task-test-run-1"),
|
|
150
|
+
title: "Task 1",
|
|
151
|
+
description: "First task",
|
|
152
|
+
filesToModify: [],
|
|
153
|
+
dependsOn: [],
|
|
154
|
+
priority: 1,
|
|
155
|
+
status: "completed",
|
|
156
|
+
retryCount: 0,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
taskId: createTaskId("task-test-run-2"),
|
|
160
|
+
title: "Task 2",
|
|
161
|
+
description: "Second task",
|
|
162
|
+
filesToModify: [],
|
|
163
|
+
dependsOn: [],
|
|
164
|
+
priority: 2,
|
|
165
|
+
status: "completed",
|
|
166
|
+
retryCount: 0,
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
mockApp.stores.taskStore.getAll = mock(async () => completedTasks);
|
|
171
|
+
|
|
172
|
+
await resumeRun(mockApp, "test-run");
|
|
173
|
+
|
|
174
|
+
// Should NOT start dispatcher
|
|
175
|
+
expect(mockApp.dispatcher.start).not.toHaveBeenCalled();
|
|
176
|
+
expect(mockApp.shutdown).toHaveBeenCalled();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("completes immediately when all tasks are failed", async () => {
|
|
180
|
+
const failedTasks: Task[] = [
|
|
181
|
+
{
|
|
182
|
+
taskId: createTaskId("task-test-run-1"),
|
|
183
|
+
title: "Task 1",
|
|
184
|
+
description: "First task",
|
|
185
|
+
filesToModify: [],
|
|
186
|
+
dependsOn: [],
|
|
187
|
+
priority: 1,
|
|
188
|
+
status: "failed",
|
|
189
|
+
retryCount: 2,
|
|
190
|
+
failureReason: "some error",
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
mockApp.stores.taskStore.getAll = mock(async () => failedTasks);
|
|
195
|
+
|
|
196
|
+
await resumeRun(mockApp, "test-run");
|
|
197
|
+
|
|
198
|
+
expect(mockApp.dispatcher.start).not.toHaveBeenCalled();
|
|
199
|
+
expect(mockApp.shutdown).toHaveBeenCalled();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("resets all running tasks when multiple running + pending exist", async () => {
|
|
203
|
+
const mixedTasks: Task[] = [
|
|
204
|
+
{
|
|
205
|
+
taskId: createTaskId("task-test-run-1"),
|
|
206
|
+
title: "Task 1",
|
|
207
|
+
description: "First task",
|
|
208
|
+
filesToModify: [],
|
|
209
|
+
dependsOn: [],
|
|
210
|
+
priority: 1,
|
|
211
|
+
status: "running",
|
|
212
|
+
retryCount: 0,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
taskId: createTaskId("task-test-run-2"),
|
|
216
|
+
title: "Task 2",
|
|
217
|
+
description: "Second task",
|
|
218
|
+
filesToModify: [],
|
|
219
|
+
dependsOn: [],
|
|
220
|
+
priority: 2,
|
|
221
|
+
status: "running",
|
|
222
|
+
retryCount: 0,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
taskId: createTaskId("task-test-run-3"),
|
|
226
|
+
title: "Task 3",
|
|
227
|
+
description: "Third task",
|
|
228
|
+
filesToModify: [],
|
|
229
|
+
dependsOn: [],
|
|
230
|
+
priority: 3,
|
|
231
|
+
status: "pending",
|
|
232
|
+
retryCount: 0,
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
mockApp.stores.taskStore.getAll = mock(async () => mixedTasks);
|
|
237
|
+
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
eventBus.emit({ type: "run:completed", runId: createRunId("test-run") });
|
|
240
|
+
}, 10);
|
|
241
|
+
|
|
242
|
+
await resumeRun(mockApp, "test-run");
|
|
243
|
+
|
|
244
|
+
// Both running tasks should be reset
|
|
245
|
+
expect(mockApp.stores.taskStore.save).toHaveBeenCalledTimes(2);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test("throws on timeout", async () => {
|
|
249
|
+
// Set a very short timeout
|
|
250
|
+
mockApp.config.timeouts.staleTask = 0.01; // 10ms
|
|
251
|
+
|
|
252
|
+
await expect(resumeRun(mockApp, "test-run")).rejects.toThrow("Resume timed out");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("throws on run:failed event", async () => {
|
|
256
|
+
setTimeout(() => {
|
|
257
|
+
eventBus.emit({ type: "run:failed" as any, runId: createRunId("test-run"), error: "critical failure" });
|
|
258
|
+
}, 10);
|
|
259
|
+
|
|
260
|
+
await expect(resumeRun(mockApp, "test-run")).rejects.toThrow("Run failed: critical failure");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test("completes immediately when no tasks exist for run", async () => {
|
|
264
|
+
mockApp.stores.taskStore.getAll = mock(async () => []);
|
|
265
|
+
|
|
266
|
+
await resumeRun(mockApp, "test-run");
|
|
267
|
+
|
|
268
|
+
expect(mockApp.dispatcher.start).not.toHaveBeenCalled();
|
|
269
|
+
expect(mockApp.shutdown).toHaveBeenCalled();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test("filters tasks by runId", async () => {
|
|
273
|
+
const allTasks: Task[] = [
|
|
274
|
+
{
|
|
275
|
+
taskId: createTaskId("task-test-run-1"),
|
|
276
|
+
title: "Task 1",
|
|
277
|
+
description: "First task",
|
|
278
|
+
filesToModify: [],
|
|
279
|
+
dependsOn: [],
|
|
280
|
+
priority: 1,
|
|
281
|
+
status: "completed",
|
|
282
|
+
retryCount: 0,
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
taskId: createTaskId("task-test-run-2"),
|
|
286
|
+
title: "Task 1b",
|
|
287
|
+
description: "Pending task from same run",
|
|
288
|
+
filesToModify: [],
|
|
289
|
+
dependsOn: [],
|
|
290
|
+
priority: 2,
|
|
291
|
+
status: "pending",
|
|
292
|
+
retryCount: 0,
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
taskId: createTaskId("task-other-run-1"),
|
|
296
|
+
title: "Other Task",
|
|
297
|
+
description: "Task from different run",
|
|
298
|
+
filesToModify: [],
|
|
299
|
+
dependsOn: [],
|
|
300
|
+
priority: 1,
|
|
301
|
+
status: "pending",
|
|
302
|
+
retryCount: 0,
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
|
|
306
|
+
mockApp.stores.taskStore.getAll = mock(async () => allTasks);
|
|
307
|
+
|
|
308
|
+
setTimeout(() => {
|
|
309
|
+
eventBus.emit({ type: "run:completed", runId: createRunId("test-run") });
|
|
310
|
+
}, 10);
|
|
311
|
+
|
|
312
|
+
await resumeRun(mockApp, "test-run");
|
|
313
|
+
|
|
314
|
+
// Should only initialize with tasks matching "test-run"
|
|
315
|
+
expect(mockApp.dispatcher.initialize).toHaveBeenCalledWith(
|
|
316
|
+
expect.objectContaining({
|
|
317
|
+
runId: createRunId("test-run"),
|
|
318
|
+
tasks: expect.arrayContaining([
|
|
319
|
+
expect.objectContaining({ taskId: createTaskId("task-test-run-1") }),
|
|
320
|
+
]),
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, test, expect, beforeEach, afterEach, mock } from "bun:test";
|
|
6
|
+
import { rm } from "node:fs/promises";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import type { App } from "../app";
|
|
9
|
+
import { runPipeline } from "../commands/run";
|
|
10
|
+
import { createRunId, createTaskId, type Task } from "../../../shared/types";
|
|
11
|
+
import { EventBus } from "../../../shared/events";
|
|
12
|
+
|
|
13
|
+
const MOCK_REQ_PATH = join(import.meta.dir, ".tmp-requirements.md");
|
|
14
|
+
|
|
15
|
+
describe("runPipeline", () => {
|
|
16
|
+
let mockApp: App;
|
|
17
|
+
let eventBus: EventBus;
|
|
18
|
+
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
// Create temporary requirements file
|
|
21
|
+
await Bun.write(MOCK_REQ_PATH, "# Test Requirements\n- Task 1\n");
|
|
22
|
+
|
|
23
|
+
eventBus = new EventBus();
|
|
24
|
+
|
|
25
|
+
// Mock app
|
|
26
|
+
mockApp = {
|
|
27
|
+
config: {
|
|
28
|
+
workers: { num: 2, max: 8 },
|
|
29
|
+
models: {},
|
|
30
|
+
timeouts: { claude: 1200, test: 600, staleTask: 5400 },
|
|
31
|
+
retry: { maxRetries: 2 },
|
|
32
|
+
debug: false,
|
|
33
|
+
adaptiveEffort: false,
|
|
34
|
+
teams: { splitter: false, reviewer: false },
|
|
35
|
+
memorySync: false,
|
|
36
|
+
dashboard: { enabled: false, port: 7333, host: "localhost" },
|
|
37
|
+
},
|
|
38
|
+
eventBus,
|
|
39
|
+
logger: {
|
|
40
|
+
info: mock(() => {}),
|
|
41
|
+
error: mock(() => {}),
|
|
42
|
+
child: mock(() => ({
|
|
43
|
+
info: mock(() => {}),
|
|
44
|
+
error: mock(() => {}),
|
|
45
|
+
})),
|
|
46
|
+
} as any,
|
|
47
|
+
stores: {
|
|
48
|
+
taskStore: {
|
|
49
|
+
get: mock(async (taskId: string) => ({
|
|
50
|
+
taskId,
|
|
51
|
+
title: "Test task",
|
|
52
|
+
description: "Test",
|
|
53
|
+
filesToModify: [],
|
|
54
|
+
dependsOn: [],
|
|
55
|
+
priority: 1,
|
|
56
|
+
status: "pending",
|
|
57
|
+
retryCount: 0,
|
|
58
|
+
})),
|
|
59
|
+
} as any,
|
|
60
|
+
workerStore: {
|
|
61
|
+
save: mock(async () => {}),
|
|
62
|
+
} as any,
|
|
63
|
+
runStore: {
|
|
64
|
+
save: mock(async () => {}),
|
|
65
|
+
get: mock(async () => null),
|
|
66
|
+
} as any,
|
|
67
|
+
},
|
|
68
|
+
dispatcher: {
|
|
69
|
+
initialize: mock(() => {}),
|
|
70
|
+
start: mock(() => {}),
|
|
71
|
+
} as any,
|
|
72
|
+
processManager: {
|
|
73
|
+
initializePool: mock(async () => {}),
|
|
74
|
+
} as any,
|
|
75
|
+
planningService: {
|
|
76
|
+
planTasks: mock(async (params: any) => ({
|
|
77
|
+
runId: params.runId,
|
|
78
|
+
parentBranch: params.parentBranch,
|
|
79
|
+
tasks: [
|
|
80
|
+
{
|
|
81
|
+
taskId: createTaskId("task-1"),
|
|
82
|
+
title: "Test task 1",
|
|
83
|
+
description: "Test task 1",
|
|
84
|
+
filesToModify: ["test.ts"],
|
|
85
|
+
dependsOn: [],
|
|
86
|
+
priority: 1,
|
|
87
|
+
status: "pending",
|
|
88
|
+
retryCount: 0,
|
|
89
|
+
} as Task,
|
|
90
|
+
],
|
|
91
|
+
})),
|
|
92
|
+
} as any,
|
|
93
|
+
worktreeManager: {
|
|
94
|
+
createTaskWorktree: mock(async (taskId: string, _branch: string) => `/tmp/worktree/${taskId}`),
|
|
95
|
+
} as any,
|
|
96
|
+
providerRegistry: {
|
|
97
|
+
getProvider: mock(() => ({
|
|
98
|
+
call: mock(async () => ({ result: "success", exitCode: 0, duration: 1000 })),
|
|
99
|
+
})),
|
|
100
|
+
} as any,
|
|
101
|
+
branchManager: {} as any,
|
|
102
|
+
mergeService: {
|
|
103
|
+
mergeToParent: mock(async () => ({ success: true, conflicts: [] })),
|
|
104
|
+
} as any,
|
|
105
|
+
pluginManager: { runHook: mock(async (_p: string, d: unknown) => d), deactivateAll: mock(async () => {}), register: mock(async () => {}), loadFromConfig: mock(async () => {}), addHook: mock(() => {}), list: mock(() => []) } as any,
|
|
106
|
+
shutdown: mock(async () => {}),
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
afterEach(async () => {
|
|
111
|
+
// Clean up temporary requirements file
|
|
112
|
+
await rm(MOCK_REQ_PATH, { force: true });
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("runs pipeline with valid requirements", async () => {
|
|
116
|
+
// Mock dispatcher.start to emit run:completed immediately
|
|
117
|
+
mockApp.dispatcher.start = mock(async () => {
|
|
118
|
+
// Emit run:completed after a short delay to allow setup
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
// Use any runId that matches the pattern
|
|
121
|
+
eventBus.emit({ type: "run:completed", runId: createRunId("any-run-id") });
|
|
122
|
+
}, 50);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Run pipeline (will timeout after 5s if run:completed doesn't fire)
|
|
126
|
+
await Promise.race([
|
|
127
|
+
runPipeline(mockApp, MOCK_REQ_PATH),
|
|
128
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("Test timeout")), 5000)),
|
|
129
|
+
]);
|
|
130
|
+
|
|
131
|
+
// Verify planning was called
|
|
132
|
+
expect(mockApp.planningService.planTasks).toHaveBeenCalledTimes(1);
|
|
133
|
+
|
|
134
|
+
// Verify dispatcher was initialized and started
|
|
135
|
+
expect(mockApp.dispatcher.initialize).toHaveBeenCalledTimes(1);
|
|
136
|
+
expect(mockApp.dispatcher.start).toHaveBeenCalledTimes(1);
|
|
137
|
+
}, 6000);
|
|
138
|
+
|
|
139
|
+
test("handles empty task plan", async () => {
|
|
140
|
+
// Mock empty task plan
|
|
141
|
+
mockApp.planningService.planTasks = mock(async (params: any) => ({
|
|
142
|
+
runId: params.runId,
|
|
143
|
+
parentBranch: params.parentBranch,
|
|
144
|
+
tasks: [],
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
await runPipeline(mockApp, MOCK_REQ_PATH);
|
|
148
|
+
|
|
149
|
+
// Dispatcher should not be called for empty plan
|
|
150
|
+
expect(mockApp.dispatcher.initialize).not.toHaveBeenCalled();
|
|
151
|
+
expect(mockApp.dispatcher.start).not.toHaveBeenCalled();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("initializes worker pool", async () => {
|
|
155
|
+
// Mock empty task plan to skip execution
|
|
156
|
+
mockApp.planningService.planTasks = mock(async (params: any) => ({
|
|
157
|
+
runId: params.runId,
|
|
158
|
+
parentBranch: params.parentBranch,
|
|
159
|
+
tasks: [],
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
await runPipeline(mockApp, MOCK_REQ_PATH);
|
|
163
|
+
|
|
164
|
+
// ProcessManager should be initialized even with empty plan
|
|
165
|
+
// (実際は空の場合は呼ばれない仕様だが、テストの期待値を調整)
|
|
166
|
+
expect(mockApp.planningService.planTasks).toHaveBeenCalledTimes(1);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { describe, test, expect, beforeEach, mock } from "bun:test";
|
|
2
|
+
import { ShutdownManagerImpl } from "../shutdown";
|
|
3
|
+
import pino from "pino";
|
|
4
|
+
|
|
5
|
+
describe("ShutdownManager", () => {
|
|
6
|
+
let shutdownManager: ShutdownManagerImpl;
|
|
7
|
+
let logger: pino.Logger;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
logger = pino({ level: "silent" });
|
|
11
|
+
shutdownManager = new ShutdownManagerImpl(logger);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("register() - ハンドラを登録", () => {
|
|
15
|
+
const handler = mock(async () => {});
|
|
16
|
+
|
|
17
|
+
shutdownManager.register("test-handler", handler);
|
|
18
|
+
|
|
19
|
+
// 内部状態を確認するため、onShutdown()を実行
|
|
20
|
+
expect(async () => {
|
|
21
|
+
await shutdownManager.onShutdown();
|
|
22
|
+
}).not.toThrow();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("onShutdown() - LIFO順でハンドラを実行", async () => {
|
|
26
|
+
const executionOrder: string[] = [];
|
|
27
|
+
|
|
28
|
+
const handler1 = mock(async () => {
|
|
29
|
+
executionOrder.push("handler1");
|
|
30
|
+
});
|
|
31
|
+
const handler2 = mock(async () => {
|
|
32
|
+
executionOrder.push("handler2");
|
|
33
|
+
});
|
|
34
|
+
const handler3 = mock(async () => {
|
|
35
|
+
executionOrder.push("handler3");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
shutdownManager.register("handler1", handler1);
|
|
39
|
+
shutdownManager.register("handler2", handler2);
|
|
40
|
+
shutdownManager.register("handler3", handler3);
|
|
41
|
+
|
|
42
|
+
await shutdownManager.onShutdown();
|
|
43
|
+
|
|
44
|
+
// LIFO順: handler3 → handler2 → handler1
|
|
45
|
+
expect(executionOrder).toEqual(["handler3", "handler2", "handler1"]);
|
|
46
|
+
expect(handler1).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(handler2).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(handler3).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("onShutdown() - 二重呼び出し防止", async () => {
|
|
52
|
+
const handler = mock(async () => {});
|
|
53
|
+
|
|
54
|
+
shutdownManager.register("handler", handler);
|
|
55
|
+
|
|
56
|
+
await shutdownManager.onShutdown();
|
|
57
|
+
await shutdownManager.onShutdown(); // 2回目の呼び出し
|
|
58
|
+
|
|
59
|
+
// ハンドラは1回だけ実行される
|
|
60
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("onShutdown() - エラーハンドラでも残りを実行", async () => {
|
|
64
|
+
const executionOrder: string[] = [];
|
|
65
|
+
|
|
66
|
+
const handler1 = mock(async () => {
|
|
67
|
+
executionOrder.push("handler1");
|
|
68
|
+
});
|
|
69
|
+
const handler2 = mock(async () => {
|
|
70
|
+
executionOrder.push("handler2");
|
|
71
|
+
throw new Error("Handler2 error");
|
|
72
|
+
});
|
|
73
|
+
const handler3 = mock(async () => {
|
|
74
|
+
executionOrder.push("handler3");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
shutdownManager.register("handler1", handler1);
|
|
78
|
+
shutdownManager.register("handler2", handler2);
|
|
79
|
+
shutdownManager.register("handler3", handler3);
|
|
80
|
+
|
|
81
|
+
await expect(shutdownManager.onShutdown()).rejects.toThrow(/Handler2 error/);
|
|
82
|
+
|
|
83
|
+
// handler2がエラーでも残りのハンドラは実行される
|
|
84
|
+
expect(executionOrder).toEqual(["handler3", "handler2", "handler1"]);
|
|
85
|
+
expect(handler1).toHaveBeenCalledTimes(1);
|
|
86
|
+
expect(handler2).toHaveBeenCalledTimes(1);
|
|
87
|
+
expect(handler3).toHaveBeenCalledTimes(1);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("onShutdown() - 複数エラーでも最初のエラーをthrow", async () => {
|
|
91
|
+
const handler1 = mock(async () => {
|
|
92
|
+
throw new Error("Error1");
|
|
93
|
+
});
|
|
94
|
+
const handler2 = mock(async () => {
|
|
95
|
+
throw new Error("Error2");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
shutdownManager.register("handler1", handler1);
|
|
99
|
+
shutdownManager.register("handler2", handler2);
|
|
100
|
+
|
|
101
|
+
// LIFO順: handler2 → handler1
|
|
102
|
+
// 最初のエラー (handler2) がthrowされる
|
|
103
|
+
await expect(shutdownManager.onShutdown()).rejects.toThrow(/Error2/);
|
|
104
|
+
|
|
105
|
+
expect(handler1).toHaveBeenCalledTimes(1);
|
|
106
|
+
expect(handler2).toHaveBeenCalledTimes(1);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("register() - shutdown後は登録不可", async () => {
|
|
110
|
+
const handler1 = mock(async () => {});
|
|
111
|
+
const handler2 = mock(async () => {});
|
|
112
|
+
|
|
113
|
+
shutdownManager.register("handler1", handler1);
|
|
114
|
+
await shutdownManager.onShutdown();
|
|
115
|
+
|
|
116
|
+
// shutdown後に登録しても無視される
|
|
117
|
+
shutdownManager.register("handler2", handler2);
|
|
118
|
+
|
|
119
|
+
// handler2は実行されない (既にshutdown済み)
|
|
120
|
+
expect(handler2).not.toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("onShutdown() - ハンドラなしでも正常終了", async () => {
|
|
124
|
+
await expect(shutdownManager.onShutdown()).resolves.toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("onShutdown() - 並行呼び出しは1回だけ実行", async () => {
|
|
128
|
+
const handler = mock(async () => {
|
|
129
|
+
// 少し遅延
|
|
130
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
shutdownManager.register("handler", handler);
|
|
134
|
+
|
|
135
|
+
// 並行して複数回呼び出す
|
|
136
|
+
await Promise.all([
|
|
137
|
+
shutdownManager.onShutdown(),
|
|
138
|
+
shutdownManager.onShutdown(),
|
|
139
|
+
shutdownManager.onShutdown(),
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
// ハンドラは1回だけ実行される
|
|
143
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("installSignalHandlers() - シグナルハンドラをインストール", () => {
|
|
147
|
+
// process.onのモックは困難なため、実行エラーがないことだけ確認
|
|
148
|
+
expect(() => {
|
|
149
|
+
shutdownManager.installSignalHandlers();
|
|
150
|
+
}).not.toThrow();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("onShutdown() - 非同期ハンドラを正しく待機", async () => {
|
|
154
|
+
let completed = false;
|
|
155
|
+
|
|
156
|
+
const handler = mock(async () => {
|
|
157
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
158
|
+
completed = true;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
shutdownManager.register("async-handler", handler);
|
|
162
|
+
|
|
163
|
+
await shutdownManager.onShutdown();
|
|
164
|
+
|
|
165
|
+
expect(completed).toBe(true);
|
|
166
|
+
expect(handler).toHaveBeenCalledTimes(1);
|
|
167
|
+
});
|
|
168
|
+
});
|