2026-06-28 13:28:56 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Services\Autopodbor\Agent\CompetitorAgent;
|
|
|
|
|
use App\Services\Autopodbor\Agent\Dto\{FindCompetitorsRequest, StudyCompetitorRequest, ResolveByNameRequest};
|
|
|
|
|
|
|
|
|
|
it('заглушка резолвится через контейнер и отдаёт данные', function () {
|
|
|
|
|
$agent = app(CompetitorAgent::class);
|
|
|
|
|
expect($agent)->toBeInstanceOf(\App\Services\Autopodbor\Agent\FakeCompetitorAgent::class);
|
|
|
|
|
|
|
|
|
|
$found = $agent->findCompetitors(new FindCompetitorsRequest(16, ['okna.ru'], [], true, 15));
|
|
|
|
|
expect(count($found->competitors))->toBeGreaterThan(0)
|
|
|
|
|
->and($found->competitors[0])->toHaveKeys(['name','relevance_pct','site_url']);
|
|
|
|
|
|
|
|
|
|
$study = $agent->studyCompetitor(new StudyCompetitorRequest(['name'=>'Окна Комфорт','site_url'=>'okna-komfort-kzn.ru'], 16));
|
|
|
|
|
expect($study->sources)->not->toBeEmpty()
|
|
|
|
|
->and($study->sources[0])->toHaveKeys(['signal_type','identifier','provenance_url']);
|
|
|
|
|
|
|
|
|
|
$resolve = $agent->resolveByName(new ResolveByNameRequest('Окна Комфорт', 16));
|
|
|
|
|
expect($resolve->candidates)->not->toBeEmpty();
|
|
|
|
|
});
|
2026-06-30 06:42:33 +03:00
|
|
|
|
|
|
|
|
it('заглушка отдаёт полный набор типов телефонов вкл. 8-800 (tollfree)', function () {
|
|
|
|
|
$agent = app(CompetitorAgent::class);
|
|
|
|
|
$study = $agent->studyCompetitor(new StudyCompetitorRequest(['name'=>'Окна Комфорт','site_url'=>'okna-komfort-kzn.ru'], 16));
|
|
|
|
|
|
|
|
|
|
$phoneTypes = collect($study->sources)
|
|
|
|
|
->where('signal_type', 'call')
|
|
|
|
|
->pluck('phone_type')
|
|
|
|
|
->unique()
|
|
|
|
|
->values()
|
|
|
|
|
->all();
|
|
|
|
|
|
|
|
|
|
// Тупой клиент должен увидеть все три типа номера: городской, мобильный, 8-800.
|
|
|
|
|
expect($phoneTypes)->toContain('city')
|
|
|
|
|
->and($phoneTypes)->toContain('mobile')
|
|
|
|
|
->and($phoneTypes)->toContain('tollfree');
|
|
|
|
|
});
|