<?php

use App\Domains\Bio\Models\BioPage;
use App\Domains\Workspace\Models\Workspace;

it('serves bio at workspace-slug-path on apex domain', function () {
    $ws = Workspace::factory()->free()->create(['slug' => 'nexxo']);
    BioPage::factory()->for($ws)->create([
        'slug'         => 'my-bio',
        'is_published' => true,
    ]);

    $this->get('http://nimu.li/b/nexxo/my-bio')->assertOk();
});

it('returns 404 for ulid-path attempt on apex domain', function () {
    $ws = Workspace::factory()->free()->create(['slug' => 'nexxo']);
    BioPage::factory()->for($ws)->create([
        'slug'         => 'my-bio',
        'is_published' => true,
    ]);

    // ULID starts with digits/uppercase — fails workspaceSlug regex [a-z][a-z0-9-]{1,62}
    $this->get('http://nimu.li/b/'.$ws->ulid.'/my-bio')->assertNotFound();
});

it('unpublished bio returns 404 on apex domain', function () {
    $ws = Workspace::factory()->free()->create(['slug' => 'nexxo']);
    BioPage::factory()->for($ws)->create([
        'slug'         => 'draft',
        'is_published' => false,
    ]);

    $this->get('http://nimu.li/b/nexxo/draft')->assertNotFound();
});
