From a72d93b0ccfcd450935d3179f9d3108839615601 Mon Sep 17 00:00:00 2001 From: roble Date: Mon, 30 Nov 2026 16:52:31 +0000 Subject: [PATCH] fix: the product factory's features are the bullets the admin edits Filament 5.12.2 validates every non-numeric TextInput as a string, so the factory's numbers keyed by name failed the features repeater on save in 13 admin tests. Real products already store a list of strings. Co-Authored-By: Claude Opus 5.5 --- database/factories/ProductFactory.php | 9 +++++---- tests/Feature/ProductFactoryTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index 98edc64..453dfcd 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -43,11 +43,12 @@ public function definition(): array */ protected function generateFeatures(): array { + // The admin's shape: one bullet per line of the pricing card. return [ - 'storage_gb' => fake()->randomElement([5, 10, 50, 100, 500, 1000]), - 'max_users' => fake()->randomElement([1, 5, 10, 25, 50, 100]), - 'support' => fake()->randomElement(['community', 'email', 'priority', '24/7']), - 'api_calls_per_month' => fake()->randomElement([1000, 10000, 100000, 'unlimited']), + fake()->randomElement([5, 10, 50, 100, 500, 1000]).' GB storage', + 'Up to '.fake()->randomElement([1, 5, 10, 25, 50, 100]).' users', + fake()->randomElement(['Community', 'Email', 'Priority', '24/7']).' support', + fake()->randomElement(['1k', '10k', '100k', 'Unlimited']).' API calls / month', ]; } diff --git a/tests/Feature/ProductFactoryTest.php b/tests/Feature/ProductFactoryTest.php index 38cd06a..01b92e9 100644 --- a/tests/Feature/ProductFactoryTest.php +++ b/tests/Feature/ProductFactoryTest.php @@ -18,4 +18,14 @@ public function test_many_products_get_their_own_slug_and_sku(): void $this->assertSame(500, Product::query()->distinct()->count('slug')); $this->assertSame(500, Product::query()->distinct()->count('sku')); } + + /** The admin edits `features` as a list of bullets: Filament 5.12.2 refuses a factory row of numbers keyed by name. */ + public function test_features_are_the_bullets_the_admin_form_edits(): void + { + $features = Product::factory()->make()->features; + + $this->assertIsList($features); + $this->assertNotEmpty($features); + $this->assertContainsOnlyString($features); + } }