feat(admin): add Filament resources for the forecasting stack
Adds three resources under a new "Forecasting" navigation group: a full-CRUD WatchedEventResource for the Layer 5 volatility detector, plus read-only WeeklyForecastResource and BacktestResource so the ridge model output and its calibration can be inspected without SQL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
43
tests/Feature/Admin/WeeklyForecastResourceTest.php
Normal file
43
tests/Feature/Admin/WeeklyForecastResourceTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Resources\WeeklyForecasts\Pages\ListWeeklyForecasts;
|
||||
use App\Filament\Resources\WeeklyForecasts\Pages\ViewWeeklyForecast;
|
||||
use App\Filament\Resources\WeeklyForecasts\WeeklyForecastResource;
|
||||
use App\Models\User;
|
||||
use App\Models\WeeklyForecast;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->admin = User::factory()->admin()->create();
|
||||
$this->actingAs($this->admin);
|
||||
});
|
||||
|
||||
it('lists weekly forecasts sorted by forecast_for desc', function () {
|
||||
$older = WeeklyForecast::factory()->create(['forecast_for' => '2026-04-06']);
|
||||
$newer = WeeklyForecast::factory()->create(['forecast_for' => '2026-05-04']);
|
||||
|
||||
Livewire::test(ListWeeklyForecasts::class)
|
||||
->assertOk()
|
||||
->assertCanSeeTableRecords([$newer, $older], inOrder: true);
|
||||
});
|
||||
|
||||
it('disables create and edit', function () {
|
||||
$forecast = WeeklyForecast::factory()->create();
|
||||
|
||||
expect(WeeklyForecastResource::canCreate())->toBeFalse();
|
||||
expect(WeeklyForecastResource::canEdit($forecast))->toBeFalse();
|
||||
expect(WeeklyForecastResource::canDelete($forecast))->toBeFalse();
|
||||
});
|
||||
|
||||
it('renders the view page for a forecast', function () {
|
||||
$forecast = WeeklyForecast::factory()->create([
|
||||
'reasoning' => 'Brent stabilising; supermarket cycle entering bottom.',
|
||||
]);
|
||||
|
||||
Livewire::test(ViewWeeklyForecast::class, ['record' => $forecast->id])
|
||||
->assertOk()
|
||||
->assertSee('Brent stabilising; supermarket cycle entering bottom.');
|
||||
});
|
||||
Reference in New Issue
Block a user