62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Models\EmbeddingUsageEvent;
|
|
use App\Models\User;
|
|
|
|
test('guests are redirected to the login page', function () {
|
|
$response = $this->get(route('dashboard'));
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('authenticated users can visit the dashboard', function () {
|
|
$user = User::factory()->create();
|
|
$this->actingAs($user);
|
|
|
|
$response = $this->get(route('dashboard'));
|
|
$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');
|
|
});
|