chore: commit remaining workspace changes
This commit is contained in:
@@ -10,8 +10,6 @@ use App\Services\AiBiography\AiBiographyInputBuilder;
|
||||
use App\Services\AiBiography\AiBiographyService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia;
|
||||
use Klevze\ControlPanel\Core\Structs\MenuRootItem;
|
||||
use Klevze\ControlPanel\Framework\Core\Menu as ControlPanelMenu;
|
||||
use Klevze\ControlPanel\Models\Admin\AdminVerification;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
@@ -77,17 +75,17 @@ it('renders the ai biography admin index with records and stats', function (): v
|
||||
]);
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->get(route('cp.ai-biography.index'))
|
||||
->get(route('admin.cp.ai-biography.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->component('Moderation/AiBiographyAdmin')
|
||||
->component('Admin/AiBiography')
|
||||
->where('stats.total_records', 2)
|
||||
->where('stats.needs_review', 1)
|
||||
->where('stats.failed', 1)
|
||||
->where('records.data.0.user.username', 'bioadmin')
|
||||
->where('records.data.0.status', CreatorAiBiography::STATUS_FAILED)
|
||||
->where('records.data.1.status', CreatorAiBiography::STATUS_NEEDS_REVIEW)
|
||||
->where('endpoints.rebuildPattern', route('cp.ai-biography.rebuild', ['user' => '__USER__'])));
|
||||
->where('endpoints.rebuildPattern', route('admin.cp.ai-biography.rebuild', ['user' => '__USER__'])));
|
||||
});
|
||||
|
||||
it('allows controlpanel-only admins to open the ai biography admin page', function (): void {
|
||||
@@ -102,30 +100,11 @@ it('allows controlpanel-only admins to open the ai biography admin page', functi
|
||||
});
|
||||
|
||||
it('registers the ai biography entry in the cpad artworks menu', function (): void {
|
||||
$admin = aiBiographyAdminUser();
|
||||
$creator = User::factory()->create(['username' => 'menubio']);
|
||||
biographyRecord($creator, [
|
||||
'needs_review' => true,
|
||||
'status' => CreatorAiBiography::STATUS_NEEDS_REVIEW,
|
||||
]);
|
||||
$artworksPlugin = file_get_contents(base_path('packages/klevze/Plugins/Artworks/ServiceProvider.php'));
|
||||
$adminLayout = file_get_contents(base_path('resources/js/Layouts/AdminLayout.jsx'));
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->get(route('cp.ai-biography.index'))
|
||||
->assertOk();
|
||||
|
||||
$sidebarMenu = collect(app(ControlPanelMenu::class)->getSidebarMenu());
|
||||
|
||||
$artworksRoot = $sidebarMenu
|
||||
->first(fn ($item): bool => $item instanceof MenuRootItem && $item->getName() === 'Artworks');
|
||||
|
||||
expect($artworksRoot)->toBeInstanceOf(MenuRootItem::class);
|
||||
|
||||
$aiBiographyItem = collect($artworksRoot->getItems())
|
||||
->first(fn ($item): bool => str_starts_with((string) ($item->name ?? ''), 'AI Biographies'));
|
||||
|
||||
expect($aiBiographyItem)->not->toBeNull()
|
||||
->and($aiBiographyItem->mainRoute)->toBe('cp.ai-biography.index')
|
||||
->and($aiBiographyItem->icon)->toBe('fa-solid fa-feather-pointed');
|
||||
expect($artworksPlugin)->toContain('admin.cp.ai-biography.index')
|
||||
->and($adminLayout)->toContain("/moderation/ai-biography");
|
||||
});
|
||||
|
||||
it('rebuilds an existing active biography through the admin surface', function (): void {
|
||||
@@ -158,7 +137,7 @@ it('rebuilds an existing active biography through the admin surface', function (
|
||||
app()->instance(AiBiographyService::class, new AiBiographyService(new AiBiographyInputBuilder(), $generator));
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->postJson(route('cp.ai-biography.rebuild', ['user' => $creator->id]))
|
||||
->postJson(route('admin.cp.ai-biography.rebuild', ['user' => $creator->id]))
|
||||
->assertOk()
|
||||
->assertJsonPath('success', true)
|
||||
->assertJsonPath('message', 'Biography rebuild completed.');
|
||||
@@ -176,7 +155,7 @@ it('allows admins to approve flag and toggle visibility on biography records', f
|
||||
]);
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->postJson(route('cp.ai-biography.approve', ['biography' => $record->id]))
|
||||
->postJson(route('admin.cp.ai-biography.approve', ['biography' => $record->id]))
|
||||
->assertOk()
|
||||
->assertJsonPath('success', true);
|
||||
|
||||
@@ -184,21 +163,21 @@ it('allows admins to approve flag and toggle visibility on biography records', f
|
||||
->and($record->fresh()->status)->toBe(CreatorAiBiography::STATUS_APPROVED);
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->postJson(route('cp.ai-biography.hide', ['biography' => $record->id]))
|
||||
->postJson(route('admin.cp.ai-biography.hide', ['biography' => $record->id]))
|
||||
->assertOk()
|
||||
->assertJsonPath('success', true);
|
||||
|
||||
expect($record->fresh()->is_hidden)->toBeTrue();
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->postJson(route('cp.ai-biography.show', ['biography' => $record->id]))
|
||||
->postJson(route('admin.cp.ai-biography.show', ['biography' => $record->id]))
|
||||
->assertOk()
|
||||
->assertJsonPath('success', true);
|
||||
|
||||
expect($record->fresh()->is_hidden)->toBeFalse();
|
||||
|
||||
$this->actingAs($admin)->actingAs($admin, 'controlpanel')
|
||||
->postJson(route('cp.ai-biography.flag', ['biography' => $record->id]))
|
||||
->postJson(route('admin.cp.ai-biography.flag', ['biography' => $record->id]))
|
||||
->assertOk()
|
||||
->assertJsonPath('success', true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user