Display Module 13-05-2026
This commit is contained in:
parent
6a65354f4c
commit
9262132325
41 changed files with 496 additions and 334 deletions
|
|
@ -4,7 +4,6 @@ use App\Models\Display;
|
|||
use App\Models\DisplayPlaylist;
|
||||
use App\Models\DisplayPlaylistItem;
|
||||
use App\Models\DisplayVersion;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
it('creates the display_playlists table with unique status per display', function () {
|
||||
|
|
@ -27,64 +26,8 @@ it('adds is_test and preview_token to displays', function () {
|
|||
expect(Schema::hasColumns('displays', ['is_test', 'preview_token']))->toBeTrue();
|
||||
});
|
||||
|
||||
it('migrates existing pivot entries into a published playlist with same ordering', function () {
|
||||
$display = Display::factory()->create();
|
||||
$moduleA = DisplayVersion::factory()->create(['name' => 'Modul A']);
|
||||
$moduleB = DisplayVersion::factory()->create(['name' => 'Modul B']);
|
||||
|
||||
DB::table('display_playlists')->where('display_id', $display->id)->delete();
|
||||
|
||||
DB::table('display_display_version')->insert([
|
||||
['display_id' => $display->id, 'display_version_id' => $moduleA->id, 'sort_order' => 0],
|
||||
['display_id' => $display->id, 'display_version_id' => $moduleB->id, 'sort_order' => 1],
|
||||
]);
|
||||
|
||||
$migration = require database_path('migrations/2026_05_11_113330_migrate_pivot_to_display_playlists.php');
|
||||
$migration->up();
|
||||
|
||||
$playlist = DisplayPlaylist::query()
|
||||
->where('display_id', $display->id)
|
||||
->where('status', DisplayPlaylist::STATUS_PUBLISHED)
|
||||
->first();
|
||||
|
||||
expect($playlist)->not->toBeNull();
|
||||
expect($playlist->published_at)->not->toBeNull();
|
||||
|
||||
$orderedIds = $playlist->items()->pluck('display_version_id')->all();
|
||||
expect($orderedIds)->toBe([$moduleA->id, $moduleB->id]);
|
||||
});
|
||||
|
||||
it('is idempotent and does not duplicate published playlists on re-run', function () {
|
||||
$display = Display::factory()->create();
|
||||
$module = DisplayVersion::factory()->create();
|
||||
|
||||
DB::table('display_playlists')->where('display_id', $display->id)->delete();
|
||||
|
||||
DB::table('display_display_version')->insert([
|
||||
['display_id' => $display->id, 'display_version_id' => $module->id, 'sort_order' => 0],
|
||||
]);
|
||||
|
||||
$migration = require database_path('migrations/2026_05_11_113330_migrate_pivot_to_display_playlists.php');
|
||||
$migration->up();
|
||||
$migration->up();
|
||||
|
||||
$count = DisplayPlaylist::query()
|
||||
->where('display_id', $display->id)
|
||||
->where('status', DisplayPlaylist::STATUS_PUBLISHED)
|
||||
->count();
|
||||
|
||||
expect($count)->toBe(1);
|
||||
});
|
||||
|
||||
it('does not break the legacy versions() relation', function () {
|
||||
$display = Display::factory()->create();
|
||||
$module = DisplayVersion::factory()->create();
|
||||
|
||||
DB::table('display_display_version')->insert([
|
||||
['display_id' => $display->id, 'display_version_id' => $module->id, 'sort_order' => 0],
|
||||
]);
|
||||
|
||||
expect($display->fresh()->versions)->toHaveCount(1);
|
||||
it('drops the legacy display version pivot table', function () {
|
||||
expect(Schema::hasTable('display_display_version'))->toBeFalse();
|
||||
});
|
||||
|
||||
it('exposes a live playlist relation and a draft playlist relation on display', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue