chore: commit current workspace changes
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Models\ContentType;
|
||||
use App\Models\User;
|
||||
use App\Services\Studio\StudioAiAssistService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use function Pest\Laravel\actingAs;
|
||||
@@ -461,6 +462,84 @@ it('builds and exposes normalized studio ai suggestions', function (): void {
|
||||
->has('data.description_suggestions', 3));
|
||||
});
|
||||
|
||||
it('keeps category mapping queries bounded during direct ai analysis', function (): void {
|
||||
config()->set('vision.enabled', true);
|
||||
config()->set('vision.gateway.base_url', 'https://vision.local');
|
||||
config()->set('cdn.files_url', 'https://files.local');
|
||||
|
||||
$skins = ContentType::query()->create([
|
||||
'name' => 'Skins',
|
||||
'slug' => 'skins',
|
||||
]);
|
||||
|
||||
$photography = ContentType::query()->create([
|
||||
'name' => 'Photography',
|
||||
'slug' => 'photography',
|
||||
]);
|
||||
|
||||
$rootCategory = Category::query()->create([
|
||||
'content_type_id' => $skins->id,
|
||||
'name' => 'Audio',
|
||||
'slug' => 'audio',
|
||||
'is_active' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
Category::query()->create([
|
||||
'content_type_id' => $skins->id,
|
||||
'parent_id' => $rootCategory->id,
|
||||
'name' => 'Child ' . $i,
|
||||
'slug' => 'child-' . $i,
|
||||
'is_active' => true,
|
||||
'sort_order' => $i,
|
||||
]);
|
||||
}
|
||||
|
||||
Category::query()->create([
|
||||
'content_type_id' => $photography->id,
|
||||
'name' => 'Flowers',
|
||||
'slug' => 'flowers',
|
||||
'is_active' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
$artwork = Artwork::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'hash' => 'boundedaa112233',
|
||||
'file_name' => 'jet-audio.jpg',
|
||||
'title' => 'Jet Audio Skin',
|
||||
'description' => 'A colorful audio interface skin.',
|
||||
]);
|
||||
|
||||
$artwork->categories()->attach($rootCategory->id);
|
||||
|
||||
Http::fake([
|
||||
'https://vision.local/analyze/all' => Http::response([
|
||||
'clip' => [
|
||||
['tag' => 'audio interface', 'confidence' => 0.96],
|
||||
['tag' => 'skin', 'confidence' => 0.91],
|
||||
],
|
||||
'yolo' => [
|
||||
['label' => 'interface', 'confidence' => 0.79],
|
||||
],
|
||||
'blip' => 'an audio player interface skin with colorful controls',
|
||||
], 200),
|
||||
]);
|
||||
|
||||
$categoryQueryCount = 0;
|
||||
DB::listen(function ($query) use (&$categoryQueryCount) {
|
||||
if (preg_match('/\b(from|join)\s+["`\[]?(categories|content_types)\b/i', $query->sql) === 1) {
|
||||
$categoryQueryCount++;
|
||||
}
|
||||
});
|
||||
|
||||
app(StudioAiAssistService::class)->analyze($artwork->fresh(), false);
|
||||
|
||||
expect($categoryQueryCount)->toBeLessThanOrEqual(6);
|
||||
});
|
||||
|
||||
it('applies ai suggestions to artwork fields and tracks ai sources', function (): void {
|
||||
$photography = ContentType::query()->create([
|
||||
'name' => 'Photography',
|
||||
|
||||
Reference in New Issue
Block a user