2026-06-27 14:32:31 +03:00
|
|
|
<?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'],
|
2026-06-27 18:57:35 +03:00
|
|
|
'total_orders',
|
|
|
|
|
'total_limit',
|
2026-06-27 14:32:31 +03:00
|
|
|
'groups',
|
|
|
|
|
]);
|
|
|
|
|
expect($res->json('light'))->toBeIn(['green', 'red']);
|
|
|
|
|
});
|