Files
portal/app/tests/Feature/Schedule/SupplierScheduleTest.php
T
Дмитрий d2ff39abc2 feat(billing-v2-c): SyncSupplierProjectsJob исключает frozen-проекты из заказа
Task 1.8 Спека C. Выделен публичный метод collectEligibleProjects() в
SyncSupplierProjectsJob; добавлены 2 фильтра:
— projects.preflight_blocked_at IS NULL (точечная блокировка проекта);
— tenants.frozen_by_balance_at IS NULL (пассивная заморозка тенанта).

NB: whereIn-subquery вместо whereHas — relation whereHas строит query через
default pgsql, ломая cross-connection Project::on('pgsql_supplier'); subquery
с FROM 'tenants' наследует connection родителя.

SupplierScheduleTest: ожидание '0 18 * * *' -> '5 18 * * *' (сдвиг Sync на
18:05 из Task 1.4 — preflight @18:00 успевает проставить флаги до формирования
заказа).

2 теста preflight-filter GREEN. Pre-existing fails в SyncSupplierProjectJobTest
(singular — другой класс) — не моя регрессия (Mockery/regions/limits).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 20:39:16 +03:00

40 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use App\Jobs\Supplier\RefreshSupplierSessionJob;
use App\Jobs\Supplier\SyncSupplierProjectsJob;
use Illuminate\Console\Scheduling\Schedule;
/*
* Крон supplier-sync переехал 20:30 → 18:00 МСК (Task 9, spec §4.7) —
* запас ~3 часа до портального дедлайна 21:00 на эскалацию ярус 2/3.
* Session refresh — на 15 мин раньше sync (17:45).
*/
it('SyncSupplierProjectsJob is scheduled at 18:05 MSK (after billing:preflight-sweep @18:00)', function (): void {
// Billing v2 Spec C §3.8: sync сдвинут с 18:00 на 18:05, чтобы
// billing:preflight-sweep (18:00) успел проставить frozen-флаги.
$schedule = app(Schedule::class);
$events = collect($schedule->events());
$sync = $events->first(fn ($e) => str_contains((string) $e->description, SyncSupplierProjectsJob::class)
|| str_contains((string) $e->command, 'SyncSupplierProjectsJob'));
expect($sync)->not->toBeNull();
expect($sync->expression)->toBe('5 18 * * *');
expect($sync->timezone)->toBe('Europe/Moscow');
});
it('Daily RefreshSupplierSessionJob is scheduled at 17:45 MSK', function (): void {
$schedule = app(Schedule::class);
$events = collect($schedule->events());
$daily = $events->first(fn ($e) => (str_contains((string) $e->description, RefreshSupplierSessionJob::class)
|| str_contains((string) $e->command, 'RefreshSupplierSessionJob'))
&& $e->expression === '45 17 * * *');
expect($daily)->not->toBeNull();
expect($daily->timezone)->toBe('Europe/Moscow');
});