feat(colors): update admin website colors in migration and seeder, add migration test

This commit is contained in:
2026-10-01 13:57:59 -03:00
parent 664441cf5c
commit b56b139631
3 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
{
DB::table('admin_website_types')
->where('codigo', 'shopit')
->update([
'secondary_color' => '#ADADAD',
'danger_color' => '#FF8888',
'success_color' => '#58B341',
'updated_at' => now(),
]);
}
public function down(): void
{
// Presentation settings are operational data; preserve them on rollback.
}
};

View File

@@ -49,6 +49,9 @@ class WebsiteTypeSeeder extends Seeder
'site_title' => 'ShopIt',
...self::PRESENTATION,
'primary_color' => '#2FD3AC',
'secondary_color' => '#ADADAD',
'danger_color' => '#FF8888',
'success_color' => '#58B341',
'site_logo' => $this->shopItLogo(),
'footer_logo' => $this->shopItFooterLogo(),
'favicon' => $this->shopItFavicon(),

View File

@@ -0,0 +1,49 @@
<?php
namespace Tests\Feature\Migrations;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Tests\TestCase;
class UpdateShopitAdminColorsTest extends TestCase
{
public function test_updates_only_shopit_admin_colors_and_preserves_them_on_rollback(): void
{
Schema::create('admin_website_types', function (Blueprint $table): void {
$table->string('codigo')->primary();
$table->string('primary_color');
$table->string('secondary_color');
$table->string('danger_color');
$table->string('success_color');
$table->timestamps();
});
foreach (['shopit', 'onticket'] as $code) {
DB::table('admin_website_types')->insert([
'codigo' => $code,
'primary_color' => '#2FD3AC',
'secondary_color' => '#777777',
'danger_color' => '#E04A4A',
'success_color' => '#81BC73',
]);
}
$migration = require database_path('migrations/2026_10_01_000100_update_shopit_admin_secondary_and_danger_colors.php');
$migration->up();
$shopit = DB::table('admin_website_types')->where('codigo', 'shopit')->first();
$this->assertSame('#ADADAD', $shopit->secondary_color);
$this->assertSame('#FF8888', $shopit->danger_color);
$this->assertSame('#58B341', $shopit->success_color);
$this->assertSame('#2FD3AC', $shopit->primary_color);
$onticket = DB::table('admin_website_types')->where('codigo', 'onticket')->first();
$this->assertSame('#777777', $onticket->secondary_color);
$this->assertSame('#E04A4A', $onticket->danger_color);
$this->assertSame('#81BC73', $onticket->success_color);
$migration->down();
$this->assertSame('#ADADAD', DB::table('admin_website_types')->where('codigo', 'shopit')->value('secondary_color'));
$this->assertSame('#FF8888', DB::table('admin_website_types')->where('codigo', 'shopit')->value('danger_color'));
$this->assertSame('#58B341', DB::table('admin_website_types')->where('codigo', 'shopit')->value('success_color'));
}
}