create(); $user = User::factory()->create(['email' => $customer->email]); $customer->update(['user_id' => $user->id]); $instance = Instance::factory()->create([ 'customer_id' => $customer->id, 'host_id' => Host::factory()->active()->create()->id, 'plan' => 'team', 'status' => 'active', ]); $subscription = Subscription::factory()->plan('team')->create([ 'customer_id' => $customer->id, 'instance_id' => $instance->id, 'price_cents' => 0, 'granted_by' => Operator::factory()->create()->id, 'granted_at' => now(), 'catalogue_price_cents' => 17900, ]); return [$customer, $user, $subscription]; } it('shows the granted plan on the cloud dashboard without a price', function () { [, $user] = customerWithGrantedPlan(); Livewire::actingAs($user) ->test(Cloud::class) // The formatted amount, not the bare digits: "179" also matches an id, // and ids climb through a suite run because a rolled-back transaction // does not reset an auto-increment counter. That made this test pass // alone and fail in company. The line below is what a leak would // actually look like on the page. ->assertDontSee('179,00') ->assertDontSee('0 €') ->assertSee(__('billing.plan.team')); }); it('shows the granted plan on the billing page without a price', function () { [, $user] = customerWithGrantedPlan(); $card = Livewire::actingAs($user)->test(Billing::class)->viewData('current'); expect($card['granted'])->toBeTrue(); Livewire::actingAs($user) ->test(Billing::class) ->assertSee(__('billing.granted_plan')) ->assertDontSee('179,00'); }); it('shows a granted module without a price, but a booked one still with its price', function () { [$customer, $user, $subscription] = customerWithGrantedPlan(); SubscriptionAddon::query()->create([ 'subscription_id' => $subscription->id, 'addon_key' => 'priority_support', 'price_cents' => 0, 'currency' => 'EUR', 'quantity' => 1, 'booked_at' => now(), 'granted_by' => Operator::factory()->create()->id, 'granted_at' => now(), 'catalogue_price_cents' => 2900, ]); Livewire::actingAs($user) ->test(Billing::class) ->assertSee(__('billing.addon.priority_support.name')) ->assertSee(__('billing.granted_plan')); });