init project

This commit is contained in:
2026-05-10 13:21:24 +03:30
parent 5f210c6c73
commit dc36701c9d
26 changed files with 2149 additions and 69 deletions

View File

@@ -1,5 +1,6 @@
<?php
use App\Models\EmbeddingUsageEvent;
use App\Models\User;
test('guests are redirected to the login page', function () {
@@ -12,5 +13,49 @@ test('authenticated users can visit the dashboard', function () {
$this->actingAs($user);
$response = $this->get(route('dashboard'));
$response->assertOk();
});
$response->assertOk()
->assertSee(__('Usage overview'))
->assertSee(__('Tool mix'))
->assertSee(__('Recent activity'));
});
test('dashboard shows usage charts for the authenticated user', function () {
$user = User::factory()->create();
$otherUser = User::factory()->create();
EmbeddingUsageEvent::factory()->for($user)->create([
'tool' => 'embed',
'model' => 'nomic-embed-text',
'input_count' => 3,
'result_count' => 3,
'created_at' => now(),
]);
EmbeddingUsageEvent::factory()->for($user)->create([
'tool' => 'search',
'model' => 'nomic-embed-text',
'input_count' => 1,
'result_count' => 2,
'created_at' => now()->subDay(),
]);
EmbeddingUsageEvent::factory()->for($otherUser)->create([
'tool' => 'compare',
'model' => 'other-user-model',
'input_count' => 9,
'result_count' => 36,
'created_at' => now(),
]);
$this->actingAs($user);
$this->get(route('dashboard'))
->assertOk()
->assertSee(__('Actions'))
->assertSee(__('Phrases'))
->assertSee(__('Models'))
->assertSee('nomic-embed-text')
->assertSee(__('Embed'))
->assertSee(__('Search'))
->assertDontSee('other-user-model');
});