95ee6644f7
Три pre-existing красных теста (ЭТАЛОН §6 «deferred») приведены к реальной схеме v8.26 после project-migration-redesign Plans 1-3: - SchemaDeltaTest: 64→65 base tables, 121→123 indexes (project_supplier_links pivot + supplier_projects_platform_key_subject_unique). - SupplierProjectsAccessTest: unique-constraint (platform, unique_key) → (platform, unique_key, subject_code) — per-субъект экспорт (Plan 1). - SupplierLeadFlowTest: routing eligibility теперь через pivot project_supplier_links (LeadRouter), не legacy supplier_b1_project_id — добавлены linkProjectToSupplier() связи. - schema.sql header: v8.25→v8.26 + метрики (CHANGELOG уже содержал v8.26). Production-код не менялся — тесты отставали от уже-смердженных Plans 1-3. Pest full 1013/1010 passed/3 skipped/0 failed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
test('supplier_projects table exists with required columns', function () {
|
|
expect(Schema::hasTable('supplier_projects'))->toBeTrue();
|
|
|
|
foreach ([
|
|
'id',
|
|
'platform',
|
|
'signal_type',
|
|
'unique_key',
|
|
'supplier_external_id',
|
|
'current_limit',
|
|
'current_workdays',
|
|
'current_regions',
|
|
'sync_status',
|
|
'last_synced_at',
|
|
'inactive_since',
|
|
'created_at',
|
|
'updated_at',
|
|
] as $col) {
|
|
expect(Schema::hasColumn('supplier_projects', $col))->toBeTrue();
|
|
}
|
|
});
|
|
|
|
test('supplier_projects has unique constraint on (platform, unique_key, subject_code)', function () {
|
|
// v8.26 (project-migration-redesign Plan 1): per-субъект экспорт — composite unique
|
|
// расширен до (platform, unique_key, subject_code) NULLS NOT DISTINCT. Старый
|
|
// 2-колоночный индекс supplier_projects_platform_unique_key_unique заменён.
|
|
$idx = DB::selectOne(
|
|
"SELECT indexdef
|
|
FROM pg_indexes
|
|
WHERE tablename = 'supplier_projects'
|
|
AND indexname = 'supplier_projects_platform_key_subject_unique'"
|
|
);
|
|
|
|
expect($idx)->not->toBeNull();
|
|
expect($idx->indexdef)
|
|
->toContain('UNIQUE')
|
|
->toContain('platform')
|
|
->toContain('unique_key')
|
|
->toContain('subject_code');
|
|
});
|
|
|
|
test('supplier_projects platform check constraint allows only B1, B2, B3', function () {
|
|
$check = DB::selectOne(
|
|
"SELECT pg_get_constraintdef(c.oid) AS def
|
|
FROM pg_constraint c
|
|
JOIN pg_class t ON c.conrelid = t.oid
|
|
WHERE t.relname = 'supplier_projects' AND c.conname = 'chk_supplier_projects_platform'"
|
|
);
|
|
|
|
expect($check)->not->toBeNull();
|
|
expect($check->def)
|
|
->toContain("'B1'")
|
|
->toContain("'B2'")
|
|
->toContain("'B3'");
|
|
});
|
|
|
|
test('supplier_projects sync_status check constraint', function () {
|
|
$check = DB::selectOne(
|
|
"SELECT pg_get_constraintdef(c.oid) AS def
|
|
FROM pg_constraint c
|
|
JOIN pg_class t ON c.conrelid = t.oid
|
|
WHERE t.relname = 'supplier_projects' AND c.conname = 'chk_supplier_projects_sync_status'"
|
|
);
|
|
|
|
expect($check)->not->toBeNull();
|
|
expect($check->def)
|
|
->toContain("'pending'")
|
|
->toContain("'ok'")
|
|
->toContain("'failed'");
|
|
});
|
|
|
|
test('supplier_projects has NO RLS policy (relrowsecurity = false)', function () {
|
|
$row = DB::selectOne(
|
|
"SELECT relrowsecurity
|
|
FROM pg_class
|
|
WHERE relname = 'supplier_projects' AND relkind = 'r'"
|
|
);
|
|
|
|
expect($row)->not->toBeNull();
|
|
expect($row->relrowsecurity)->toBeFalse();
|
|
});
|
|
|
|
test('supplier_projects has REVOKE ALL on crm_app_user (no privileges in role_table_grants)', function () {
|
|
$rows = DB::select(
|
|
"SELECT privilege_type
|
|
FROM information_schema.role_table_grants
|
|
WHERE table_name = 'supplier_projects'
|
|
AND grantee = 'crm_app_user'"
|
|
);
|
|
|
|
expect($rows)->toBe([]);
|
|
});
|