namespace Tests.Pages;

public class DatabasePage : BasePage
{
    public DatabasePage(Website website) : base(website)
    {
    }

    public override string Url => "database";

    public async Task FilterNameAsync(string name)
    {
        var input = Website.FindById("filterName").First;
        await Website.EnterInputAsync(input, name);
    }

    public async Task<string> GetEntityNameAsync(string entityType, string entityName)
    {
        var el = Website.Locator($"#{entityType.ToLower()}-{entityName.ToLower()}").Locator("#entityName");
        return (await el.InnerTextAsync()).Trim();
    }

    public async Task<string> GetEntityNameByIndexAsync(int index)
    {
        var el = Website.FindById("entityName").Nth(index);
        return (await el.InnerTextAsync()).Trim();
    }
}