<?php

namespace MintyPHP\Tests\Architecture;

use PHPUnit\Framework\TestCase;

class AuthLoginFrontendCleanupContractTest extends TestCase
{
    use ProjectFileAssertionSupport;

    public function testLoginCssDoesNotContainLegacyBackToLoginSelector(): void
    {
        $content = $this->readProjectFile('web/css/pages/app-login.css');

        $this->assertStringNotContainsString('.back_to_login', $content);
    }

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

        $this->assertStringContainsString("input.dataset.passwordToggleBound === '1'", $content);
        $this->assertStringContainsString("input.dataset.passwordToggleBound = '1';", $content);
        $this->assertStringContainsString("toggle.dataset.passwordToggleBound = '1';", $content);
    }

    public function testLoginPasswordHintsUsesDuplicateBindingGuard(): void
    {
        $content = $this->readProjectFile('web/js/components/app-password-hints.js');

        $this->assertStringContainsString("container.dataset.passwordHintsBound === '1'", $content);
        $this->assertStringContainsString("container.dataset.passwordHintsBound = '1';", $content);
    }
}
