feat: Inertia profile settings page, Studio edit redesign, EGS, Nova UI components\n\n- Redesign /dashboard/profile as Inertia React page (Settings/ProfileEdit)\n with SettingsLayout sidebar, Nova UI components (TextInput, Textarea,\n Toggle, Select, RadioGroup, Modal, Button), avatar drag-and-drop,\n password change, and account deletion sections\n- Redesign Studio artwork edit page with two-column layout, Nova components,\n integrated TagPicker, and version history modal\n- Add shared MarkdownEditor component\n- Add Early-Stage Growth System (EGS): SpotlightEngine, FeedBlender,\n GridFiller, AdaptiveTimeWindow, ActivityLayer, admin panel\n- Fix upload category/tag persistence (V1+V2 paths)\n- Fix tag source enum, category tree display, binding resolution\n- Add settings.jsx Vite entry, settings.blade.php wrapper\n- Update ProfileController with JSON response support for API calls\n- Various route fixes (profile.edit, toolbar settings link)"

This commit is contained in:
2026-03-03 20:57:43 +01:00
parent dc51d65440
commit b9c2d8597d
114 changed files with 8760 additions and 693 deletions

View File

@@ -0,0 +1,116 @@
<?php
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
describe('Footer pages', function () {
it('shows the FAQ page', function () {
$this->get('/faq')
->assertOk()
->assertSee('Frequently Asked Questions');
});
it('shows the Rules & Guidelines page', function () {
$this->get('/rules-and-guidelines')
->assertOk()
->assertSee('Rules & Guidelines');
});
it('shows the Privacy Policy page', function () {
$this->get('/privacy-policy')
->assertOk()
->assertSee('Privacy Policy');
});
it('shows the Terms of Service page', function () {
$this->get('/terms-of-service')
->assertOk()
->assertSee('Terms of Service');
});
it('shows the bug report page to guests with login prompt', function () {
$this->get('/bug-report')
->assertOk()
->assertSee('Bug Report');
});
it('shows the bug report form to authenticated users', function () {
$user = \App\Models\User::factory()->create();
$this->actingAs($user)
->get('/bug-report')
->assertOk()
->assertSee('Subject');
});
it('submits a bug report as authenticated user', function () {
$user = \App\Models\User::factory()->create();
$this->actingAs($user)
->post('/bug-report', [
'subject' => 'Test subject',
'description' => 'This is a test bug report description.',
])
->assertRedirect('/bug-report');
$this->assertDatabaseHas('bug_reports', [
'user_id' => $user->id,
'subject' => 'Test subject',
]);
});
it('rejects bug report submission from guests', function () {
$this->post('/bug-report', [
'subject' => 'Test',
'description' => 'Test description',
])->assertRedirect('/login');
});
it('shows the staff page', function () {
$this->get('/staff')
->assertOk()
->assertSee('Meet the Staff');
});
it('shows the RSS feeds info page', function () {
$this->get('/rss-feeds')
->assertOk()
->assertSee('RSS')
->assertSee('Latest Uploads');
});
it('returns XML for latest uploads feed', function () {
$this->get('/rss/latest-uploads.xml')
->assertOk()
->assertHeader('Content-Type', 'application/rss+xml; charset=utf-8');
});
it('returns XML for latest skins feed', function () {
$this->get('/rss/latest-skins.xml')
->assertOk()
->assertHeader('Content-Type', 'application/rss+xml; charset=utf-8');
});
it('returns XML for latest wallpapers feed', function () {
$this->get('/rss/latest-wallpapers.xml')
->assertOk()
->assertHeader('Content-Type', 'application/rss+xml; charset=utf-8');
});
it('returns XML for latest photos feed', function () {
$this->get('/rss/latest-photos.xml')
->assertOk()
->assertHeader('Content-Type', 'application/rss+xml; charset=utf-8');
});
it('RSS feed contains valid XML', function () {
$response = $this->get('/rss/latest-uploads.xml');
$response->assertOk();
$xml = simplexml_load_string($response->getContent());
expect($xml)->not->toBeFalse();
expect((string) $xml->channel->title)->toContain('Skinbase');
});
});

View File

@@ -0,0 +1,194 @@
<?php
declare(strict_types=1);
/**
* Feature tests for the new canonical route families introduced by the
* Routing Unification spec (§3.2 Explore, §4 Blog/Pages, §6.1 redirects).
*/
// ── /explore routes ──────────────────────────────────────────────────────────
it('GET /explore returns 200', function () {
$this->get('/explore')->assertOk();
});
it('GET /explore contains "Explore" heading', function () {
$this->get('/explore')->assertOk()->assertSee('Explore', false);
});
it('GET /explore/wallpapers returns 200', function () {
$this->get('/explore/wallpapers')->assertOk();
});
it('GET /explore/skins returns 200', function () {
$this->get('/explore/skins')->assertOk();
});
it('GET /explore/photography returns 200', function () {
$this->get('/explore/photography')->assertOk();
});
it('GET /explore/artworks returns 200', function () {
$this->get('/explore/artworks')->assertOk();
});
it('GET /explore/other returns 200', function () {
$this->get('/explore/other')->assertOk();
});
it('GET /explore/wallpapers/trending returns 200', function () {
$this->get('/explore/wallpapers/trending')->assertOk();
});
it('GET /explore/wallpapers/latest returns 200', function () {
$this->get('/explore/wallpapers/latest')->assertOk();
});
it('GET /explore/wallpapers/best returns 200', function () {
$this->get('/explore/wallpapers/best')->assertOk();
});
it('GET /explore/wallpapers/new-hot returns 200', function () {
$this->get('/explore/wallpapers/new-hot')->assertOk();
});
it('/explore pages include canonical link tag', function () {
$html = $this->get('/explore')->assertOk()->getContent();
expect($html)->toContain('rel="canonical"');
});
it('/explore pages set robots index,follow', function () {
$html = $this->get('/explore')->assertOk()->getContent();
expect($html)->toContain('index,follow');
});
it('/explore pages include breadcrumb JSON-LD', function () {
$html = $this->get('/explore/wallpapers')->assertOk()->getContent();
expect($html)->toContain('BreadcrumbList');
});
// ── 301 redirects from legacy routes ─────────────────────────────────────────
it('GET /browse redirects to /explore with 301', function () {
$this->get('/browse')->assertRedirect('/explore')->assertStatus(301);
});
it('GET /discover redirects to /discover/trending with 301', function () {
$this->get('/discover')->assertRedirect('/discover/trending')->assertStatus(301);
});
// ── /blog routes ─────────────────────────────────────────────────────────────
it('GET /blog returns 200', function () {
$this->get('/blog')->assertOk();
});
it('/blog page contains Blog heading', function () {
$html = $this->get('/blog')->assertOk()->getContent();
expect($html)->toContain('Blog');
});
it('/blog page includes canonical link', function () {
$html = $this->get('/blog')->assertOk()->getContent();
expect($html)->toContain('rel="canonical"');
});
it('/blog/:slug returns 404 for non-existent post', function () {
$this->get('/blog/this-post-does-not-exist-xyz')->assertNotFound();
});
it('published blog post is accessible at /blog/:slug', function () {
$post = \App\Models\BlogPost::factory()->create([
'slug' => 'hello-world',
'title' => 'Hello World Post',
'body' => '<p>Test content.</p>',
'is_published' => true,
'published_at' => now()->subDay(),
]);
$html = $this->get('/blog/hello-world')->assertOk()->getContent();
expect($html)->toContain('Hello World Post');
});
it('unpublished blog post returns 404', function () {
\App\Models\BlogPost::factory()->create([
'slug' => 'draft-post',
'title' => 'Draft Post',
'body' => '<p>Draft.</p>',
'is_published' => false,
]);
$this->get('/blog/draft-post')->assertNotFound();
});
it('/blog post includes Article JSON-LD', function () {
\App\Models\BlogPost::factory()->create([
'slug' => 'schema-post',
'title' => 'Schema Post',
'body' => '<p>Content.</p>',
'is_published' => true,
'published_at' => now()->subHour(),
]);
$html = $this->get('/blog/schema-post')->assertOk()->getContent();
expect($html)->toContain('"Article"');
});
// ── /pages routes ─────────────────────────────────────────────────────────────
it('GET /pages/:slug returns 404 for non-existent page', function () {
$this->get('/pages/does-not-exist-xyz')->assertNotFound();
});
it('published page is accessible at /pages/:slug', function () {
\App\Models\Page::factory()->create([
'slug' => 'test-page',
'title' => 'Test Page Title',
'body' => '<p>Page content.</p>',
'is_published' => true,
'published_at' => now()->subDay(),
]);
$html = $this->get('/pages/test-page')->assertOk()->getContent();
expect($html)->toContain('Test Page Title');
});
it('/about returns 200 when about page exists', function () {
\App\Models\Page::factory()->create([
'slug' => 'about',
'title' => 'About Skinbase',
'body' => '<p>About us.</p>',
'is_published' => true,
'published_at' => now()->subDay(),
]);
$this->get('/about')->assertOk();
});
it('/legal/terms returns 200 when legal-terms page exists', function () {
\App\Models\Page::factory()->create([
'slug' => 'legal-terms',
'title' => 'Terms of Service',
'body' => '<p>Terms.</p>',
'is_published' => true,
'published_at' => now()->subDay(),
]);
$this->get('/legal/terms')->assertOk();
});
// ── tags index layout ─────────────────────────────────────────────────────────
it('/tags page renders with ContentLayout breadcrumbs', function () {
$html = $this->get('/tags')->assertOk()->getContent();
// ContentLayout should inject breadcrumb nav
expect($html)->toContain('Tags');
});
it('/tags page includes canonical and robots', function () {
$html = $this->get('/tags')->assertOk()->getContent();
expect($html)
->toContain('rel="canonical"')
->toContain('index,follow');
});

View File

@@ -0,0 +1,298 @@
<?php
declare(strict_types=1);
use App\Services\EarlyGrowth\AdaptiveTimeWindow;
use App\Services\EarlyGrowth\EarlyGrowth;
use App\Services\EarlyGrowth\FeedBlender;
use App\Services\EarlyGrowth\GridFiller;
use App\Services\EarlyGrowth\SpotlightEngineInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;
uses(TestCase::class);
// ─── EarlyGrowth feature-flag guard ──────────────────────────────────────────
it('EarlyGrowth::enabled returns false when config disabled', function () {
config()->set('early_growth.enabled', false);
config()->set('early_growth.mode', 'light');
expect(EarlyGrowth::enabled())->toBeFalse();
});
it('EarlyGrowth::enabled returns false when mode is off', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'off');
expect(EarlyGrowth::enabled())->toBeFalse();
});
it('EarlyGrowth::enabled returns true when enabled and mode is light', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
expect(EarlyGrowth::enabled())->toBeTrue();
});
it('EarlyGrowth::enabled returns true when mode is aggressive', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'aggressive');
config()->set('early_growth.auto_disable.enabled', false);
expect(EarlyGrowth::enabled())->toBeTrue();
});
it('EarlyGrowth::mode rejects unknown values and returns off', function () {
config()->set('early_growth.mode', 'extreme_turbo');
expect(EarlyGrowth::mode())->toBe('off');
});
it('EarlyGrowth::status returns all keys', function () {
config()->set('early_growth.enabled', false);
config()->set('early_growth.mode', 'off');
$status = EarlyGrowth::status();
expect($status)->toHaveKeys(['enabled', 'mode', 'adaptive_window', 'grid_filler', 'spotlight', 'activity_layer']);
});
it('module toggles are false when EGS is disabled', function () {
config()->set('early_growth.enabled', false);
expect(EarlyGrowth::adaptiveWindowEnabled())->toBeFalse();
expect(EarlyGrowth::gridFillerEnabled())->toBeFalse();
expect(EarlyGrowth::spotlightEnabled())->toBeFalse();
expect(EarlyGrowth::activityLayerEnabled())->toBeFalse();
});
it('module toggles respect individual flags when EGS is on', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.adaptive_time_window', false);
config()->set('early_growth.grid_filler', true);
config()->set('early_growth.spotlight', false);
config()->set('early_growth.activity_layer', true);
expect(EarlyGrowth::adaptiveWindowEnabled())->toBeFalse();
expect(EarlyGrowth::gridFillerEnabled())->toBeTrue();
expect(EarlyGrowth::spotlightEnabled())->toBeFalse();
expect(EarlyGrowth::activityLayerEnabled())->toBeTrue();
});
it('EarlyGrowth returns correct blend ratios per mode', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.blend_ratios.light', ['fresh' => 0.60, 'curated' => 0.25, 'spotlight' => 0.15]);
$ratios = EarlyGrowth::blendRatios();
expect($ratios['fresh'])->toBe(0.60);
expect($ratios['curated'])->toBe(0.25);
expect($ratios['spotlight'])->toBe(0.15);
});
// ─── AdaptiveTimeWindow ───────────────────────────────────────────────────────
it('AdaptiveTimeWindow returns default when EGS disabled', function () {
config()->set('early_growth.enabled', false);
$tw = new AdaptiveTimeWindow();
expect($tw->getTrendingWindowDays(30))->toBe(30);
expect($tw->getTrendingWindowDays(7))->toBe(7);
});
it('AdaptiveTimeWindow expands to medium window when uploads below narrow threshold', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.adaptive_time_window', true);
config()->set('early_growth.thresholds.uploads_per_day_narrow', 10);
config()->set('early_growth.thresholds.uploads_per_day_wide', 3);
config()->set('early_growth.thresholds.window_narrow_days', 7);
config()->set('early_growth.thresholds.window_medium_days', 30);
config()->set('early_growth.thresholds.window_wide_days', 90);
// Mock: 5 uploads/day (between narrow=10 and wide=3) → 30 days
Cache::put('egs.uploads_per_day', 5.0, 60);
$tw = new AdaptiveTimeWindow();
expect($tw->getTrendingWindowDays(7))->toBe(30);
});
it('AdaptiveTimeWindow expands to wide window when uploads below wide threshold', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.adaptive_time_window', true);
config()->set('early_growth.thresholds.uploads_per_day_narrow', 10);
config()->set('early_growth.thresholds.uploads_per_day_wide', 3);
config()->set('early_growth.thresholds.window_narrow_days', 7);
config()->set('early_growth.thresholds.window_medium_days', 30);
config()->set('early_growth.thresholds.window_wide_days', 90);
// Mock: 1 upload/day (below wide=3) → 90 days
Cache::put('egs.uploads_per_day', 1.0, 60);
$tw = new AdaptiveTimeWindow();
expect($tw->getTrendingWindowDays(7))->toBe(90);
});
it('AdaptiveTimeWindow keeps narrow window when uploads above narrow threshold', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.adaptive_time_window', true);
config()->set('early_growth.thresholds.uploads_per_day_narrow', 10);
config()->set('early_growth.thresholds.uploads_per_day_wide', 3);
config()->set('early_growth.thresholds.window_narrow_days', 7);
config()->set('early_growth.thresholds.window_medium_days', 30);
config()->set('early_growth.thresholds.window_wide_days', 90);
// Mock: 15 uploads/day (above narrow=10) → normal 7-day window
Cache::put('egs.uploads_per_day', 15.0, 60);
$tw = new AdaptiveTimeWindow();
expect($tw->getTrendingWindowDays(7))->toBe(7);
});
// ─── GridFiller ───────────────────────────────────────────────────────────────
it('GridFiller does nothing when EGS disabled', function () {
config()->set('early_growth.enabled', false);
$original = make_paginator(3);
$gf = new GridFiller();
$result = $gf->fill($original, 12, 1);
expect($result->getCollection()->count())->toBe(3);
});
it('GridFiller does not fill pages beyond page 1', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.grid_filler', true);
$original = make_paginator(3, perPage: 12, page: 2);
$gf = new GridFiller();
$result = $gf->fill($original, 12, 2);
// Page > 1 → leave untouched
expect($result->getCollection()->count())->toBe(3);
});
it('GridFiller fillCollection does nothing when EGS disabled', function () {
config()->set('early_growth.enabled', false);
$items = collect(range(1, 3))->map(fn ($i) => (object) ['id' => $i]);
$gf = new GridFiller();
expect($gf->fillCollection($items, 12)->count())->toBe(3);
});
// ─── FeedBlender ─────────────────────────────────────────────────────────────
it('FeedBlender returns original paginator when EGS disabled', function () {
config()->set('early_growth.enabled', false);
$spotlight = Mockery::mock(SpotlightEngineInterface::class);
$blender = new FeedBlender($spotlight);
$original = make_paginator(8);
$result = $blender->blend($original, 24, 1);
expect($result->getCollection()->count())->toBe(8);
});
it('FeedBlender returns original paginator on page > 1', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
$spotlight = Mockery::mock(SpotlightEngineInterface::class);
$blender = new FeedBlender($spotlight);
$original = make_paginator(8, page: 2);
$result = $blender->blend($original, 24, 2);
expect($result->getCollection()->count())->toBe(8);
});
it('FeedBlender preserves original total in blended paginator', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'light');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.blend_ratios.light', ['fresh' => 0.60, 'curated' => 0.25, 'spotlight' => 0.15]);
$spotlight = Mockery::mock(SpotlightEngineInterface::class);
$spotlight->allows('getCurated')->andReturn(collect());
$spotlight->allows('getSpotlight')->andReturn(collect());
$blender = new FeedBlender($spotlight);
$original = make_paginator(6, total: 100);
$result = $blender->blend($original, 24, 1);
// Original total must be preserved so pagination links are stable
expect($result->total())->toBe(100);
});
it('FeedBlender removes duplicate IDs across sources', function () {
config()->set('early_growth.enabled', true);
config()->set('early_growth.mode', 'aggressive');
config()->set('early_growth.auto_disable.enabled', false);
config()->set('early_growth.blend_ratios.aggressive', ['fresh' => 0.30, 'curated' => 0.50, 'spotlight' => 0.20]);
// Curated returns some IDs that overlap with fresh
$freshItems = collect(range(1, 10))->map(fn ($i) => make_artwork_stub($i));
$curatedItems = collect(range(5, 15))->map(fn ($i) => make_artwork_stub($i)); // IDs 5-10 overlap
$spotlightItems = collect(range(20, 25))->map(fn ($i) => make_artwork_stub($i));
$spotlight = Mockery::mock(SpotlightEngineInterface::class);
$spotlight->allows('getCurated')->andReturn($curatedItems);
$spotlight->allows('getSpotlight')->andReturn($spotlightItems);
$blender = new FeedBlender($spotlight);
$original = make_paginator(10, total: 100, items: $freshItems);
$result = $blender->blend($original, 24, 1);
$ids = $result->getCollection()->pluck('id')->toArray();
$uniqueIds = array_unique($ids);
expect(count($ids))->toBe(count($uniqueIds));
});
// ─── Helpers ──────────────────────────────────────────────────────────────────
function make_paginator(
int $count = 12,
int $total = 0,
int $perPage = 24,
int $page = 1,
?\Illuminate\Support\Collection $items = null,
): LengthAwarePaginator {
$collection = $items ?? collect(range(1, $count))->map(fn ($i) => make_artwork_stub($i));
$total = $total > 0 ? $total : $count;
return new LengthAwarePaginator($collection->all(), $total, $perPage, $page, [
'path' => '/discover/fresh',
]);
}
function make_artwork_stub(int $id): object
{
return (object) [
'id' => $id,
'title' => "Artwork {$id}",
'published_at' => now()->subDays($id),
];
}