Files
portal/app/tests/Feature/Admin/AdminDashboardSupplyTest.php
T

33 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
uses(DatabaseTransactions::class);
it('GET /api/admin/dashboard/supply возвращает группы и итоги', function () {
// supplier_projects не партиционирован — сеем напрямую. project_routing_snapshots
// партиционирована по дате → в тесте не сеем (контракт ответа проверяем; формула
// покрыта unit-тестом SupplyReconciliation).
DB::table('supplier_projects')->insert([
'platform' => 'B1', 'signal_type' => 'site', 'unique_key' => 'demo-x.ru',
'current_limit' => 50, 'sync_status' => 'ok',
'created_at' => now(), 'updated_at' => now(),
]);
$res = $this->getJson('/api/admin/dashboard/supply');
$res->assertOk();
$res->assertJsonStructure([
'snapshot_date',
'light',
'totals' => ['demand', 'formula', 'ordered', 'mismatches'],
'total_orders',
'total_limit',
'groups',
]);
expect($res->json('light'))->toBeIn(['green', 'red']);
});