Files
portal/app/tests/Feature/Imitation/ImitationSeedCommandTest.php
T
Дмитрий 669e161017 feat(imitation): imitation:seed command to populate local portal
Self-contained app-namespace artisan command (NEVER on production) that funds local imitation clients on a shared B2 supplier, disables DaData (region from tag), rebuilds the routing snapshot, then injects synthetic leads through the real RouteSupplierLeadJob so deals/charges/notifications appear for hands-on UI review. The lead payload encodes the supplier unique_key as a domain so RouteSupplierLeadJob re-resolves the real supplier (parseProjectField then resolveOrStub). Test asserts exit 0 + new deals.
2026-06-04 05:09:29 +03:00

34 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Deal;
use Database\Seeders\PricingTierSeeder;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Tests\Concerns\SharesSupplierPdo;
// Same in-transaction DB the command writes to and the assertions read.
uses(DatabaseTransactions::class, SharesSupplierPdo::class);
beforeEach(function (): void {
(new PricingTierSeeder())->run();
DB::statement("SELECT set_config('app.current_tenant_id', '0', true)");
});
/**
* Task 14 — live `imitation:seed` command.
*
* The command self-contains the population scenario (funded clients on a shared
* supplier source, region from tag with DaData disabled, snapshot rebuild, then
* synthetic leads through the real RouteSupplierLeadJob) so a developer can review
* the running portal "through the client's eyes". It must NEVER run on production.
*/
it('populates the running portal for UI review', function (): void {
$this->artisan('imitation:seed', ['--leads' => 20, '--clients' => 3])
->assertExitCode(0);
// The real routing + ledger pipeline ran → new deals exist for review.
expect(Deal::where('status', 'new')->count())->toBeGreaterThan(0);
})->group('imitation');