Set Pro to GHS 100/mo and add sidebar Go Pro UI like Accounting.
Deploy Ladill Frontdesk / deploy (push) Successful in 33s
Deploy Ladill Frontdesk / deploy (push) Successful in 33s
Adds a dedicated Pro page with wallet upgrade, gradient Upgrade to Pro button in the sidebar footer, and view composer for plan status. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
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 Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FrontdeskProTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $owner;
|
||||
|
||||
protected Organization $organization;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(EnsurePlatformSession::class);
|
||||
config(['billing.api_url' => 'https://billing.test']);
|
||||
|
||||
$this->owner = User::create([
|
||||
'public_id' => 'pro-owner-001',
|
||||
'name' => 'Owner',
|
||||
'email' => 'owner@example.com',
|
||||
]);
|
||||
|
||||
$this->organization = Organization::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'name' => 'Pro Org',
|
||||
'slug' => 'pro-org',
|
||||
'settings' => ['onboarded' => true, 'badge_expiry_hours' => 8],
|
||||
]);
|
||||
|
||||
Member::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'user_ref' => $this->owner->public_id,
|
||||
'role' => 'org_admin',
|
||||
]);
|
||||
|
||||
Branch::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'HQ',
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_pro_page_renders_for_free_organization(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('frontdesk.pro.index'))
|
||||
->assertOk()
|
||||
->assertSee('Ladill Frontdesk Pro')
|
||||
->assertSee('GHS 100')
|
||||
->assertSee('Upgrade to Pro');
|
||||
}
|
||||
|
||||
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
|
||||
{
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('frontdesk.dashboard'))
|
||||
->assertOk()
|
||||
->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('frontdesk.pro.subscribe'))
|
||||
->assertRedirect(route('frontdesk.pro.index'))
|
||||
->assertSessionHas('success');
|
||||
|
||||
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
|
||||
}
|
||||
|
||||
public function test_pro_sidebar_shows_active_label_after_upgrade(): void
|
||||
{
|
||||
$this->organization->update([
|
||||
'settings' => array_merge($this->organization->settings ?? [], [
|
||||
'plan' => 'pro',
|
||||
'plan_expires_at' => now()->addMonth()->toIso8601String(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('frontdesk.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Frontdesk Pro')
|
||||
->assertDontSee('Upgrade to Pro');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user