Add Queue Enterprise billing and visible upgrade CTAs for all roles.
Deploy Ladill Queue / deploy (push) Successful in 1m32s
Deploy Ladill Queue / deploy (push) Successful in 1m32s
Enterprise charges per active branch (GHS 299+) with wallet subscribe/renew; sidebar and dashboard upsell no longer gated behind settings.view. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Services\Qms\OrganizationResolver;
|
||||
@@ -40,17 +42,50 @@ class QmsProTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_pro_page_renders_for_free_organization(): void
|
||||
public function test_pro_page_renders_three_tier_pricing(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('qms.pro.index'))
|
||||
->assertOk()
|
||||
->assertSee('Ladill Queue Pro')
|
||||
->assertSee('Choose your Queue plan')
|
||||
->assertSee('GHS 99')
|
||||
->assertSee('GHS 299')
|
||||
->assertSee('Upgrade to Pro')
|
||||
->assertSee('Enterprise');
|
||||
}
|
||||
|
||||
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('qms.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Upgrade to Pro');
|
||||
}
|
||||
|
||||
public function test_subscribe_upgrades_organization(): void
|
||||
public function test_sidebar_shows_upgrade_for_operator_without_settings_access(): void
|
||||
{
|
||||
$operator = User::create([
|
||||
'public_id' => 'queue-operator-001',
|
||||
'name' => 'Operator',
|
||||
'email' => 'operator@example.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
Member::create([
|
||||
'owner_ref' => $this->organization->owner_ref,
|
||||
'organization_id' => $this->organization->id,
|
||||
'user_ref' => $operator->public_id,
|
||||
'role' => 'queue_operator',
|
||||
]);
|
||||
|
||||
$this->actingAs($operator)
|
||||
->get(route('qms.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Upgrade to Pro')
|
||||
->assertDontSee(route('qms.settings.edit'));
|
||||
}
|
||||
|
||||
public function test_subscribe_upgrades_organization_to_pro(): void
|
||||
{
|
||||
Http::fake([
|
||||
'billing.test/can-afford*' => Http::response(['affordable' => true]),
|
||||
@@ -65,6 +100,35 @@ class QmsProTest extends TestCase
|
||||
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
|
||||
}
|
||||
|
||||
public function test_subscribe_enterprise_requires_multiple_branches(): 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-enterprise'))
|
||||
->assertRedirect(route('qms.pro.index'))
|
||||
->assertSessionHas('error');
|
||||
|
||||
Branch::create([
|
||||
'owner_ref' => $this->organization->owner_ref,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Second',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('qms.pro.subscribe-enterprise'))
|
||||
->assertRedirect(route('qms.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('enterprise', $settings['plan']);
|
||||
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||
}
|
||||
|
||||
public function test_pro_renew_extends_subscription_when_wallet_charges(): void
|
||||
{
|
||||
$this->organization->update([
|
||||
@@ -85,4 +149,37 @@ class QmsProTest extends TestCase
|
||||
$this->assertSame('pro', $settings['plan']);
|
||||
$this->assertTrue(now()->parse($settings['plan_expires_at'])->isFuture());
|
||||
}
|
||||
|
||||
public function test_enterprise_renew_charges_per_active_branch(): void
|
||||
{
|
||||
Branch::create([
|
||||
'owner_ref' => $this->organization->owner_ref,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Second',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->organization->update([
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'enterprise',
|
||||
'auto_renew' => true,
|
||||
'enterprise_billed_branches' => 2,
|
||||
'plan_expires_at' => now()->subDay()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'billing.test/debit' => function ($request) {
|
||||
$this->assertSame(59800, (int) $request['amount_minor']);
|
||||
|
||||
return Http::response(['ok' => true]);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->artisan('qms:pro-renew')->assertSuccessful();
|
||||
|
||||
$settings = $this->organization->fresh()->settings;
|
||||
$this->assertSame('enterprise', $settings['plan']);
|
||||
$this->assertSame(2, $settings['enterprise_billed_branches']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user