Display-Module in der Modulliste duplizieren.
Ermöglicht das Kopieren inklusive aller Inhalte und Einstellungen mit fortlaufender Benennung als „Kopie N - …“. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
bebfa63e87
commit
6c2da9bdac
3 changed files with 116 additions and 0 deletions
|
|
@ -132,6 +132,65 @@ test('can toggle display version active status', function () {
|
|||
expect($version->fresh()->is_active)->toBeFalse();
|
||||
});
|
||||
|
||||
test('can copy a display version with all items and settings', function () {
|
||||
$user = User::factory()->create();
|
||||
$source = DisplayVersion::factory()->create([
|
||||
'name' => 'B2In Immobilien Dark',
|
||||
'type' => DisplayVersionType::B2in,
|
||||
'settings' => ['theme' => 'dark', 'show_footer' => false],
|
||||
'is_active' => true,
|
||||
]);
|
||||
DisplayVersionItem::factory()->create([
|
||||
'display_version_id' => $source->id,
|
||||
'item_type' => 'media',
|
||||
'content' => ['headline' => 'Test Headline'],
|
||||
'sort_order' => 0,
|
||||
]);
|
||||
DisplayVersionItem::factory()->create([
|
||||
'display_version_id' => $source->id,
|
||||
'item_type' => 'media',
|
||||
'content' => ['headline' => 'Zweites Medium'],
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
Livewire::actingAs($user)
|
||||
->test(DisplayVersionList::class)
|
||||
->call('copyVersion', $source->id);
|
||||
|
||||
$copy = DisplayVersion::query()->where('name', 'Kopie 1 - B2In Immobilien Dark')->first();
|
||||
|
||||
expect($copy)->not->toBeNull()
|
||||
->and($copy->type)->toBe(DisplayVersionType::B2in)
|
||||
->and($copy->settings)->toBe(['theme' => 'dark', 'show_footer' => false])
|
||||
->and($copy->is_active)->toBeTrue()
|
||||
->and($copy->items)->toHaveCount(2)
|
||||
->and($copy->items->pluck('content.headline')->all())->toBe(['Test Headline', 'Zweites Medium']);
|
||||
});
|
||||
|
||||
test('copying a display version increments the copy number', function () {
|
||||
$user = User::factory()->create();
|
||||
$source = DisplayVersion::factory()->create(['name' => 'Schaufenster Video']);
|
||||
|
||||
Livewire::actingAs($user)
|
||||
->test(DisplayVersionList::class)
|
||||
->call('copyVersion', $source->id)
|
||||
->call('copyVersion', $source->id);
|
||||
|
||||
expect(DisplayVersion::where('name', 'Kopie 1 - Schaufenster Video')->exists())->toBeTrue()
|
||||
->and(DisplayVersion::where('name', 'Kopie 2 - Schaufenster Video')->exists())->toBeTrue();
|
||||
});
|
||||
|
||||
test('copying an existing copy keeps the original base name in the title', function () {
|
||||
$user = User::factory()->create();
|
||||
$copy = DisplayVersion::factory()->create(['name' => 'Kopie 1 - Angebote Schauraum']);
|
||||
|
||||
Livewire::actingAs($user)
|
||||
->test(DisplayVersionList::class)
|
||||
->call('copyVersion', $copy->id);
|
||||
|
||||
expect(DisplayVersion::where('name', 'Kopie 2 - Angebote Schauraum')->exists())->toBeTrue();
|
||||
});
|
||||
|
||||
// ========================================
|
||||
// DisplayVersionEditor
|
||||
// ========================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue