Initialer Laravel Commit für BetiX
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
2026-04-04 18:01:50 +02:00
commit 0280278978
374 changed files with 65210 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace Tests\Feature\Gateway;
use App\Models\User;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class AdminSupportAdminControllerTest extends TestCase
{
private function base(): string { return rtrim((string) config('services.backend.base'), '/'); }
private function adminUser()
{
if (class_exists(User::class) && method_exists(User::class, 'factory')) {
return User::factory()->make(['id' => 1201, 'username' => 'admin', 'role' => 'Admin', 'email_verified_at' => now()]);
}
return new class { public $id=1201; public $username='admin'; public $role='Admin'; };
}
public function test_index_renders_with_threads()
{
Http::fake([
$this->base() . '/admin/support' => Http::response([
'enabled' => true,
'threads' => [ ['id' => 't-1', 'status' => 'ai'] ],
'ollama' => ['healthy' => true],
], 200),
]);
$res = $this->actingAs($this->adminUser())->get('/admin/support');
$res->assertStatus(200);
}
public function test_settings_success_sets_flash()
{
Http::fake([
$this->base() . '/admin/support/settings' => Http::response(['message' => 'OK'], 200),
]);
$res = $this->actingAs($this->adminUser())->post('/admin/support/settings', ['enabled' => true]);
$res->assertSessionHas('success');
}
public function test_reply_and_close_success_set_flash()
{
Http::fake([
$this->base() . '/admin/support/threads/t-1/message' => Http::response(['message' => 'Sent'], 200),
$this->base() . '/admin/support/threads/t-1/close' => Http::response(['message' => 'Closed'], 200),
]);
$this->actingAs($this->adminUser())
->post('/admin/support/threads/t-1/message', ['text' => 'hi'])
->assertSessionHas('success');
$this->actingAs($this->adminUser())
->post('/admin/support/threads/t-1/close')
->assertSessionHas('success');
}
}