Tighten Pro alert caps and move custom badges to Enterprise.
Deploy Ladill Frontdesk / deploy (push) Has been cancelled

Pro includes 5,000 email and 5,000 SMS host alerts per month with hard
monthly caps; Enterprise is unlimited. Custom badge templates are
Enterprise-only, and plan benefit copy matches the new limits.
This commit is contained in:
isaacclad
2026-07-16 08:37:06 +00:00
parent 4ce45f4989
commit b6f229ab9a
12 changed files with 298 additions and 29 deletions
@@ -242,7 +242,7 @@ class FrontdeskNotificationBillingTest extends TestCase
->assertSee('Upgrade to Pro');
}
public function test_pro_plan_emails_record_usage_without_wallet_debit(): void
public function test_pro_plan_emails_within_allowance_skip_wallet_debit(): void
{
Http::fake([
'billing.test/can-afford*' => Http::response(['affordable' => true]),
@@ -260,7 +260,7 @@ class FrontdeskNotificationBillingTest extends TestCase
NotificationUsage::create([
'organization_id' => $this->organization->id,
'period' => now()->format('Y-m'),
'email_count' => 10_000,
'email_count' => 4_999,
]);
$host = Host::create([
@@ -284,10 +284,96 @@ class FrontdeskNotificationBillingTest extends TestCase
Http::assertNotSent(fn ($request) => str_contains($request->url(), '/debit'));
$usage = NotificationUsage::where('organization_id', $this->organization->id)->first();
$this->assertSame(10_001, $usage->email_count);
$this->assertSame(5_000, $usage->email_count);
$this->assertSame(0, $usage->email_charged_minor);
}
public function test_pro_plan_stops_email_after_monthly_allowance(): void
{
Http::fake([
'billing.test/can-afford*' => Http::response(['affordable' => true]),
'billing.test/debit' => Http::response(['ok' => true]),
'*/api/smtp/send' => Http::response(['success' => true]),
]);
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
]),
]);
NotificationUsage::create([
'organization_id' => $this->organization->id,
'period' => now()->format('Y-m'),
'email_count' => 5_000,
]);
$host = Host::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Capped Host',
'email' => 'capped@example.com',
'is_available' => true,
]);
$this->actingAs($this->owner)
->post(route('frontdesk.visits.store'), [
'full_name' => 'Capped Guest',
'host_id' => $host->id,
'visitor_type' => 'visitor',
'policies_accepted' => '1',
])
->assertRedirect();
Http::assertNotSent(fn ($request) => str_contains($request->url(), '/api/smtp/send'));
$usage = NotificationUsage::where('organization_id', $this->organization->id)->first();
$this->assertSame(5_000, $usage->email_count);
}
public function test_enterprise_plan_emails_are_unlimited(): void
{
Http::fake([
'billing.test/can-afford*' => Http::response(['affordable' => true]),
'billing.test/debit' => Http::response(['ok' => true]),
'*/api/smtp/send' => Http::response(['success' => true]),
]);
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'plan' => 'enterprise',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
]),
]);
NotificationUsage::create([
'organization_id' => $this->organization->id,
'period' => now()->format('Y-m'),
'email_count' => 50_000,
]);
$host = Host::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Ent Host',
'email' => 'ent@example.com',
'is_available' => true,
]);
$this->actingAs($this->owner)
->post(route('frontdesk.visits.store'), [
'full_name' => 'Ent Guest',
'host_id' => $host->id,
'visitor_type' => 'visitor',
'policies_accepted' => '1',
])
->assertRedirect();
Http::assertSent(fn ($request) => str_contains($request->url(), '/api/smtp/send'));
Http::assertNotSent(fn ($request) => str_contains($request->url(), '/debit'));
}
public function test_linked_user_still_gets_in_app_notification(): void
{
Notification::fake();
+32 -1
View File
@@ -61,8 +61,15 @@ class FrontdeskPhase8Test extends TestCase
]);
}
public function test_badge_template_settings_can_be_updated(): void
public function test_badge_template_settings_can_be_updated_on_enterprise(): void
{
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'plan' => 'enterprise',
'plan_expires_at' => now()->addYear()->toIso8601String(),
]),
]);
$this->actingAs($this->user)
->put(route('frontdesk.settings.badge.update'), [
'show_photo' => '1',
@@ -80,6 +87,30 @@ class FrontdeskPhase8Test extends TestCase
$this->assertFalse($settings['badge_template']['show_company']);
}
public function test_badge_template_requires_enterprise(): void
{
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
]),
]);
$this->actingAs($this->user)
->get(route('frontdesk.settings.badge'))
->assertOk()
->assertSee('Upgrade your plan');
$this->actingAs($this->user)
->put(route('frontdesk.settings.badge.update'), [
'show_photo' => '1',
'show_qr' => '1',
'primary_color' => '#00ff00',
])
->assertRedirect(route('frontdesk.pro.index'))
->assertSessionHas('error');
}
public function test_check_in_stores_photo_from_base64(): void
{
$png = 'data:image/png;base64,'.base64_encode(UploadedFile::fake()->image('photo.png')->getContent());