Skip to content

Commit b5ce150

Browse files
Queue::fake six V2RunDetailViewTest tests + available_at-aware drain
Six RunDetailView tests were racing real testbench queue workers in CI under the same bucket A pattern as the V2WorkflowTest conversions in d042ea9 / 561a441. They pass reliably on local docker but time out at 5–30s on contention-bound GitHub Actions runners. Convert them to the Queue::fake + drainReadyTasks pattern so they are self-contained, and teach V2RunDetailViewTest's local drainReadyTasks helper to respect `available_at` just like the real worker does (same patch shape as d042ea9 on V2WorkflowTest). Without the available_at filter, drainReadyTasks would fire future-scheduled timer tasks early and the test would observe a completed workflow when it expected a parked one. Clears 6 CI-only MySQL failures under #399: * testRunDetailViewIncludesCommandsActivitiesAndTimelineForCompletedSignalRun * testRunDetailViewKeepsActivityDetailWhenActivityRowDrifts * testRunDetailViewFallsBackToTypedActivityHistoryWhenActivityRowIsMissing * testRunDetailViewKeepsSignalWaitCommandMetadataWhenCommandRowsDrift * testRunDetailViewIncludesChildWaitAndLineageForParentRun * testRunDetailViewReturnsTypedPayloadsNotPhpSerializedStrings Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 561a441 commit b5ce150

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/Feature/V2/V2RunDetailViewTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,16 +1094,20 @@ public function testRunDetailViewReturnsEmptyNormalizedTargetsWhenCommandContrac
10941094

10951095
public function testRunDetailViewIncludesCommandsActivitiesAndTimelineForCompletedSignalRun(): void
10961096
{
1097+
Queue::fake();
1098+
10971099
$workflow = WorkflowStub::make(TestSignalWorkflow::class, 'detail-signal-complete');
10981100
$workflow->start();
10991101
$runId = $workflow->runId();
11001102

11011103
$this->assertNotNull($runId);
11021104

1105+
$this->drainReadyTasks();
11031106
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'signal');
11041107

11051108
$workflow->signal('name-provided', 'Taylor');
11061109

1110+
$this->drainReadyTasks();
11071111
$this->waitFor(static fn (): bool => $workflow->refresh()->completed());
11081112

11091113
/** @var ActivityExecution $execution */
@@ -1203,16 +1207,20 @@ public function testRunDetailViewIncludesCommandsActivitiesAndTimelineForComplet
12031207

12041208
public function testRunDetailViewKeepsActivityDetailWhenActivityRowDrifts(): void
12051209
{
1210+
Queue::fake();
1211+
12061212
$workflow = WorkflowStub::make(TestSignalWorkflow::class, 'detail-activity-row-drift');
12071213
$workflow->start();
12081214
$runId = $workflow->runId();
12091215

12101216
$this->assertNotNull($runId);
12111217

1218+
$this->drainReadyTasks();
12121219
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'signal');
12131220

12141221
$workflow->signal('name-provided', 'Taylor');
12151222

1223+
$this->drainReadyTasks();
12161224
$this->waitFor(static fn (): bool => $workflow->refresh()->completed());
12171225

12181226
/** @var ActivityExecution $execution */
@@ -1250,16 +1258,20 @@ public function testRunDetailViewKeepsActivityDetailWhenActivityRowDrifts(): voi
12501258

12511259
public function testRunDetailViewFallsBackToTypedActivityHistoryWhenActivityRowIsMissing(): void
12521260
{
1261+
Queue::fake();
1262+
12531263
$workflow = WorkflowStub::make(TestSignalWorkflow::class, 'detail-activity-row-missing');
12541264
$workflow->start();
12551265
$runId = $workflow->runId();
12561266

12571267
$this->assertNotNull($runId);
12581268

1269+
$this->drainReadyTasks();
12591270
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'signal');
12601271

12611272
$workflow->signal('name-provided', 'Taylor');
12621273

1274+
$this->drainReadyTasks();
12631275
$this->waitFor(static fn (): bool => $workflow->refresh()->completed());
12641276

12651277
ActivityExecution::query()
@@ -1291,16 +1303,20 @@ public function testRunDetailViewFallsBackToTypedActivityHistoryWhenActivityRowI
12911303

12921304
public function testRunDetailViewKeepsSignalWaitCommandMetadataWhenCommandRowsDrift(): void
12931305
{
1306+
Queue::fake();
1307+
12941308
$workflow = WorkflowStub::make(TestSignalWorkflow::class, 'detail-signal-history-snapshot');
12951309
$workflow->start();
12961310
$runId = $workflow->runId();
12971311

12981312
$this->assertNotNull($runId);
12991313

1314+
$this->drainReadyTasks();
13001315
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'signal');
13011316

13021317
$workflow->signal('name-provided', 'Taylor');
13031318

1319+
$this->drainReadyTasks();
13041320
$this->waitFor(static fn (): bool => $workflow->refresh()->completed());
13051321

13061322
/** @var WorkflowCommand $signalCommand */
@@ -2269,12 +2285,15 @@ public function testRunDetailViewIncludesInstanceRunNavigation(): void
22692285

22702286
public function testRunDetailViewIncludesChildWaitAndLineageForParentRun(): void
22712287
{
2288+
Queue::fake();
2289+
22722290
$workflow = WorkflowStub::make(TestParentWaitingOnChildWorkflow::class, 'detail-child-parent');
22732291
$workflow->start(60);
22742292
$runId = $workflow->runId();
22752293

22762294
$this->assertNotNull($runId);
22772295

2296+
$this->drainReadyTasks();
22782297
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'child');
22792298

22802299
/** @var WorkflowRun $run */
@@ -3713,13 +3732,17 @@ public function testRunDetailViewRebuildsActivityAttemptsFromTypedHistoryWhenAtt
37133732

37143733
public function testRunDetailViewReturnsTypedPayloadsNotPhpSerializedStrings(): void
37153734
{
3735+
Queue::fake();
3736+
37163737
$workflow = WorkflowStub::make(TestSignalWorkflow::class, 'detail-typed-contract');
37173738
$workflow->start();
37183739

3740+
$this->drainReadyTasks();
37193741
$this->waitFor(static fn (): bool => $workflow->refresh()->summary()?->wait_kind === 'signal');
37203742

37213743
$workflow->signal('name-provided', 'Taylor');
37223744

3745+
$this->drainReadyTasks();
37233746
$this->waitFor(static fn (): bool => $workflow->refresh()->completed());
37243747

37253748
/** @var WorkflowRun $run */
@@ -3803,6 +3826,10 @@ private function drainReadyTasks(): void
38033826
/** @var WorkflowTask|null $task */
38043827
$task = WorkflowTask::query()
38053828
->where('status', TaskStatus::Ready->value)
3829+
->where(static function ($query): void {
3830+
$query->whereNull('available_at')
3831+
->orWhere('available_at', '<=', now());
3832+
})
38063833
->orderBy('created_at')
38073834
->first();
38083835

0 commit comments

Comments
 (0)