Frag das Portal durchsucht alles, neue Demo-Inhalte (0.66.0)
All checks were successful
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) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
All checks were successful
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) Successful in 8m33s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 9m8s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 17m55s
CI / Build-Artefakte aktuell (pull_request) Successful in 9m50s
- Wissensquellen: Termine, Downloads, Formulare, Stellen, Ideen, Umfragen, Personen, eigene IT-Tickets/Geräte (OpenNIT, je Anfrage zwischengespeichert) - Ranking mit IDF, Abfrage je Begriff, Abkürzungen als ganze Wörter, LIKE unabhängig von Groß-/Kleinschreibung (JSON-Spalten), Datum im Prompt - Demo-Inhalte für einen Träger der Eingliederungshilfe (DemoData), mehrseitige PDFs, vorhandene Inhalte je Bereich entfernen Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1656cd8090
commit
3addc09c38
165 changed files with 2258 additions and 814 deletions
|
|
@ -15,6 +15,7 @@ use Illuminate\Http\Client\Request;
|
|||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use Inhaus\Plugins\Glossar\Models\GlossaryEntry;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Inhaus\Plugins\Pages\Models\Page;
|
||||
|
|
@ -92,6 +93,49 @@ class AskPortalTest extends TestCase
|
|||
$this->assertSame(['id', 'question', 'answered', 'source_count', 'asked_on'], array_keys($logged->getAttributes()));
|
||||
}
|
||||
|
||||
public function test_events_people_and_short_abbreviations(): void
|
||||
{
|
||||
$event = Event::query()->create([
|
||||
'title' => 'Sommerfest der Werkstatt', 'description' => 'Grillen und Musik', 'location' => 'Werkstatt am Kanal',
|
||||
'starts_at' => now()->addDays(10)->setTime(14, 0), 'ends_at' => now()->addDays(10)->setTime(18, 0), 'is_published' => true,
|
||||
]);
|
||||
Event::query()->create([
|
||||
'title' => 'Sommerfest 2024', 'description' => 'Längst vorbei', 'starts_at' => now()->subYears(2), 'is_published' => true,
|
||||
]);
|
||||
$admin = User::factory()->create(['first_name' => 'Jens', 'last_name' => 'Hüsing', 'job_title' => 'IT-Administrator', 'department' => 'IT', 'phone' => '05482 230']);
|
||||
$this->page('Arbeiten mit Kolleginnen', '<p>Wir arbeiten mit Freude miteinander.</p>');
|
||||
$this->fakeAi('Am '.now()->addDays(10)->format('d.m.').' um 14 Uhr [1].');
|
||||
|
||||
$this->actingAs($this->user)->postJson('/frag-das-portal', ['question' => 'Wann ist das Sommerfest?'])->assertOk()->assertJsonPath('sources.0.url', '/termine/'.$event->id);
|
||||
Http::assertSent(fn (Request $r) => str_contains($r['messages'][0]['content'], 'Werkstatt am Kanal')
|
||||
&& str_contains($r['messages'][0]['content'], 'Heute ist ')
|
||||
&& ! str_contains($r['messages'][0]['content'], 'Längst vorbei'));
|
||||
|
||||
$this->assertSame(['it', 'zuständig'], Keywords::from('Wer ist für die IT zuständig?'));
|
||||
$this->fakeAi('Jens Hüsing [1].');
|
||||
$result = $this->actingAs($this->user)->postJson('/frag-das-portal', ['question' => 'Wer ist für die IT zuständig?'])->json();
|
||||
$this->assertSame([route('people.show', $admin)], array_column($result['sources'], 'url'));
|
||||
// „IT“ trifft kein „mit“ oder „arbeiten“
|
||||
Http::assertSent(fn (Request $r) => str_contains($r['messages'][0]['content'], '05482 230') && ! str_contains($r['messages'][0]['content'], 'miteinander'));
|
||||
}
|
||||
|
||||
public function test_own_it_tickets_are_a_source_for_the_asker_only(): void
|
||||
{
|
||||
app(\Inhaus\Plugins\ItService\OpenNit\Settings::class)->save(['url' => 'https://opennit.example.com/api/ex', 'token' => 'tok', 'secret' => 'geheim', 'auto_reserve' => 'default', 'intro' => null]);
|
||||
Http::fake([
|
||||
'*/my-tickets*' => Http::response(['tickets' => [['id' => 42, 'number' => 'T-1042', 'subject' => 'Drucker im Büro druckt nicht', 'status' => 'open', 'created_at' => '2026-10-01']]]),
|
||||
'*/tickets/42*' => Http::response(['ticket' => ['id' => 42, 'subject' => 'Drucker im Büro druckt nicht', 'status' => 'open', 'description' => '<p>Papierstau</p>'], 'replies' => [['message' => 'Toner ist bestellt.', 'is_staff' => true]]]),
|
||||
'*/my-assets*' => Http::response(['assets' => []]),
|
||||
AiAssistant::ENDPOINT => Http::response(['content' => [['type' => 'text', 'text' => 'Der Toner ist bestellt [1].']]]),
|
||||
]);
|
||||
|
||||
$result = $this->actingAs($this->user)->postJson('/frag-das-portal', ['question' => 'Was ist mit meinem Drucker-Ticket?'])->assertOk()->json();
|
||||
|
||||
$this->assertSame('Mein Ticket: Drucker im Büro druckt nicht', $result['sources'][0]['title']);
|
||||
Http::assertSent(fn (Request $r) => str_contains($r->url(), 'my-tickets') && str_contains($r->url(), urlencode($this->user->email)));
|
||||
Http::assertSent(fn (Request $r) => $r->url() === AiAssistant::ENDPOINT && str_contains($r['messages'][0]['content'], 'Toner ist bestellt'));
|
||||
}
|
||||
|
||||
public function test_nothing_found_does_not_call_the_ai(): void
|
||||
{
|
||||
Http::fake();
|
||||
|
|
|
|||
|
|
@ -14,13 +14,18 @@ use Illuminate\Support\Facades\Storage;
|
|||
use Inhaus\Plugins\Downloads\Models\Download;
|
||||
use Inhaus\Plugins\Downloads\Models\DownloadVersion;
|
||||
use Inhaus\Plugins\Events\Models\Event;
|
||||
use Inhaus\Plugins\Forms\Models\Form;
|
||||
use Inhaus\Plugins\Gemeinsam\Models\Entry;
|
||||
use Inhaus\Plugins\Glossar\Models\GlossaryEntry;
|
||||
use Inhaus\Plugins\Ideen\Models\Idea;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Inhaus\Plugins\Pages\Models\Page;
|
||||
use Inhaus\Plugins\Qm\Models\QmEntry;
|
||||
use Inhaus\Plugins\Qm\Models\QmFile;
|
||||
use Inhaus\Plugins\Qm\Models\QmFolder;
|
||||
use Inhaus\Plugins\Stellen\Models\JobPosting;
|
||||
use Inhaus\Plugins\Umfragen\Models\Poll;
|
||||
use Livewire\Livewire;
|
||||
use RuntimeException;
|
||||
use Tests\TestCase;
|
||||
|
|
@ -48,36 +53,49 @@ class DemoContentTest extends TestCase
|
|||
|
||||
$this->assertSame([], $result['warnings']);
|
||||
$this->assertTrue($demo->isInstalled());
|
||||
$this->assertSame(16, $result['counts']['Personen']);
|
||||
$this->assertSame(16, User::query()->where('email', 'like', '%@demo.inhaus.invalid')->count());
|
||||
$this->assertSame(26, $result['counts']['Personen']);
|
||||
$this->assertSame(26, User::query()->where('email', 'like', '%@demo.inhaus.invalid')->count());
|
||||
$this->assertNotNull(User::query()->where('email', 'thomas.albers@demo.inhaus.invalid')->value('manager_id'));
|
||||
$this->assertSame('05931 4080-130', User::query()->where('email', 'jens.huesing@demo.inhaus.invalid')->value('phone'));
|
||||
|
||||
$this->assertSame(16, NewsPost::query()->published()->count());
|
||||
$this->assertSame(3, NewsPost::query()->where('is_featured', true)->count());
|
||||
$this->assertSame(12, NewsPost::query()->published()->count());
|
||||
$this->assertSame(2, NewsPost::query()->where('is_featured', true)->count());
|
||||
$this->assertSame(1, NewsPost::query()->where('must_read', true)->count());
|
||||
$post = NewsPost::query()->whereNotNull('cover_path')->firstOrFail();
|
||||
Storage::disk('uploads')->assertExists($post->cover_path);
|
||||
$this->assertStringContainsString('-thumb.webp', $post->coverUrl('thumb'));
|
||||
$this->assertStringContainsString('<blockquote>', NewsPost::query()->where('slug', 'gemeinsam-zukunft-gestalten-unsere-strategie-2030')->value('body_html'));
|
||||
$this->assertStringContainsString('<blockquote>', NewsPost::query()->where('title', 'Neues Gewaltschutzkonzept gilt ab sofort')->value('body_html'));
|
||||
|
||||
$this->assertSame(8, Event::query()->upcoming()->count());
|
||||
$this->assertSame(4, Page::query()->whereNotNull('content')->count());
|
||||
$this->assertNotEmpty(Page::query()->where('path', 'mitarbeitervertretung')->firstOrFail()->content['blocks']);
|
||||
$this->assertSame(13, Event::query()->upcoming()->count());
|
||||
$this->assertSame(16, Event::query()->where('title', 'Erste-Hilfe-Kurs (Auffrischung)')->value('capacity'));
|
||||
$this->assertSame(31, Page::query()->whereNotNull('content')->count());
|
||||
$this->assertNotEmpty(Page::query()->where('title', 'Urlaub beantragen')->firstOrFail()->content['blocks']);
|
||||
|
||||
$this->assertSame(6, Download::query()->count());
|
||||
$this->assertSame(9, Download::query()->count());
|
||||
$version = DownloadVersion::query()->firstOrFail();
|
||||
$this->assertStringStartsWith('%PDF-1.4', Storage::disk('local')->get($version->path));
|
||||
|
||||
$this->assertSame(5, QmFolder::query()->count());
|
||||
$this->assertSame(10, QmEntry::query()->count());
|
||||
$this->assertSame(7, QmFolder::query()->count());
|
||||
$this->assertSame(15, QmEntry::query()->count());
|
||||
$this->assertNotEmpty(app(Settings::class)->get('qm.home.intro'));
|
||||
$qmFile = QmFile::query()->firstOrFail();
|
||||
$qmFile = QmFile::query()->whereHas('entry', fn ($q) => $q->where('title', 'Umgang mit Medikamenten'))->firstOrFail();
|
||||
Storage::disk('local')->assertExists($qmFile->path);
|
||||
$this->assertSame('ok', $qmFile->text_status);
|
||||
$this->assertStringContainsString('Geltungsbereich', (string) $qmFile->text);
|
||||
// Auch der Text auf der zweiten Seite ist durchsuchbar
|
||||
$this->assertStringContainsString('Vier-Augen-Prinzip', (string) $qmFile->text);
|
||||
$this->assertStringContainsString('Medikamentenschulung', (string) $qmFile->text);
|
||||
|
||||
$this->assertSame(6, Entry::query()->count());
|
||||
$this->assertSame(35, GlossaryEntry::query()->count());
|
||||
$this->assertSame(4, JobPosting::query()->open()->count());
|
||||
$this->assertSame(0, JobPosting::query()->whereNull('announced_at')->count(), 'Demo-Stellen kündigen sich nicht an');
|
||||
$this->assertSame(6, Idea::query()->count());
|
||||
$this->assertTrue(Idea::query()->where('anonymous', true)->exists());
|
||||
$this->assertSame(2, Poll::query()->count());
|
||||
$this->assertSame(3, Form::query()->count());
|
||||
|
||||
$this->assertSame(5, Entry::query()->count());
|
||||
$this->assertSame(1, DashboardTile::query()->count());
|
||||
$this->assertCount(10, app(Settings::class)->get('portal.quick_links'));
|
||||
$this->assertSame('Vivendi PEP', app(Settings::class)->get('portal.quick_links')[0]['label']);
|
||||
|
||||
// Zweites Anlegen wird abgelehnt.
|
||||
try {
|
||||
|
|
@ -104,6 +122,11 @@ class DemoContentTest extends TestCase
|
|||
$this->assertSame(0, QmFolder::query()->count());
|
||||
$this->assertSame(0, QmEntry::query()->count());
|
||||
$this->assertSame(0, Entry::query()->count());
|
||||
$this->assertSame(0, GlossaryEntry::query()->count());
|
||||
$this->assertSame(0, JobPosting::query()->count());
|
||||
$this->assertSame(0, Idea::query()->count());
|
||||
$this->assertSame(0, Poll::query()->count());
|
||||
$this->assertSame(0, Form::query()->count());
|
||||
$this->assertSame(0, DashboardTile::query()->count());
|
||||
$this->assertNull(app(Settings::class)->get('portal.quick_links'));
|
||||
$this->assertNull(app(Settings::class)->get('qm.home.intro'));
|
||||
|
|
@ -114,6 +137,37 @@ class DemoContentTest extends TestCase
|
|||
$this->assertSame(['records' => 0, 'files' => 0, 'warnings' => []], $demo->remove());
|
||||
}
|
||||
|
||||
public function test_existing_content_can_be_cleared_per_area(): void
|
||||
{
|
||||
$admin = User::factory()->admin()->create();
|
||||
NewsPost::factory()->create(['title' => 'Neues Passwort!!!', 'body' => '<p>dfsafdfsafdfsafdfs</p>']);
|
||||
Event::query()->create(['title' => 'Test', 'starts_at' => now(), 'is_published' => true]);
|
||||
GlossaryEntry::query()->create(['term' => 'Quatsch']);
|
||||
|
||||
Livewire::actingAs($admin)->test(DemoContentPage::class)
|
||||
->set('clearAreas', ['news', 'glossar'])
|
||||
->set('clearConfirm', 'falsch')
|
||||
->call('clear')
|
||||
->assertNotified('Bitte zur Bestätigung „LÖSCHEN“ eintippen.');
|
||||
$this->assertSame(1, NewsPost::query()->count());
|
||||
|
||||
Livewire::actingAs($admin)->test(DemoContentPage::class)
|
||||
->set('clearAreas', ['news', 'glossar'])
|
||||
->set('clearConfirm', 'löschen')
|
||||
->call('clear');
|
||||
|
||||
$this->assertSame(0, NewsPost::query()->count());
|
||||
$this->assertSame(0, NewsCategory::query()->count());
|
||||
$this->assertSame(0, GlossaryEntry::query()->count());
|
||||
$this->assertSame(1, Event::query()->count(), 'Nicht gewählte Bereiche bleiben');
|
||||
$this->assertTrue(User::query()->whereKey($admin->id)->exists());
|
||||
|
||||
// Bei angelegten Demo-Inhalten zuerst diese entfernen
|
||||
app(DemoContent::class)->install($admin);
|
||||
$this->expectExceptionMessage('zuerst die Demo-Inhalte entfernen');
|
||||
app(DemoContent::class)->clear(['events']);
|
||||
}
|
||||
|
||||
public function test_existing_quick_links_are_kept_and_restored(): void
|
||||
{
|
||||
$links = [['label' => 'Intranet alt', 'url' => 'https://example.org', 'icon' => 'link', 'new_tab' => true]];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue