using Microsoft.Playwright;
using IWS5.Autotest.IWS5.UiTests.Base;

namespace IWS5.Autotest.IWS5.UiTests
{
    public class LoginTests : PageTest
    {
        private EnvironmentSettings _settings;
        private IPage _page;

        [OneTimeSetUp]
        public async Task GlobalSetupAsync()
        {
            // Load environment settings and open browser
            _settings = await ConfigLoader.LoadEnvironmentSettingsAsync();
        }

        [Test]
        public async Task LogInPage_GivenValidUrlAndHostsFileEntry_ShouldContainLPNUEmarkInTitle()
        {
            // Arrange: Build full login URL
            var loginUrl = $"{_settings.baseUrl}{_settings.LogInPath}";
            await _page.GotoAsync(loginUrl);

            // Act & Assert: Ensure the page title contains "LPNU-Emark"
            await Expect(_page).ToHaveTitleAsync(new Regex("LPNU-Emark"));
        }

        [OneTimeTearDown]
        public async Task CleanupAsync()
        {
            await BrowserManager.CloseBrowserAsync();
        }
    }
}
