trypost/tests/Unit/Ai/Agents/BrandAnalyzerTest.php
Paulo Castellano de4d5f3c68 Share a ContentLanguageOption type and close the review's test gaps
- Extract ContentLanguageOption into @/types and use it for availableContentLanguages
  across BrandForm, BrandTab, Brand, Create, and the LanguagePicker options, so the
  englishName field that drives search is visible to TypeScript instead of being
  dropped silently by the pass-through prop types.
- Add BrandAnalyzerTest: assert the language schema enum equals the full 15-language
  set (guards against it shrinking back to a hardcoded subset behind ::fake()) and
  that instructions() lists every code.
- Isolate the "LLM language wins" autofill test by declaring the page as `en` while
  the LLM returns `de`, so it actually proves mergeLlm precedence instead of both
  paths agreeing.
- Cover SetLocale's cookie side effect: the default locale cookie is set on an
  invalid/absent cookie and left untouched for a valid locale.
2026-07-03 19:28:28 -03:00

23 lines
777 B
PHP

<?php
declare(strict_types=1);
use App\Ai\Agents\BrandAnalyzer;
use App\Enums\Workspace\ContentLanguage;
use Illuminate\JsonSchema\JsonSchemaTypeFactory;
test('language schema allows every supported content language', function () {
$schema = (new BrandAnalyzer)->schema(new JsonSchemaTypeFactory);
// Guards against the enum silently shrinking back to a hardcoded subset:
// the LLM may only emit a language the schema allows.
expect($schema['language']->toArray()['enum'])->toBe(ContentLanguage::values());
});
test('instructions list every supported language code', function () {
$instructions = (new BrandAnalyzer)->instructions();
foreach (ContentLanguage::values() as $code) {
expect($instructions)->toContain("`{$code}`");
}
});