From a3552970fe84774b4d19319c15de2740b9deaca2 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 17 May 2026 23:32:53 +0200 Subject: [PATCH] fix(bio): add missing url_format columns + update PublicUrl tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migration: url_format_override on bio_pages, bio_url_format on workspaces, needs_migration + migration_required_at on bio_pages (model casts existed, columns did not) - PublicUrl tests updated for effectiveFormat() logic: - Pro default = SystemPath (no subdomain without explicit bio_url_format=Subdomain) - url_format_override on bio overrides workspace format - needs_migration=true → publicUrl() returns '' Co-Authored-By: Claude Sonnet 4.6 --- ...5_17_700000_add_bio_url_format_columns.php | 28 ++++++++++++++ tests/Feature/Bio/PublicUrlTest.php | 37 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_05_17_700000_add_bio_url_format_columns.php diff --git a/database/migrations/2026_05_17_700000_add_bio_url_format_columns.php b/database/migrations/2026_05_17_700000_add_bio_url_format_columns.php new file mode 100644 index 0000000..7b1c3ac --- /dev/null +++ b/database/migrations/2026_05_17_700000_add_bio_url_format_columns.php @@ -0,0 +1,28 @@ +string('url_format_override', 32)->nullable()->after('slug'); + $table->boolean('needs_migration')->default(false)->after('is_published'); + $table->timestamp('migration_required_at')->nullable()->after('needs_migration'); + }); + + Schema::table('workspaces', function (Blueprint $table) { + $table->string('bio_url_format', 32)->nullable()->after('subdomain_provisioned_at'); + }); + } + + public function down(): void + { + Schema::table('workspaces', fn (Blueprint $t) => $t->dropColumn('bio_url_format')); + Schema::table('bio_pages', fn (Blueprint $t) => $t->dropColumn(['url_format_override', 'needs_migration', 'migration_required_at'])); + } +}; diff --git a/tests/Feature/Bio/PublicUrlTest.php b/tests/Feature/Bio/PublicUrlTest.php index f110cfd..629cc99 100644 --- a/tests/Feature/Bio/PublicUrlTest.php +++ b/tests/Feature/Bio/PublicUrlTest.php @@ -2,6 +2,7 @@ use App\Domains\Bio\Models\BioPage; use App\Domains\Workspace\Models\Workspace; +use App\Enums\BioUrlFormat; it('returns free path-url for free plan workspace', function () { $ws = Workspace::factory()->free()->create(['slug' => 'nexxo']); @@ -17,13 +18,37 @@ it('returns shortPublicUrl without scheme', function () { expect($bio->shortPublicUrl())->toBe('nimu.li/b/nexxo/my-bio'); }); -it('returns pro subdomain-url when subdomain_full set', function () { +it('returns pro subdomain-url when bio_url_format=Subdomain and subdomain_full set', function () { + $ws = Workspace::factory()->pro()->create([ + 'slug' => 'acme', + 'subdomain_full' => 'acme.nimu.li', + 'bio_url_format' => BioUrlFormat::Subdomain, + ]); + $bio = BioPage::factory()->for($ws)->create(['slug' => 'john']); + + expect($bio->publicUrl())->toBe('https://acme.nimu.li/b/john'); +}); + +it('returns pro path-url by default (no bio_url_format set)', function () { $ws = Workspace::factory()->pro()->create([ 'slug' => 'acme', 'subdomain_full' => 'acme.nimu.li', ]); $bio = BioPage::factory()->for($ws)->create(['slug' => 'john']); + expect($bio->publicUrl())->toBe('https://nimu.li/b/acme/john'); +}); + +it('bio url_format_override=Subdomain overrides workspace format', function () { + $ws = Workspace::factory()->pro()->create([ + 'slug' => 'acme', + 'subdomain_full' => 'acme.nimu.li', + ]); + $bio = BioPage::factory()->for($ws)->create([ + 'slug' => 'john', + 'url_format_override' => BioUrlFormat::Subdomain, + ]); + expect($bio->publicUrl())->toBe('https://acme.nimu.li/b/john'); }); @@ -46,3 +71,13 @@ it('falls back to free path when no subdomain_full on paid plan', function () { expect($bio->publicUrl())->toBe('https://nimu.li/b/acme/test'); }); + +it('returns empty string when needs_migration is true', function () { + $ws = Workspace::factory()->free()->create(['slug' => 'nexxo']); + $bio = BioPage::factory()->for($ws)->create([ + 'slug' => 'migrating', + 'needs_migration' => true, + ]); + + expect($bio->publicUrl())->toBe(''); +});