using Dalamud.Bindings.ImGui;
using Dalamud.Plugin.SelfTest;
using HellionChat.Resources;

namespace HellionChat.SelfTests;

// Verifies the v1.5.4 PM-2 quick-picker plumbing without rendering:
// resource strings resolve, the theme registry yields the expected
// minimum built-in count, and Config.Tabs is populated.
internal sealed class QuickPickerSelfTestStep : ISelfTestStep
{
    private readonly Plugin plugin;

    public QuickPickerSelfTestStep(Plugin plugin)
    {
        this.plugin = plugin;
    }

    public string Name => "Hellion Chat - Quick picker plumbing";

    public SelfTestStepResult RunStep()
    {
        if (string.IsNullOrWhiteSpace(HellionStrings.Settings_QuickPicker_Tooltip))
        {
            ImGui.Text("Settings_QuickPicker_Tooltip is empty in the active locale.");
            return SelfTestStepResult.Fail;
        }
        if (string.IsNullOrWhiteSpace(HellionStrings.Settings_QuickPicker_Themes_Header))
        {
            ImGui.Text("Settings_QuickPicker_Themes_Header is empty in the active locale.");
            return SelfTestStepResult.Fail;
        }
        if (string.IsNullOrWhiteSpace(HellionStrings.Settings_QuickPicker_Tabs_Header))
        {
            ImGui.Text("Settings_QuickPicker_Tabs_Header is empty in the active locale.");
            return SelfTestStepResult.Fail;
        }

        var registry = this.plugin.ThemeRegistry;
        if (registry is null)
        {
            ImGui.Text("ThemeRegistry not resolved.");
            return SelfTestStepResult.Fail;
        }

        var builtIns = registry.AllBuiltIns().ToList();
        if (builtIns.Count < 10)
        {
            ImGui.Text($"Expected at least 10 built-in themes, found {builtIns.Count}.");
            return SelfTestStepResult.Fail;
        }

        var tabs = Plugin.Config.Tabs;
        if (tabs is null || tabs.Count == 0)
        {
            ImGui.Text("Config.Tabs is empty.");
            return SelfTestStepResult.Fail;
        }

        return SelfTestStepResult.Pass;
    }

    public void CleanUp() { }
}
