<?php

use App\Models\AdminSite;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

test('public runtime origins returns enabled integration site iframe origins only', function (): void {
    AdminSite::query()->create([
        'code' => 'enabled-a',
        'name' => 'Enabled A',
        'currency_code' => 'NPR',
        'status' => 1,
        'iframe_allowed_origins' => [
            'https://main.example.test',
            'https://main.example.test',
            ' https://shell.example.test ',
        ],
    ]);

    AdminSite::query()->create([
        'code' => 'disabled-a',
        'name' => 'Disabled A',
        'currency_code' => 'NPR',
        'status' => 0,
        'iframe_allowed_origins' => [
            'https://disabled.example.test',
        ],
    ]);

    $this->getJson('/api/v1/integration/runtime-origins')
        ->assertOk()
        ->assertJsonPath('code', 0)
        ->assertJsonPath('data.iframe_allowed_origins', [
            'https://main.example.test',
            'https://shell.example.test',
        ]);
});
