2026-09-18 19:01:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\BenchmarkRun;
|
|
|
|
|
use App\Models\SoftbenchResult;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
|
|
|
|
|
|
test('festbench:snapshot rebuilds the flat home view', function () {
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['suite' => 'softbench', 'model_id' => 'snap/model', 'visibility' => 'public']);
|
|
|
|
|
SoftbenchResult::factory()->create(['benchmark_run_id' => $run->id, 'task' => 'snap-task']);
|
|
|
|
|
BenchmarkRun::factory()->private()->create(['suite' => 'softbench']);
|
|
|
|
|
|
|
|
|
|
Artisan::call('festbench:snapshot');
|
|
|
|
|
|
|
|
|
|
$rows = DB::table('home_snapshot')->get();
|
|
|
|
|
|
|
|
|
|
expect($rows)->toHaveCount(1)
|
|
|
|
|
->and($rows[0]->task)->toBe('snap-task')
|
|
|
|
|
->and($rows[0]->model_id)->toBe('snap/model')
|
|
|
|
|
->and($rows[0]->run_id)->toBe($run->run_id);
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-19 00:12:30 +00:00
|
|
|
test('guest default results view reads the snapshot, no union needed', function () {
|
2026-09-18 19:01:41 +00:00
|
|
|
$run = BenchmarkRun::factory()->create(['suite' => 'softbench', 'visibility' => 'public']);
|
|
|
|
|
SoftbenchResult::factory()->create(['benchmark_run_id' => $run->id, 'task' => 'snapshotted-task']);
|
|
|
|
|
Artisan::call('festbench:snapshot');
|
|
|
|
|
|
|
|
|
|
// The snapshot is the only path that knows this task name; seeing it
|
|
|
|
|
// proves the default view served from home_snapshot.
|
2026-09-19 00:12:30 +00:00
|
|
|
$this->get(route('results'))->assertOk()->assertSee('snapshotted-task');
|
2026-09-18 19:01:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('guest pages get public cache headers, authenticated pages do not', function () {
|
2026-09-19 00:12:30 +00:00
|
|
|
$guest = $this->get(route('results'));
|
2026-09-18 19:01:41 +00:00
|
|
|
expect($guest->headers->get('Cache-Control'))->toContain('public')
|
|
|
|
|
->and($guest->headers->get('Cache-Control'))->toContain('s-maxage');
|
|
|
|
|
|
|
|
|
|
$this->actingAs(User::factory()->create());
|
2026-09-19 00:12:30 +00:00
|
|
|
$auth = $this->get(route('results'));
|
2026-09-18 19:01:41 +00:00
|
|
|
|
|
|
|
|
expect($auth->headers->get('Cache-Control'))->toContain('private')
|
|
|
|
|
->and($auth->headers->get('Cache-Control'))->not->toContain('public');
|
|
|
|
|
});
|