41fb1e9d02
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Services\External\JivoLivenessProbe;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class); // нужен booted-app: config()/Http::fake()
|
|
|
|
beforeEach(function () {
|
|
config()->set('services.jivosite.widget_id', 'ABC123');
|
|
config()->set('services.jivosite.widget_url_template', 'https://code.jivo.ru/widget/{id}');
|
|
});
|
|
|
|
it('зелёный при 200 на виджет-скрипт', function () {
|
|
Http::fake(['code.jivo.ru/widget/ABC123' => Http::response('/* jivo */', 200)]);
|
|
$r = (new JivoLivenessProbe)->check();
|
|
expect($r->serviceKey)->toBe('jivosite');
|
|
expect($r->light)->toBe('green');
|
|
});
|
|
|
|
it('красный при 404', function () {
|
|
Http::fake(['code.jivo.ru/widget/ABC123' => Http::response('', 404)]);
|
|
expect((new JivoLivenessProbe)->check()->light)->toBe('red');
|
|
});
|
|
|
|
it('серый, когда widget_id не задан', function () {
|
|
config()->set('services.jivosite.widget_id', '');
|
|
expect((new JivoLivenessProbe)->check()->light)->toBe('grey');
|
|
});
|