Initial Ladill Transfer app — file sharing with QR links.
Scaffolded from the Ladill mini/events extraction pattern: multi-file transfers, retention controls, public landing pages, analytics, and Gitea deploy workflow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AfiaTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Http::preventStrayRequests();
|
||||
}
|
||||
|
||||
private function user(): User
|
||||
{
|
||||
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
|
||||
}
|
||||
|
||||
public function test_requires_a_message(): void
|
||||
{
|
||||
config(['afia.api_key' => 'sk-test']);
|
||||
$this->actingAs($this->user())->postJson('/afia/chat', [])->assertStatus(422);
|
||||
}
|
||||
|
||||
public function test_returns_503_when_not_configured(): void
|
||||
{
|
||||
config(['afia.api_key' => '']);
|
||||
$this->actingAs($this->user())->postJson('/afia/chat', ['message' => 'hi'])->assertStatus(503);
|
||||
}
|
||||
|
||||
public function test_returns_reply_from_llm(): void
|
||||
{
|
||||
config(['afia.api_key' => 'sk-test', 'afia.provider' => 'openai', 'afia.model' => 'gpt-4o-mini']);
|
||||
Http::fake([
|
||||
'api.openai.com/*' => Http::response(['choices' => [['message' => ['content' => 'Create a Business QR under My Codes.']]]]),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user())
|
||||
->postJson('/afia/chat', ['message' => 'How do I create a business QR?'])
|
||||
->assertOk()
|
||||
->assertJson(['reply' => 'Create a Business QR under My Codes.']);
|
||||
|
||||
Http::assertSent(fn ($r) => str_contains($r->url(), 'openai.com')
|
||||
&& collect($r['messages'])->first()['role'] === 'system'
|
||||
&& str_contains(collect($r['messages'])->first()['content'], 'Ladill QR Plus'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user