Frag das Portal (0.64.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Failing after 19m38s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 24m17s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m13s
CI / Build-Artefakte aktuell (pull_request) Successful in 6m4s

Antworten mit Quellen aus Seiten, QM-Dokumenten, Glossar und Neuigkeiten –
nur aus Sichtbarem, über den KI-Assistenten (Anthropic, OpenAI, Ollama).
Wissensquellen als Registry für Plugins, Auswertung ohne Personenbezug.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-10-07 18:08:35 +00:00
parent 372f0656f9
commit 9d8bdc08ce
168 changed files with 1751 additions and 383 deletions

View file

@ -2,12 +2,15 @@
namespace Tests\Feature\Qm;
use App\Ai\AiAssistant;
use App\Models\Role;
use App\Models\User;
use App\Support\Permissions\Audiences;
use App\Support\Settings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Inertia\Testing\AssertableInertia as Assert;
use Inhaus\Plugins\Qm\Filament\Pages\QmSettings;
@ -255,6 +258,27 @@ class QmTest extends TestCase
$this->get('/qm/suche?q=checkliste')->assertInertia(fn (Assert $p) => $p->where('results.0.in_content', false));
}
public function test_ask_portal_answers_from_document_text_in_visible_folders_only(): void
{
$this->addFile($this->personal, 'Hygieneplan', $this->docx('hygiene.docx', 'Haendedesinfektion vor und nach jedem Bewohnerkontakt, mindestens 30 Sekunden.'));
$secret = QmCategory::query()->create(['name' => 'Leitung']);
$folder = QmFolder::query()->create(['name' => 'Protokolle', 'category_id' => $secret->id]);
$this->addFile($folder, 'Leitungsprotokoll', $this->pdf('p.pdf', ['Haendedesinfektion Budget vertraulich']));
Audiences::sync('qm_category', $secret->id, ['department' => ['Leitung']]);
QmTree::flush();
app(Settings::class)->setMany(['ai.enabled' => true, 'ai.api_key' => Crypt::encryptString('sk-test'), 'ai.model' => 'claude-sonnet-5', 'ask.enabled' => true]);
Http::fake([AiAssistant::ENDPOINT => Http::response(['content' => [['type' => 'text', 'text' => 'Mindestens 30 Sekunden [1].']]])]);
$result = $this->actingAs(User::factory()->create(['department' => 'Pflege']))
->postJson('/frag-das-portal', ['question' => 'Wie lange dauert die Haendedesinfektion?'])->assertOk()->json();
$this->assertTrue($result['found']);
$this->assertSame(['Hygieneplan'], array_column($result['sources'], 'title'));
$this->assertSame('Qualitätsmanagement', $result['sources'][0]['label']);
Http::assertSent(fn ($request) => str_contains($request['messages'][0]['content'], 'mindestens 30 Sekunden')
&& ! str_contains($request['messages'][0]['content'], 'vertraulich'));
}
public function test_excluded_roles_do_not_see_the_module(): void
{
$clients = Role::query()->create(['name' => 'Klient*innen']);