0f820c4569
Backend AdminSuppliersController:
- GET /api/admin/suppliers — все 3 поставщика (B1/B2/B3).
- PATCH /api/admin/suppliers/{id} — обновляет cost_rub / quality_score / is_active.
- Validation: cost_rub >= 0, quality_score 0..9.99.
- Audit trail saas_admin_audit_log (stub admin via system-supplier@liderra.local).
- 4 Pest integration tests.
Frontend AdminSupplierPricesView (Vue 3 + Vuetify 3):
- v-data-table 3 строки с inline-editing cost_rub/quality_score/is_active.
- Forest-palette + JetBrains Mono tnum.
- 3 Vitest tests + Histoire story.
Router /admin/supplier-prices route.
Drive-by fix: SupplierProjectFactory.definition() default signal_type
ограничен ['site','call'] — иначе при ->create(['platform' => 'B1']) с
оригинальным random 'sms' нарушается CHECK chk_supplier_projects_b1_not_for_sms
(flaky parallel-pest race condition). Тесты, которым нужен 'sms', продолжают
явно передавать signal_type вместе с B2/B3.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?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 3 suppliers B1/B2/B3', function () {
|
|
$response = $this->getJson('/api/admin/suppliers');
|
|
$response->assertOk();
|
|
$data = $response->json('data');
|
|
expect($data)->toHaveCount(3);
|
|
expect(collect($data)->pluck('code')->all())->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();
|
|
});
|