using System.Runtime.CompilerServices;

namespace ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests.Cluster;

/// <summary>
/// Makes the suite's skip policy visible: at process exit, writes one console
/// line reporting how many cluster/DB-dependent test gates skipped because the
/// cluster was unavailable (see <see cref="ClusterAvailability.SkippedCount"/>).
/// Registered once via a <see cref="ModuleInitializerAttribute"/> so it runs
/// regardless of how the test host is launched (Task 3).
/// </summary>
internal static class SkipSummaryReporter
{
    [ModuleInitializer]
    internal static void Init() =>
        AppDomain.CurrentDomain.ProcessExit += (_, _) =>
        {
            if (ClusterAvailability.SkippedCount > 0)
            {
                Console.WriteLine($"[E2E] Skipped {ClusterAvailability.SkippedCount} cluster/DB-dependent test gate(s) — {ClusterAvailability.SkipReason}");
            }
        };
}
