Files
portal/app/tests/Feature/Bot/HelpRebuildKnowledgeCommandTest.php
T

27 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
uses(RefreshDatabase::class);
it('перечитывает resources/help и заполняет knowledge_chunks с нуля', function () {
// Мусорная строка от прошлой индексации — должна исчезнуть (полная перезаливка).
DB::table('knowledge_chunks')->insert([
'source_path' => 'help/deleted-article.md', 'title' => 'Старая', 'topics' => '',
'chunk_index' => 0, 'content' => 'мусор', 'created_at' => now(), 'updated_at' => now(),
]);
$this->artisan('help:rebuild-knowledge')->assertExitCode(0);
expect(DB::table('knowledge_chunks')->where('source_path', 'help/deleted-article.md')->count())->toBe(0)
2026-07-12 12:56:22 +03:00
->and(DB::table('knowledge_chunks')->where('title', 'like', 'Создать проект%')->count())->toBeGreaterThan(0)
->and(DB::table('knowledge_chunks')->where('title', 'like', 'Тарифы%')->count())->toBeGreaterThan(0)
->and(DB::table('knowledge_chunks')->where('title', 'like', 'Дубли конкурентов%')->count())->toBeGreaterThan(0)
// Инструкция переписана 12.07.2026 узкими статьями по темам («резать по вопросу»,
// требование владельца) — их сильно больше, чем прежних 17 обзорных.
->and(DB::table('knowledge_chunks')->distinct('source_path')->count('source_path'))->toBeGreaterThanOrEqual(30);
});