update
This commit is contained in:
@@ -7,6 +7,9 @@ declare(strict_types=1);
|
||||
* Routing Unification spec (§3.2 Explore, §4 Blog/Pages, §6.1 redirects).
|
||||
*/
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
|
||||
// ── /explore routes ──────────────────────────────────────────────────────────
|
||||
|
||||
it('GET /explore returns 200', function () {
|
||||
@@ -78,6 +81,116 @@ it('GET /discover redirects to /discover/trending with 301', function () {
|
||||
$this->get('/discover')->assertRedirect('/discover/trending')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /sections redirects to /categories with 301', function () {
|
||||
$this->get('/sections')->assertRedirect('/categories')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /browse-categories redirects to /categories with 301', function () {
|
||||
$this->get('/browse-categories')->assertRedirect('/categories')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('legacy mixed-case category route redirects to the canonical category URL with 301', function () {
|
||||
$contentType = ContentType::query()->create([
|
||||
'name' => 'Skins',
|
||||
'slug' => 'skins',
|
||||
]);
|
||||
|
||||
$category = Category::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'name' => 'BrowserBob',
|
||||
'slug' => 'browserbob',
|
||||
]);
|
||||
|
||||
$this->get('/Skins/BrowserBob/' . $category->id . '?ref=legacy')
|
||||
->assertRedirect('/skins/browserbob?ref=legacy')
|
||||
->assertStatus(301);
|
||||
});
|
||||
|
||||
it('legacy nested category route redirects to the canonical nested category URL with 301', function () {
|
||||
$contentType = ContentType::query()->create([
|
||||
'name' => 'Skins',
|
||||
'slug' => 'skins',
|
||||
]);
|
||||
|
||||
$parent = Category::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'name' => 'BrowserBob',
|
||||
'slug' => 'browserbob',
|
||||
]);
|
||||
|
||||
$child = Category::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'parent_id' => $parent->id,
|
||||
'name' => 'sdsdsdsd',
|
||||
'slug' => 'sdsdsdsd',
|
||||
]);
|
||||
|
||||
$this->get('/Skins/BrowserBob/sdsdsdsd/' . $child->id)
|
||||
->assertRedirect('/skins/browserbob/sdsdsdsd')
|
||||
->assertStatus(301);
|
||||
});
|
||||
|
||||
it('legacy category route falls back to /categories and preserves query string when no category matches', function () {
|
||||
$this->get('/Skins/does-not-exist/999999?source=old-site')
|
||||
->assertRedirect('/categories?source=old-site')
|
||||
->assertStatus(301);
|
||||
});
|
||||
|
||||
it('legacy /category route redirects to the canonical category URL with 301', function () {
|
||||
$contentType = ContentType::query()->create([
|
||||
'name' => 'Skins',
|
||||
'slug' => 'skins',
|
||||
]);
|
||||
|
||||
$category = Category::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'name' => 'BrowserBob',
|
||||
'slug' => 'browserbob',
|
||||
]);
|
||||
|
||||
$this->get('/category/skins/browserbob/' . $category->id . '?ref=legacy-category')
|
||||
->assertRedirect('/skins/browserbob?ref=legacy-category')
|
||||
->assertStatus(301);
|
||||
});
|
||||
|
||||
it('legacy /category route falls back to /categories and preserves query string when no category matches', function () {
|
||||
$this->get('/category/skins/does-not-exist/999999?source=legacy-category')
|
||||
->assertRedirect('/categories?source=legacy-category')
|
||||
->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /today-in-history redirects to /discover/on-this-day with 301', function () {
|
||||
$this->get('/today-in-history')->assertRedirect('/discover/on-this-day')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /members redirects to /creators/top with 301', function () {
|
||||
$this->get('/members')->assertRedirect('/creators/top')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /explore/members redirects to /creators/top with 301', function () {
|
||||
$this->get('/explore/members')->assertRedirect('/creators/top')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /latest-artworks redirects to /discover/fresh with 301', function () {
|
||||
$this->get('/latest-artworks')->assertRedirect('/discover/fresh')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /today-downloads redirects to /downloads/today with 301', function () {
|
||||
$this->get('/today-downloads')->assertRedirect('/downloads/today')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /monthly-commentators redirects to /comments/monthly with 301', function () {
|
||||
$this->get('/monthly-commentators')->assertRedirect('/comments/monthly')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /top-favourites redirects to /discover/top-rated with 301', function () {
|
||||
$this->get('/top-favourites')->assertRedirect('/discover/top-rated')->assertStatus(301);
|
||||
});
|
||||
|
||||
it('GET /downloads/today returns 200', function () {
|
||||
$this->get('/downloads/today')->assertOk();
|
||||
});
|
||||
|
||||
// ── /blog routes ─────────────────────────────────────────────────────────────
|
||||
|
||||
it('GET /blog returns 200', function () {
|
||||
|
||||
Reference in New Issue
Block a user