<?php

namespace MintyPHP\Tests\Architecture;

use PHPUnit\Framework\TestCase;

final class AsideNavigationRuntimeContractTest extends TestCase
{
    use ProjectFileAssertionSupport;

    public function testAsidePanelsUseSharedDetailsOpenStateHelper(): void
    {
        $content = $this->readProjectFile('web/js/components/app-toggle-aside-panels.js');

        $this->assertStringContainsString(
            "import { initPersistedDetailsGroup } from '../core/app-details-open-state.js';",
            $content
        );
        $this->assertStringContainsString('initPersistedDetailsGroup({', $content);
        $this->assertStringContainsString("panel.dataset.asideDetailsOpenActive === '1'", $content);
    }

    public function testDetailStateUsesSharedDetailsOpenStateHelper(): void
    {
        $content = $this->readProjectFile('web/js/components/app-details-state.js');

        $this->assertStringContainsString(
            "import { initPersistedDetailsGroup } from '../core/app-details-open-state.js';",
            $content
        );
        $this->assertStringContainsString('initPersistedDetailsGroup({', $content);
        $this->assertStringNotContainsString('window.localStorage.setItem(storageKey, JSON.stringify(openKeys));', $content);
    }
}
