2026-09-17 02:41:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\BenchmarkRun;
|
2026-09-18 18:49:09 +00:00
|
|
|
use App\Models\ProsebenchResult;
|
|
|
|
|
use App\Models\SoftbenchResult;
|
2026-09-17 02:41:12 +00:00
|
|
|
use App\Models\User;
|
|
|
|
|
use Livewire\Volt\Volt;
|
|
|
|
|
|
2026-09-19 00:12:30 +00:00
|
|
|
test('guests see public task results on the results page', function () {
|
2026-09-18 18:49:09 +00:00
|
|
|
$publicRun = BenchmarkRun::factory()->create(['model_id' => 'public/model', 'suite' => 'softbench']);
|
|
|
|
|
ProsebenchResult::factory()->count(3)->create(['benchmark_run_id' => $publicRun->id]);
|
|
|
|
|
BenchmarkRun::factory()->private()->create(['model_id' => 'private/model', 'suite' => 'softbench']);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
2026-09-19 00:12:30 +00:00
|
|
|
$response = $this->get(route('results'));
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
$response->assertOk()
|
|
|
|
|
->assertSee('public/model')
|
|
|
|
|
->assertDontSee('private/model');
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-19 00:12:30 +00:00
|
|
|
test('authenticated users see their private runs mixed in on results', function () {
|
2026-09-17 02:41:12 +00:00
|
|
|
$me = User::factory()->create();
|
2026-09-18 18:49:09 +00:00
|
|
|
BenchmarkRun::factory()->private()->create(['model_id' => 'my-private/model', 'user_id' => $me->id, 'suite' => 'softbench']);
|
|
|
|
|
BenchmarkRun::factory()->private()->create(['model_id' => 'other-private/model', 'suite' => 'softbench']);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
$this->actingAs($me);
|
|
|
|
|
|
2026-09-19 00:12:30 +00:00
|
|
|
$this->get(route('results'))->assertOk()
|
2026-09-17 02:41:12 +00:00
|
|
|
->assertSee('my-private/model')
|
|
|
|
|
->assertDontSee('other-private/model');
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-18 18:49:09 +00:00
|
|
|
test('home page sorting orders by user tok/s through the view', function () {
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['suite' => 'softbench']);
|
|
|
|
|
SoftbenchResult::factory()->create(['benchmark_run_id' => $run->id, 'task' => 'slow-task', 'user_tps' => 5]);
|
|
|
|
|
SoftbenchResult::factory()->create(['benchmark_run_id' => $run->id, 'task' => 'fast-task', 'user_tps' => 95]);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
Volt::test('results.index', ['sortBy' => 'user_tps', 'sortDirection' => 'asc'])
|
|
|
|
|
->assertSeeInOrder(['slow-task', 'fast-task']);
|
|
|
|
|
});
|
|
|
|
|
|
2026-09-18 18:49:09 +00:00
|
|
|
test('home page suite filter queries the concrete suite table', function () {
|
|
|
|
|
$softRun = BenchmarkRun::factory()->create(['suite' => 'softbench']);
|
|
|
|
|
$proseRun = BenchmarkRun::factory()->create(['suite' => 'prosebench']);
|
|
|
|
|
SoftbenchResult::factory()->create(['benchmark_run_id' => $softRun->id, 'task' => 'soft-task']);
|
|
|
|
|
ProsebenchResult::factory()->create(['benchmark_run_id' => $proseRun->id, 'task' => 'prose-task']);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
Volt::test('results.index', ['filters' => ['search' => null, 'suite' => 'softbench', 'level' => null, 'model' => null, 'result' => null]])
|
|
|
|
|
->assertSee('soft-task')
|
2026-09-18 18:49:09 +00:00
|
|
|
->assertDontSee('prose-task');
|
2026-09-17 02:41:12 +00:00
|
|
|
});
|
|
|
|
|
|
2026-09-18 18:49:09 +00:00
|
|
|
test('run detail page shows metadata and suite-tailored results', function () {
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['model_id' => 'detail/model', 'engine' => 'vllm', 'suite' => 'prosebench']);
|
|
|
|
|
ProsebenchResult::factory()->create(['benchmark_run_id' => $run->id, 'task' => 'visible-task', 'checks_passed' => 6, 'checks_total' => 6]);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
$this->get(route('runs.show', $run->run_id))->assertOk()
|
|
|
|
|
->assertSee('detail/model')
|
|
|
|
|
->assertSee('visible-task')
|
2026-09-18 18:49:09 +00:00
|
|
|
->assertSee('vllm')
|
|
|
|
|
->assertSee('6/6');
|
2026-09-17 02:41:12 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('private runs are hidden from guests on the detail page', function () {
|
|
|
|
|
$run = BenchmarkRun::factory()->private()->create();
|
|
|
|
|
|
|
|
|
|
$this->get(route('runs.show', $run->run_id))->assertNotFound();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('owners can edit notes from the run detail page', function () {
|
|
|
|
|
$me = User::factory()->create();
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['user_id' => $me->id]);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($me);
|
|
|
|
|
|
|
|
|
|
Volt::test('runs.show', ['run' => $run->run_id])
|
|
|
|
|
->set('notes', 'ran on the spare GPU while idle')
|
|
|
|
|
->call('saveNotes');
|
|
|
|
|
|
|
|
|
|
expect($run->fresh()->notes)->toBe('ran on the spare GPU while idle');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('non-owners cannot edit notes', function () {
|
|
|
|
|
$intruder = User::factory()->create();
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['user_id' => User::factory()->create()->id]);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($intruder);
|
|
|
|
|
|
|
|
|
|
Volt::test('runs.show', ['run' => $run->run_id])
|
|
|
|
|
->set('notes', 'nice try')
|
|
|
|
|
->call('saveNotes');
|
|
|
|
|
|
|
|
|
|
expect($run->fresh()->notes)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('owner can toggle visibility from run detail page', function () {
|
|
|
|
|
$me = User::factory()->create();
|
|
|
|
|
$run = BenchmarkRun::factory()->create(['user_id' => $me->id]);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($me);
|
|
|
|
|
|
|
|
|
|
Volt::test('runs.show', ['run' => $run->run_id])->call('toggleVisibility');
|
|
|
|
|
|
|
|
|
|
expect($run->fresh()->visibility)->toBe('private');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('my runs page lists only owned runs with counts', function () {
|
|
|
|
|
$me = User::factory()->create();
|
2026-09-18 18:49:09 +00:00
|
|
|
$run = BenchmarkRun::factory()->create(['user_id' => $me->id, 'model_id' => 'mine/model', 'suite' => 'softbench']);
|
|
|
|
|
SoftbenchResult::factory()->count(4)->create(['benchmark_run_id' => $run->id]);
|
|
|
|
|
BenchmarkRun::factory()->create(['user_id' => User::factory()->create()->id, 'model_id' => 'theirs/model', 'suite' => 'softbench']);
|
2026-09-17 02:41:12 +00:00
|
|
|
|
|
|
|
|
$this->actingAs($me);
|
|
|
|
|
|
|
|
|
|
$this->get(route('my-runs'))->assertOk()
|
|
|
|
|
->assertSee('mine/model')
|
2026-09-18 18:49:09 +00:00
|
|
|
->assertDontSee('theirs/model')
|
|
|
|
|
->assertSee('4');
|
2026-09-17 02:41:12 +00:00
|
|
|
});
|