@@ -79,7 +79,9 @@ function spendLogsPayload(int $promptTokens): array
7979})->group ('llm-analytics ' );
8080
8181it ('does not clear the response cache when a single day is stored ' , function () {
82- $ responseCache = ResponseCache::spy ();
82+ // Clearing the whole site's rendered HTML is the sync's decision, not one day's —
83+ // otherwise an hourly run wipes the response cache once per day in its window.
84+ ResponseCache::partialMock ()->shouldReceive ('clear ' )->never ();
8385
8486 (new StoreLlmUsageAction )->store (collect ([[
8587 'date ' => '2026-07-20 ' ,
@@ -91,19 +93,15 @@ function spendLogsPayload(int $promptTokens): array
9193 'spend ' => 0.5 ,
9294 ]]));
9395
94- // Clearing the whole site's rendered HTML is the sync's decision, not one day's —
95- // otherwise an hourly run wipes the response cache once per day in its window.
96- $ responseCache ->shouldNotHaveReceived ('clear ' );
9796})->group ('llm-analytics ' );
9897
9998it ('clears the response cache once after the whole sync batch finishes ' , function () {
10099 Http::fake (['llm.codebar.net/spend/logs* ' => Http::response (spendLogsPayload (promptTokens: 100 ))]);
101100
102- $ responseCache = ResponseCache::spy ();
101+ // Four days are synced below; the rendered pages are dropped exactly once.
102+ ResponseCache::partialMock ()->shouldReceive ('clear ' )->once ();
103103
104104 runArtisan ('llm:fetch-analytics ' , ['--from ' => '2026-07-20 ' , '--to ' => '2026-07-23 ' ])
105105 ->assertSuccessful ();
106106
107- // Four days were synced; the rendered pages are dropped exactly once.
108- $ responseCache ->shouldHaveReceived ('clear ' )->once ();
109107})->group ('llm-analytics ' );
0 commit comments