Filtere im Aufbau-Picker nach der Filterregel, nenne betroffene Objekte und tausche beim Sortieren nur Nachbarn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e20f428a57
commit
8a97d9c334
5 files changed
+81
-7
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
@@ -15,11 +16,13 @@
|
||||
use App\Filament\Pages\RedaktionelleStammdaten;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -241,6 +244,45 @@ public function test_pillars_keep_their_own_management(): void
|
||||
$this->assertArrayNotHasKey(EditorialDimension::PILLAR_SLUG, (new RedaktionelleStammdaten)->gruppen());
|
||||
}
|
||||
|
||||
public function test_filters_in_picker_and_member_library_follow_their_rules_for_inactive_values(): void
|
||||
{
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Lara im Park');
|
||||
$schule = $this->value('einsatzbereich', 'schule');
|
||||
$kita = $this->value('einsatzbereich', 'kita');
|
||||
app(IdentityDimension::class)->assign($film, $schule);
|
||||
$schule->update(['is_active' => false]);
|
||||
$kita->update(['is_active' => false]);
|
||||
$modul = app(ContentService::class)->createComposition('Grenzen üben', CompositionKind::Uebung);
|
||||
|
||||
// Aufbau-Picker: verwendete inaktive Werte bleiben als Filter auffindbar, unbenutzte inaktive nicht.
|
||||
$seite = Livewire::actingAs($this->editor(), 'staff')->test(EditExercise::class, ['record' => $modul->getKey()]);
|
||||
$labels = array_merge(...array_map(fn (array $g): array => array_column($g['values'], 'label'), $seite->instance()->pickerDimensionGroups()));
|
||||
$this->assertContains('Schule (inaktiv)', $labels);
|
||||
$this->assertNotContains('Kita (inaktiv)', $labels);
|
||||
|
||||
// Mitgliederbibliothek: nur aktive Werte, ein gewählter inaktiver bleibt sichtbar.
|
||||
$vokabular = app(EditorialVocabulary::class);
|
||||
$ids = fn ($dimensionen): array => $dimensionen->flatMap(fn ($d) => $d->values->pluck('id'))->map(fn ($id): int => (int) $id)->all();
|
||||
$this->assertNotContains($schule->id, $ids($vokabular->memberFilterDimensions()));
|
||||
$this->assertContains($schule->id, $ids($vokabular->memberFilterDimensions([$schule->id])));
|
||||
}
|
||||
|
||||
public function test_reordering_swaps_only_the_two_neighbours(): void
|
||||
{
|
||||
$werte = $this->dimension('zielgruppe')->values()->get();
|
||||
[$erster, $zweiter, $dritter] = [$werte[0], $werte[1], $werte[2]];
|
||||
$vorher = $dritter->updated_at?->toDateTimeString();
|
||||
Carbon::setTestNow(now()->addMinute());
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')->test(RedaktionelleStammdaten::class)
|
||||
->call('zeigeGruppe', 'zielgruppe')
|
||||
->callAction(TestAction::make('runter')->table($erster));
|
||||
|
||||
$this->assertSame([$zweiter->id, $erster->id], $this->dimension('zielgruppe')->values()->limit(2)->pluck('id')->all());
|
||||
$this->assertSame($vorher, $dritter->fresh()->updated_at?->toDateTimeString(), 'Unbeteiligte Werte werden nicht geschrieben.');
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
|
||||
public function test_staff_without_the_editor_role_cannot_change_master_data(): void
|
||||
{
|
||||
$katalog = User::factory()->katalogverwalter()->create();
|
||||
|
||||
Reference in new issue
Block a user