artisan('db:seed', ['--class' => 'PlanSeeder']); $this->actingAs(User::factory()->create(['is_admin' => true])); }); // ─── ListPlans ──────────────────────────────────────────────────────────────── it('lists all four plans', function (): void { Livewire::test(ListPlans::class) ->assertCanSeeTableRecords(Plan::all()); }); it('has no create button on the list page', function (): void { Livewire::test(ListPlans::class) ->assertActionDoesNotExist('create'); }); // ─── EditPlan — no delete ───────────────────────────────────────────────────── it('has no delete action on the edit page', function (): void { $plan = Plan::where('name', 'basic')->first(); Livewire::test(EditPlan::class, ['record' => $plan->id]) ->assertActionDoesNotExist(DeleteAction::class); }); // ─── EditPlan — saves features correctly ───────────────────────────────────── it('saves email frequency on edit', function (): void { $plan = Plan::where('name', 'free')->first(); Livewire::test(EditPlan::class, ['record' => $plan->id]) ->fillForm([ 'features.email.frequency' => 'daily', ]) ->call('save') ->assertHasNoFormErrors(); expect($plan->fresh()->features['email']['frequency'])->toBe('daily'); }); it('saves sms daily limit on edit', function (): void { $plan = Plan::where('name', 'plus')->first(); Livewire::test(EditPlan::class, ['record' => $plan->id]) ->fillForm([ 'features.sms.daily_limit' => 3, ]) ->call('save') ->assertHasNoFormErrors(); expect($plan->fresh()->features['sms']['daily_limit'])->toBe(3); }); it('saves null fuel type max for pro (unlimited)', function (): void { $plan = Plan::where('name', 'pro')->first(); Livewire::test(EditPlan::class, ['record' => $plan->id]) ->fillForm([ 'features.fuel_types.max' => null, ]) ->call('save') ->assertHasNoFormErrors(); expect($plan->fresh()->features['fuel_types']['max'])->toBeNull(); });