QM-Texterkennung: Imagick nur mit Ghostscript als verfügbar melden
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 3m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 3m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 3m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 2m56s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m4s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 4m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m39s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m10s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 3m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 3m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 3m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 2m56s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m4s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 4m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m39s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m10s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5a360d3cc7
commit
b50d089946
117 changed files with 1747 additions and 2 deletions
92
tests/Feature/Gemeinsam/GemeinsamTest.php
Normal file
92
tests/Feature/Gemeinsam/GemeinsamTest.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Gemeinsam;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Birthdays\Models\Birthday;
|
||||
use Inhaus\Plugins\Gemeinsam\Models\Entry;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GemeinsamTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $hr;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Carbon::setTestNow('2026-10-05 10:00');
|
||||
$role = Role::query()->create(['name' => 'Personalabteilung']);
|
||||
$role->grants()->create(['ability' => 'gemeinsam.manage']);
|
||||
$this->hr = User::factory()->withRoles([$role])->create();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Carbon::setTestNow();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_hr_maintains_all_sections_and_everyone_sees_the_month(): void
|
||||
{
|
||||
$new = User::factory()->create(['first_name' => 'Nora', 'last_name' => 'Neu', 'department' => 'Pflege', 'location' => 'Hamburg']);
|
||||
|
||||
$this->actingAs($this->hr);
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'welcome', 'user_id' => $new->id, 'date' => '2026-10-01'])->assertSessionHasNoErrors();
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'transfer', 'name' => 'Tim Wechsel', 'from' => 'Werkstatt Nord', 'to' => 'Verwaltung', 'date' => '2026-10-15'])->assertSessionHasNoErrors();
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'jubilee', 'name' => 'Jutta Jubel', 'label' => '25 Jahre', 'date' => '2026-10-20'])->assertSessionHasNoErrors();
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'farewell', 'name' => 'Rolf Ruhestand', 'label' => 'Ruhestand', 'date' => '2026-10-31'])->assertSessionHasNoErrors();
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'memoriam', 'name' => 'Gerda Gedenk', 'born_on' => '1958-03-12', 'date' => '2026-09-28', 'text' => 'Wir werden sie vermissen.'])->assertSessionHasNoErrors();
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'welcome', 'date' => '2026-10-01'])->assertSessionHasErrors('name');
|
||||
|
||||
$this->actingAs(User::factory()->create())->get('/gemeinsam')->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->component('gemeinsam::Index')
|
||||
->where('month', '2026-10')
|
||||
->where('canManage', false)
|
||||
->where('sections.0.key', 'welcome')
|
||||
->where('sections.0.entries.0.name', 'Nora Neu')
|
||||
->where('sections.0.entries.0.department', 'Pflege', 'aus dem Profil')
|
||||
->where('sections.1.entries.0.to', 'Verwaltung')
|
||||
->where('sections.3.entries.0.label', '25 Jahre')
|
||||
->where('sections.5.entries', []));
|
||||
|
||||
// Gedenken im September
|
||||
$this->get('/gemeinsam?monat=2026-09')->assertInertia(fn (Assert $p) => $p
|
||||
->where('sections.5.entries.0.name', 'Gerda Gedenk')
|
||||
->where('sections.5.entries.0.born_on', '1958-03-12'));
|
||||
}
|
||||
|
||||
public function test_birthdays_come_from_the_birthday_plugin(): void
|
||||
{
|
||||
$anna = User::factory()->create(['first_name' => 'Anna', 'last_name' => 'Oktober']);
|
||||
Birthday::query()->create(['user_id' => $anna->id, 'month' => 10, 'day' => 14]);
|
||||
Birthday::query()->create(['user_id' => User::factory()->inactive()->create()->id, 'month' => 10, 'day' => 2]);
|
||||
Birthday::query()->create(['user_id' => User::factory()->create()->id, 'month' => 11, 'day' => 2]);
|
||||
|
||||
$this->actingAs(User::factory()->create())->get('/gemeinsam')->assertInertia(fn (Assert $p) => $p
|
||||
->where('sections.2.key', 'birthdays')
|
||||
->where('sections.2.automatic', true)
|
||||
->has('sections.2.entries', 1)
|
||||
->where('sections.2.entries.0.name', 'Anna Oktober')
|
||||
->where('sections.2.entries.0.date', '2026-10-14'));
|
||||
}
|
||||
|
||||
public function test_only_hr_can_change_entries(): void
|
||||
{
|
||||
$entry = Entry::query()->create(['section' => 'welcome', 'name' => 'X', 'date' => '2026-10-01']);
|
||||
|
||||
$this->actingAs(User::factory()->create());
|
||||
$this->post('/gemeinsam/eintraege', ['section' => 'welcome', 'name' => 'Y', 'date' => '2026-10-01'])->assertForbidden();
|
||||
$this->delete("/gemeinsam/eintraege/{$entry->id}")->assertForbidden();
|
||||
|
||||
$this->actingAs($this->hr)->put("/gemeinsam/eintraege/{$entry->id}", ['section' => 'welcome', 'name' => 'X Neu', 'date' => '2026-11-01'])->assertRedirect('/gemeinsam?monat=2026-11');
|
||||
$this->delete("/gemeinsam/eintraege/{$entry->id}");
|
||||
$this->assertSame(0, Entry::query()->count());
|
||||
}
|
||||
}
|
||||
100
tests/Feature/Speiseplan/SpeiseplanTest.php
Normal file
100
tests/Feature/Speiseplan/SpeiseplanTest.php
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Speiseplan;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Speiseplan\Models\Week;
|
||||
use Inhaus\Plugins\Speiseplan\SpeiseplanPlugin;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SpeiseplanTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $kitchen;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('local');
|
||||
Carbon::setTestNow('2026-09-30 09:00'); // Mittwoch, KW 40
|
||||
$role = Role::query()->create(['name' => 'Küche']);
|
||||
$role->grants()->create(['ability' => 'speiseplan.manage']);
|
||||
$this->kitchen = User::factory()->withRoles([$role])->create();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Carbon::setTestNow();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function upload(string $week): void
|
||||
{
|
||||
$this->actingAs($this->kitchen)->post('/speiseplan/wochen', ['week' => $week, 'image' => UploadedFile::fake()->image('plan.jpg', 1240, 1754)])->assertSessionHasNoErrors();
|
||||
}
|
||||
|
||||
public function test_weeks_ahead_current_and_next_week_are_shown(): void
|
||||
{
|
||||
$this->upload('2026-10-01'); // irgendein Tag → Montag 28.09.
|
||||
$this->upload('2026-10-05');
|
||||
$this->upload('2026-10-19'); // drei Wochen im Voraus
|
||||
|
||||
$this->assertSame(['2026-09-28', '2026-10-05', '2026-10-19'], Week::query()->orderBy('week_start')->pluck('week_start')->map->toDateString()->all());
|
||||
|
||||
$this->actingAs(User::factory()->create())->get('/speiseplan')->assertOk()->assertInertia(fn (Assert $p) => $p
|
||||
->component('speiseplan::Index')
|
||||
->where('weeks.0.title', 'Diese Woche')
|
||||
->where('weeks.0.plan.week', 40)
|
||||
->where('weeks.0.plan.width', 1240)
|
||||
->where('weeks.1.plan.week', 41)
|
||||
->where('canManage', false)
|
||||
->where('manage', null));
|
||||
|
||||
$this->get(Week::query()->first()->present()['image_url'])->assertOk();
|
||||
}
|
||||
|
||||
public function test_uploading_again_replaces_the_week(): void
|
||||
{
|
||||
$this->upload('2026-09-28');
|
||||
$old = Week::query()->sole()->path;
|
||||
$this->upload('2026-09-29');
|
||||
|
||||
$this->assertSame(1, Week::query()->count());
|
||||
Storage::disk('local')->assertMissing($old);
|
||||
}
|
||||
|
||||
public function test_only_images_are_stored_and_only_the_kitchen_uploads(): void
|
||||
{
|
||||
$this->actingAs($this->kitchen)->post('/speiseplan/wochen', ['week' => '2026-09-28', 'image' => UploadedFile::fake()->create('plan.pdf', 10, 'application/pdf')])->assertSessionHasErrors('image');
|
||||
$this->actingAs(User::factory()->create())->post('/speiseplan/wochen', ['week' => '2026-09-28', 'image' => UploadedFile::fake()->image('p.jpg')])->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_allergen_pdf_and_print_view(): void
|
||||
{
|
||||
$this->upload('2026-09-28');
|
||||
$this->actingAs($this->kitchen)->post('/speiseplan/allergene', ['file' => UploadedFile::fake()->create('Allergene.pdf', 20, 'application/pdf')])->assertSessionHasNoErrors();
|
||||
|
||||
$user = User::factory()->create();
|
||||
$this->actingAs($user)->get('/speiseplan')->assertInertia(fn (Assert $p) => $p->where('allergens.name', 'Allergene.pdf'));
|
||||
$this->get('/speiseplan/allergene')->assertOk()->assertHeader('Content-Type', 'application/pdf');
|
||||
$this->get('/speiseplan/druck')->assertOk()->assertInertia(fn (Assert $p) => $p->component('speiseplan::Print')->has('plans', 1));
|
||||
}
|
||||
|
||||
public function test_old_weeks_are_deleted_after_two_weeks(): void
|
||||
{
|
||||
foreach (['2026-09-07', '2026-09-14', '2026-09-21', '2026-09-28'] as $week) {
|
||||
$this->upload($week);
|
||||
}
|
||||
|
||||
$this->assertSame(1, SpeiseplanPlugin::purge());
|
||||
$this->assertSame(['2026-09-14', '2026-09-21', '2026-09-28'], Week::query()->orderBy('week_start')->pluck('week_start')->map->toDateString()->all());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue