Files
api/services/nginx/app/tests/Unit/Search/SystemSearchOpenApiSpecTest.php
T

54 lines
2.0 KiB
PHP

<?php
function system_search_openapi_content_or_skip(): string
{
$candidates = [];
for ($depth = 1; $depth <= 8; $depth++) {
$candidates[] = dirname(__DIR__, $depth) . DIRECTORY_SEPARATOR . 'openapi.yaml';
}
$cwd = getcwd();
if (is_string($cwd) && $cwd !== '') {
$candidates[] = $cwd . DIRECTORY_SEPARATOR . 'openapi.yaml';
$candidates[] = dirname($cwd) . DIRECTORY_SEPARATOR . 'openapi.yaml';
}
$candidates = array_values(array_unique($candidates));
foreach ($candidates as $candidate) {
if (is_file($candidate)) {
$content = file_get_contents($candidate);
if ($content !== false) {
return $content;
}
}
}
test()->markTestSkipped('openapi.yaml is not available in this runtime environment.');
}
it('documents system-wide search endpoints in openapi', function (): void {
$content = system_search_openapi_content_or_skip();
expect($content)->toContain('/search/system:');
expect($content)->toContain('/superuser/search/system/cache:');
expect($content)->toContain('/superuser/search/system/cache/rebuild:');
});
it('documents max_results and omits pagination and intent parser schemas in openapi', function (): void {
$content = system_search_openapi_content_or_skip();
expect($content)->toContain('max_results:');
expect($content)->not->toContain('debug_intent:');
expect($content)->not->toContain('SystemSearchIntentParserMeta:');
expect($content)->not->toContain('intent_parser:');
expect($content)->toContain('SystemSearchResponse:');
});
it('documents e-conomic indexed customer matching and synonym behavior', function (): void {
$content = system_search_openapi_content_or_skip();
expect($content)->toContain('local e-conomic customer index');
expect($content)->toContain('`rabat` -> `discount`');
expect($content)->toContain('strict relevance filtering');
expect($content)->toContain('recent records preferred when relevance is comparable');
});