withoutMiddleware(EnsurePlatformSession::class); config(['billing.api_url' => 'https://billing.test']); $this->owner = User::create([ 'public_id' => 'queue-owner-001', 'name' => 'Owner', 'email' => 'owner@example.com', 'password' => bcrypt('password'), ]); $this->organization = app(OrganizationResolver::class)->completeOnboarding($this->owner, [ 'organization_name' => 'Queue Org', 'industry' => 'retail', 'appointment_mode' => 'hybrid', 'branch_name' => 'Main', 'timezone' => 'UTC', ]); } public function test_pro_page_renders_for_free_organization(): void { $this->actingAs($this->owner) ->get(route('qms.pro.index')) ->assertOk() ->assertSee('Ladill Queue Pro') ->assertSee('GHS 99') ->assertSee('Upgrade to Pro'); } public function test_subscribe_upgrades_organization(): void { Http::fake([ 'billing.test/can-afford*' => Http::response(['affordable' => true]), 'billing.test/debit' => Http::response(['ok' => true]), ]); $this->actingAs($this->owner) ->post(route('qms.pro.subscribe')) ->assertRedirect(route('qms.pro.index')) ->assertSessionHas('success'); $this->assertSame('pro', $this->organization->fresh()->settings['plan']); } public function test_pro_renew_extends_subscription_when_wallet_charges(): void { $this->organization->update([ 'settings' => array_merge($this->organization->settings ?? [], [ 'plan' => 'pro', 'auto_renew' => true, 'plan_expires_at' => now()->subDay()->toIso8601String(), ]), ]); Http::fake([ 'billing.test/debit' => Http::response(['ok' => true]), ]); $this->artisan('qms:pro-renew')->assertSuccessful(); $settings = $this->organization->fresh()->settings; $this->assertSame('pro', $settings['plan']); $this->assertTrue(now()->parse($settings['plan_expires_at'])->isFuture()); } }