<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminPlatformOrderIndexToolGroupsShouldStayInsideToolsGridTest extends TestCase
{
    use RefreshDatabase;

    protected function loginAsPlatformAdmin(): void
    {
        $this->seed();

        $this->post('/admin/login', [
            'email' => 'platform.admin@demo.local',
            'password' => 'Platform@123456',
        ])->assertRedirect('/admin');
    }

    public function test_platform_orders_tool_groups_should_stay_inside_tools_grid(): void
    {
        $this->loginAsPlatformAdmin();

        $res = $this->get('/admin/platform-orders');
        $res->assertOk();

        $html = (string) $res->getContent();
        $this->assertMatchesRegularExpression('/data-role="po-tools-grid"[\s\S]*?po-tools-group-export[\s\S]*?po-tools-group-batch-activate-subscriptions[\s\S]*?po-tools-group-batch-bmpa[\s\S]*?po-tools-group-batch-mark-activated[\s\S]*?po-tools-group-clear-sync-errors[\s\S]*?po-tools-group-clear-bmpa-errors/u', $html);
    }
}
