Add tier feature design spec, annual billing, fuel type normalization, and admin subscription management
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

- Add comprehensive tier feature matrix spec defining Free/Basic/Plus/Pro capabilities across recommendations, predictions, history, logs, tools, and family sharing
- Add `stripe_price_id_annual` column to plans table and rename existing column to `stripe_price_id_monthly`
- Normalize legacy fuel type aliases (petrol→e10, diesel→b7_standard) in users table
- Implement BillingController with checkout, portal, success/cancel routes supporting monthly/annual cadence
- Add admin subscription assignment in Filament user edit page with admin-granted subscription support
- Add DowngradeUserOnSubscriptionDeleted listener to disable WhatsApp/SMS preferences on subscription cancellation
- Add MissedNotificationsOverview widget to Filament user detail page
- Add PollFuelPricesTest covering auto-refresh scenarios
- Add PriceReliability enum with reliability classification based on price age
- Add fuelTypes.js constants file exporting FUEL_TYPES from window global
This commit is contained in:
Ovidiu U
2026-04-20 14:13:03 +01:00
parent 5acb99c9e3
commit d29f3e6487
12 changed files with 680 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function (): void {
config([
'services.stripe.prices.basic.monthly' => 'price_test_basic_monthly',
'services.stripe.prices.basic.annual' => 'price_test_basic_annual',
'services.stripe.prices.plus.monthly' => 'price_test_plus_monthly',
'services.stripe.prices.plus.annual' => 'price_test_plus_annual',
'services.stripe.prices.pro.monthly' => null,
'services.stripe.prices.pro.annual' => null,
]);
});
it('requires authentication for the checkout route', function (): void {
$this->get('/billing/checkout/basic/monthly')->assertRedirect('/login');
});
it('requires authentication for the portal route', function (): void {
$this->get('/billing/portal')->assertRedirect('/login');
});
it('rejects an unknown tier', function (): void {
$this->actingAs(User::factory()->create())
->get('/billing/checkout/titanium/monthly')
->assertNotFound();
});
it('rejects an unknown cadence', function (): void {
$this->actingAs(User::factory()->create())
->get('/billing/checkout/basic/weekly')
->assertNotFound();
});
it('returns 404 when no price is configured for the tier + cadence', function (): void {
$this->actingAs(User::factory()->create())
->get('/billing/checkout/pro/monthly')
->assertNotFound();
});
it('redirects the success route to the dashboard', function (): void {
$this->actingAs(User::factory()->create())
->get('/billing/success')
->assertRedirect(route('dashboard'))
->assertSessionHas('status', 'subscription_started');
});
it('redirects the cancel route to the dashboard', function (): void {
$this->actingAs(User::factory()->create())
->get('/billing/cancel')
->assertRedirect(route('dashboard'))
->assertSessionHas('status', 'subscription_cancelled');
});