Neues Modul Glossar (0.27.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m52s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m31s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m58s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m52s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m31s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m58s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d148f2fbe2
commit
0bd20a527e
121 changed files with 946 additions and 298 deletions
76
tests/Feature/Glossar/GlossarTest.php
Normal file
76
tests/Feature/Glossar/GlossarTest.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Glossar;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Glossar\Models\GlossaryEntry;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GlossarTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $editor;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$role = Role::query()->create(['name' => 'Glossar']);
|
||||
$role->grants()->create(['ability' => 'glossary.manage']);
|
||||
$this->editor = User::factory()->withRoles([$role])->create();
|
||||
}
|
||||
|
||||
public function test_entries_are_sorted_alphabetically_with_umlauts_and_numbers(): void
|
||||
{
|
||||
foreach (['Zeiterfassung', 'Überstunden', 'Arbeitszeit', '24-Stunden-Dienst', 'Ärztlicher Dienst', 'Budget'] as $term) {
|
||||
GlossaryEntry::query()->create(['term' => $term]);
|
||||
}
|
||||
|
||||
$this->actingAs(User::factory()->create())->get('/glossar')->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||
->component('glossar::Index')
|
||||
->where('canManage', false)
|
||||
->where('entries', fn ($entries) => collect($entries)->pluck('term')->all() === ['24-Stunden-Dienst', 'Arbeitszeit', 'Ärztlicher Dienst', 'Budget', 'Überstunden', 'Zeiterfassung']
|
||||
&& collect($entries)->pluck('letter')->all() === ['#', 'A', 'A', 'B', 'U', 'Z']));
|
||||
}
|
||||
|
||||
public function test_editors_maintain_entries_in_the_portal(): void
|
||||
{
|
||||
$this->actingAs($this->editor)->get('/glossar')->assertInertia(fn (Assert $page) => $page->where('canManage', true));
|
||||
$this->assertFalse($this->editor->canAccessAdmin(), 'Glossar pflegen braucht kein Backend');
|
||||
|
||||
$this->post('/glossar', [
|
||||
'term' => 'Dienstvereinbarung', 'aliases' => 'DV',
|
||||
'description' => '<p>Vereinbarung zwischen <strong>MAV</strong> und Dienstgeber<script>alert(1)</script></p>',
|
||||
'link_url' => 'javascript:alert(1)',
|
||||
])->assertRedirect()->assertSessionHasNoErrors();
|
||||
|
||||
$entry = GlossaryEntry::query()->sole();
|
||||
$this->assertSame('D', $entry->letter);
|
||||
$this->assertStringContainsString('<strong>MAV</strong>', $entry->description);
|
||||
$this->assertStringNotContainsString('script', $entry->description);
|
||||
$this->assertNull($entry->link_url);
|
||||
|
||||
$this->post('/glossar', ['term' => 'dienstvereinbarung'])->assertSessionHasErrors(['term' => 'Diesen Begriff gibt es schon im Glossar.']);
|
||||
|
||||
$this->put("/glossar/{$entry->id}", ['term' => 'Dienstvereinbarung', 'link_url' => '/seiten/mav', 'link_label' => 'Zur MAV'])->assertSessionHasNoErrors();
|
||||
$this->assertSame('/seiten/mav', $entry->fresh()->link_url);
|
||||
|
||||
$this->delete("/glossar/{$entry->id}")->assertRedirect();
|
||||
$this->assertSame(0, GlossaryEntry::query()->count());
|
||||
}
|
||||
|
||||
public function test_others_cannot_edit_and_entries_are_found_in_the_global_search(): void
|
||||
{
|
||||
$entry = GlossaryEntry::query()->create(['term' => 'Rufbereitschaft', 'description' => '<p>Erreichbar außerhalb der Dienstzeit</p>']);
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)->post('/glossar', ['term' => 'x'])->assertForbidden();
|
||||
$this->actingAs($user)->delete("/glossar/{$entry->id}")->assertForbidden();
|
||||
|
||||
$this->getJson('/suche/live?q=Rufbereit')->assertOk()->assertJsonFragment(['url' => '/glossar#begriff-'.$entry->id]);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ class CorePluginToggleTest extends TestCase
|
|||
|
||||
$file = storage_path('app/plugins.json');
|
||||
$this->previousState = is_file($file) ? file_get_contents($file) : null;
|
||||
file_put_contents($file, json_encode(['news' => ['enabled' => false], 'events' => ['enabled' => false], 'pages' => ['enabled' => false], 'forms' => ['enabled' => false], 'wordpress-import' => ['enabled' => false], 'downloads' => ['enabled' => false], 'qm' => ['enabled' => false], 'gemeinsam' => ['enabled' => false], 'speiseplan' => ['enabled' => false], 'it-service' => ['enabled' => false]]));
|
||||
file_put_contents($file, json_encode(['news' => ['enabled' => false], 'events' => ['enabled' => false], 'pages' => ['enabled' => false], 'forms' => ['enabled' => false], 'wordpress-import' => ['enabled' => false], 'downloads' => ['enabled' => false], 'qm' => ['enabled' => false], 'gemeinsam' => ['enabled' => false], 'speiseplan' => ['enabled' => false], 'it-service' => ['enabled' => false], 'glossar' => ['enabled' => false]]));
|
||||
|
||||
// Plugins werden beim Start der Anwendung geladen – also neu starten.
|
||||
$this->refreshApplication();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue