<?php

declare(strict_types=1);

use App\Models\User;
use Database\Seeders\RoleAndPermissionSeeder;

beforeEach(function (): void {
    $this->seed(RoleAndPermissionSeeder::class);
    $this->accountUrl = 'http://'.config('app.domains.account');
});

it('displays the subscriptions index page', function (): void {
    $user = User::factory()->create();

    $this->actingAs($user)
        ->get($this->accountUrl.'/subscriptions')
        ->assertOk()
        ->assertInertia(fn ($page) => $page
            ->component('Subscriptions/Index')
            ->has('subscriptions')
        );
});

it('requires authentication to view subscriptions', function (): void {
    $this->get($this->accountUrl.'/subscriptions')
        ->assertRedirect();
});
