removed all references to credits. now credits are completely replaced by addons.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Filament\Widgets\CreditAlertsWidget;
|
||||
use App\Filament\Widgets\RevenueTrendWidget;
|
||||
use App\Models\PurchaseHistory;
|
||||
use App\Models\Tenant;
|
||||
@@ -21,67 +20,17 @@ class AdminDashboardWidgetsTest extends TestCase
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
|
||||
public function test_credit_alerts_widget_cards_reflect_metrics(): void
|
||||
{
|
||||
$lowBalanceTenant = Tenant::factory()->create([
|
||||
'event_credits_balance' => 2,
|
||||
'is_active' => true,
|
||||
'subscription_expires_at' => now()->addMonths(2),
|
||||
]);
|
||||
|
||||
Tenant::factory()->create([
|
||||
'event_credits_balance' => 20,
|
||||
'is_active' => true,
|
||||
'subscription_expires_at' => now()->addMonths(1),
|
||||
]);
|
||||
|
||||
Tenant::factory()->create([
|
||||
'event_credits_balance' => 1,
|
||||
'is_active' => false,
|
||||
'subscription_expires_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
PurchaseHistory::create([
|
||||
'id' => 'ph-1',
|
||||
'tenant_id' => $lowBalanceTenant->id,
|
||||
'package_id' => 'starter_pack',
|
||||
'credits_added' => 5,
|
||||
'price' => 149.90,
|
||||
'currency' => 'EUR',
|
||||
'platform' => 'web',
|
||||
'transaction_id' => 'txn-1',
|
||||
'purchased_at' => now()->startOfMonth()->addDay(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$widget = new CreditAlertsWidget();
|
||||
|
||||
$cards = $this->invokeProtectedMethod($widget, 'getCards');
|
||||
|
||||
$this->assertCount(3, $cards);
|
||||
$this->assertSame(
|
||||
__('admin.widgets.credit_alerts.low_balance_label'),
|
||||
$cards[0]->getLabel()
|
||||
);
|
||||
$this->assertSame(1, $cards[0]->getValue());
|
||||
$this->assertSame(
|
||||
2,
|
||||
$cards[2]->getValue()
|
||||
);
|
||||
$this->assertStringContainsString('149.9', (string) $cards[1]->getValue());
|
||||
}
|
||||
|
||||
public function test_revenue_trend_widget_compiles_monthly_totals(): void
|
||||
{
|
||||
Carbon::setTestNow(Carbon::create(2025, 10, 20, 12));
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$packagePro = \App\Models\Package::factory()->create(['name' => 'Pro Pack']);
|
||||
$packageStarter = \App\Models\Package::factory()->create(['name' => 'Starter Pack']);
|
||||
|
||||
PurchaseHistory::create([
|
||||
'id' => 'cur-1',
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => 'pro_pack',
|
||||
'credits_added' => 10,
|
||||
'package_id' => $packagePro->id,
|
||||
'price' => 299.99,
|
||||
'currency' => 'EUR',
|
||||
'platform' => 'web',
|
||||
@@ -91,10 +40,8 @@ class AdminDashboardWidgetsTest extends TestCase
|
||||
]);
|
||||
|
||||
PurchaseHistory::create([
|
||||
'id' => 'prev-1',
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => 'starter_pack',
|
||||
'credits_added' => 5,
|
||||
'package_id' => $packageStarter->id,
|
||||
'price' => 149.90,
|
||||
'currency' => 'EUR',
|
||||
'platform' => 'web',
|
||||
|
||||
Reference in New Issue
Block a user