test: stabilize OpenClaw gateway active slot regression
This commit is contained in:
parent
71f0f98946
commit
26a04b29f3
@ -3592,7 +3592,7 @@ void main() {
|
||||
controller.assistantSessionHasPendingRun('openclaw-failed-task'),
|
||||
isFalse,
|
||||
);
|
||||
expect(controller.openClawGatewayActiveTasksInternal, 0);
|
||||
await _waitForOpenClawActiveTaskCount(controller, 0);
|
||||
expect(
|
||||
controller
|
||||
.requireTaskThreadForSessionInternal('openclaw-failed-task')
|
||||
@ -3615,7 +3615,7 @@ void main() {
|
||||
'openclaw-second-task',
|
||||
);
|
||||
await secondSubmitFuture;
|
||||
expect(controller.openClawGatewayActiveTasksInternal, 0);
|
||||
await _waitForOpenClawActiveTaskCount(controller, 0);
|
||||
expect(
|
||||
controller.chatMessages.map((message) => message.text),
|
||||
contains('second task completed'),
|
||||
@ -4165,6 +4165,22 @@ Future<void> _waitForThreadLastResultCode(
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _waitForOpenClawActiveTaskCount(
|
||||
AppController controller,
|
||||
int expectedCount,
|
||||
) async {
|
||||
final deadline = DateTime.now().add(const Duration(seconds: 15));
|
||||
while (DateTime.now().isBefore(deadline)) {
|
||||
if (controller.openClawGatewayActiveTasksInternal == expectedCount) {
|
||||
return;
|
||||
}
|
||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
||||
}
|
||||
throw StateError(
|
||||
'Timed out waiting for OpenClaw active task count $expectedCount. Current count: ${controller.openClawGatewayActiveTasksInternal}.',
|
||||
);
|
||||
}
|
||||
|
||||
class _RecordingGoTaskServiceClient implements GoTaskServiceClient {
|
||||
int executeCount = 0;
|
||||
final List<GoTaskServiceRequest> requests = <GoTaskServiceRequest>[];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user