- Wired the checkout wizard for Google “comfort login”: added Socialite controller + dependency, new Google env

hooks in config/services.php/.env.example, and updated wizard steps/controllers to store session payloads,
attach packages, and surface localized success/error states.
- Retooled payment handling for both Stripe and PayPal, adding richer status management in CheckoutController/
PayPalController, fallback flows in the wizard’s PaymentStep.tsx, and fresh feature tests for intent
creation, webhooks, and the wizard CTA.
- Introduced a consent-aware Matomo analytics stack: new consent context, cookie-banner UI, useAnalytics/
useCtaExperiment hooks, and MatomoTracker component, then instrumented marketing pages (Home, Packages,
Checkout) with localized copy and experiment tracking.
- Polished package presentation across marketing UIs by centralizing formatting in PresentsPackages, surfacing
localized description tables/placeholders, tuning badges/layouts, and syncing guest/marketing translations.
- Expanded docs & reference material (docs/prp/*, TODOs, public gallery overview) and added a Playwright smoke
test for the hero CTA while reconciling outstanding checklist items.
This commit is contained in:
Codex Agent
2025-10-19 11:41:03 +02:00
parent ae9b9160ac
commit a949c8d3af
113 changed files with 5169 additions and 712 deletions

View File

@@ -0,0 +1,136 @@
<?php
namespace Tests\Unit;
use App\Filament\Widgets\CreditAlertsWidget;
use App\Filament\Widgets\RevenueTrendWidget;
use App\Models\PurchaseHistory;
use App\Models\Tenant;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use ReflectionClass;
use Tests\TestCase;
class AdminDashboardWidgetsTest extends TestCase
{
use RefreshDatabase;
protected function tearDown(): void
{
parent::tearDown();
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();
PurchaseHistory::create([
'id' => 'cur-1',
'tenant_id' => $tenant->id,
'package_id' => 'pro_pack',
'credits_added' => 10,
'price' => 299.99,
'currency' => 'EUR',
'platform' => 'web',
'transaction_id' => 'txn-cur',
'purchased_at' => now()->copy()->startOfMonth()->addDays(2),
'created_at' => now(),
]);
PurchaseHistory::create([
'id' => 'prev-1',
'tenant_id' => $tenant->id,
'package_id' => 'starter_pack',
'credits_added' => 5,
'price' => 149.90,
'currency' => 'EUR',
'platform' => 'web',
'transaction_id' => 'txn-prev',
'purchased_at' => now()->copy()->subMonth()->startOfMonth()->addDays(4),
'created_at' => now()->subMonth(),
]);
$widget = new RevenueTrendWidget();
$data = $this->invokeProtectedMethod($widget, 'getData');
$this->assertArrayHasKey('datasets', $data);
$this->assertArrayHasKey('labels', $data);
$this->assertCount(12, $data['labels']);
$this->assertSame(12, count($data['datasets'][0]['data']));
$lastValue = end($data['datasets'][0]['data']);
$prevValue = $data['datasets'][0]['data'][count($data['datasets'][0]['data']) - 2];
$this->assertEquals(299.99, $lastValue);
$this->assertEquals(149.90, $prevValue);
}
/**
* @template T
*
* @param object $object
* @param string $method
* @return mixed
*/
private function invokeProtectedMethod(object $object, string $method)
{
$reflection = new ReflectionClass($object);
$reflectedMethod = $reflection->getMethod($method);
$reflectedMethod->setAccessible(true);
return $reflectedMethod->invoke($object);
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace Tests\Unit;
use App\Models\Package;
use App\Models\Tenant;
use App\Models\TenantPackage;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class TenantCreditTest extends TestCase
{
use RefreshDatabase;
public function test_consume_event_allowance_uses_reseller_package(): void
{
$package = Package::factory()
->reseller()
->create([
'max_events_per_year' => 5,
]);
$tenant = Tenant::factory()->create([
'event_credits_balance' => 0,
]);
TenantPackage::factory()->for($tenant)->for($package)->create([
'used_events' => 1,
'active' => true,
]);
$this->assertTrue($tenant->consumeEventAllowance());
$updatedPackage = $tenant->getActiveResellerPackage();
$this->assertNotNull($updatedPackage);
$this->assertSame(2, $updatedPackage->used_events);
}
public function test_consume_event_allowance_decrements_credits_when_no_package(): void
{
$tenant = Tenant::factory()->create([
'event_credits_balance' => 2,
]);
$this->assertTrue($tenant->consumeEventAllowance(1, 'event.create', 'Event #1 created'));
$tenant->refresh();
$this->assertSame(1, $tenant->event_credits_balance);
$this->assertDatabaseHas('event_credits_ledger', [
'tenant_id' => $tenant->id,
'delta' => -1,
'reason' => 'event.create',
'note' => 'Event #1 created',
]);
}
public function test_consume_event_allowance_returns_false_without_package_or_credits(): void
{
$tenant = Tenant::factory()->create([
'event_credits_balance' => 0,
]);
$this->assertFalse($tenant->consumeEventAllowance());
$this->assertDatabaseCount('event_credits_ledger', 0);
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace Tests\Unit;
use App\Models\Tenant;
use App\Models\User;
use App\Policies\TenantPolicy;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class TenantPolicyTest extends TestCase
{
use RefreshDatabase;
protected TenantPolicy $policy;
protected function setUp(): void
{
parent::setUp();
$this->policy = new TenantPolicy();
}
public function test_super_admin_can_adjust_credits(): void
{
$tenant = Tenant::factory()->create();
$user = User::factory()->create([
'role' => 'super_admin',
]);
$this->assertTrue($this->policy->adjustCredits($user, $tenant));
}
public function test_tenant_admin_cannot_adjust_credits(): void
{
$tenant = Tenant::factory()->create();
$user = User::factory()->create([
'role' => 'tenant_admin',
]);
$user->forceFill(['tenant_id' => $tenant->id])->save();
$this->assertFalse($this->policy->adjustCredits($user, $tenant));
}
public function test_tenant_admin_can_view_own_tenant(): void
{
$tenant = Tenant::factory()->create();
$user = User::factory()->create([
'role' => 'tenant_admin',
]);
$user->forceFill(['tenant_id' => $tenant->id])->save();
$this->assertTrue($this->policy->view($user, $tenant));
}
public function test_tenant_admin_cannot_view_other_tenant(): void
{
$tenant = Tenant::factory()->create();
$otherTenant = Tenant::factory()->create();
$user = User::factory()->create([
'role' => 'tenant_admin',
]);
$user->forceFill(['tenant_id' => $tenant->id])->save();
$this->assertFalse($this->policy->view($user, $otherTenant));
}
}