Files
portal/app/tests/Feature/Admin/AdminSuppliersControllerTest.php
T
Дмитрий 88ace4e3d9
Accessibility (Pa11y live) / a11y (push) Has been cancelled
test: дозакрытие оздоровления — protekateli pd-аудита, видимость supplier, новый флоу регистрации
Снижение остатка 19 to 5. Всё тест-сторона:
- PdErasureServiceTest + AdminPdSubjectRequestsControllerTest: SharesSupplierPdo —
  перестали коммитить pd_processing_log через pgsql_supplier, что ломало
  глобальный audit:verify-chains (6 падений) и амплифицировало PhoneRegionSmoke.
- ReportFileDeletePdLogTest: SharesSupplierPdo — cron reports:cleanup-expired
  теперь видит незакоммиченные job'ы теста.
- AdminSuppliersControllerTest: устойчивый ассерт (с фазы 3 в suppliers есть direct).
- AuthLogCoverageTest/AuthFlowIntegrationTest: новый флоу самозаписи G1/SP1 —
  register_success пишется после confirm-email; добавлен шаг подтверждения.
- ImpersonationTest end: verify (G7-B) ставит маркер impersonation → admin-зона
  закрыта by design; помечаем токен used напрямую вместо session-takeover.
- CleanupInactiveSupplierProjectsJobTest: phase A читает pivot project_supplier_links —
  добавлена привязка linkProjectToSupplier (раньше был только legacy FK).
- Pint-нормализация uses() FQN to import в ранее тронутых файлах.

Остаток 5 (НЕ слепой патч): webhook B-префикс ×2 (решение владельца), advisory-lock
audit-цепочки (возможный дрейф схемы, флажок), SupplierConnection WARN#2 (cap-3,
поведенческое), SupplierPortalClientTest (пре-существующий, не от этих правок).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 08:19:53 +03:00

50 lines
1.8 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\Models\Supplier;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
uses(DatabaseTransactions::class);
it('GET /api/admin/suppliers returns B1/B2/B3 suppliers', function () {
// NB: с фазы 3 в suppliers есть и псевдо-поставщик 'direct' (DIRECT-лиды,
// миграция 2026_05_25_120100), поэтому проверяем наличие закупочных b1/b2/b3,
// а не строгий счёт. Если 'direct' не должен быть в этом списке — это правка
// контроллера (фильтр), решение владельца, не тест.
$response = $this->getJson('/api/admin/suppliers');
$response->assertOk();
$codes = collect($response->json('data'))->pluck('code')->all();
expect($codes)->toContain('b1', 'b2', 'b3');
});
it('PATCH updates cost_rub for supplier', function () {
$b1 = Supplier::where('code', 'b1')->first();
$oldCost = (string) $b1->cost_rub;
$this->patchJson("/api/admin/suppliers/{$b1->id}", ['cost_rub' => '1.50'])
->assertOk();
expect((string) $b1->fresh()->cost_rub)->toBe('1.50');
expect((string) $b1->fresh()->cost_rub)->not->toBe($oldCost);
});
it('PATCH validates cost_rub >= 0', function () {
$b1 = Supplier::where('code', 'b1')->first();
$this->patchJson("/api/admin/suppliers/{$b1->id}", ['cost_rub' => '-1.00'])
->assertStatus(422);
});
it('PATCH writes saas_admin_audit_log row', function () {
$b1 = Supplier::where('code', 'b1')->first();
$this->patchJson("/api/admin/suppliers/{$b1->id}", ['cost_rub' => '2.00'])
->assertOk();
$log = DB::table('saas_admin_audit_log')
->where('action', 'suppliers.update')->first();
expect($log)->not->toBeNull();
});