using NATS.Server.JetStream.Cluster;

namespace NATS.Server.JetStream.Tests.JetStream;

public class JetStreamMetaGovernanceStrictParityTests
{
    [Fact]
    public async Task Meta_and_replica_governance_actions_reflect_committed_state_transitions()
    {
        var meta = new JetStreamMetaGroup(3);
        var before = meta.GetState();

        await meta.ProposeCreateStreamAsync(new NATS.Server.JetStream.Models.StreamConfig
        {
            Name = "ORDERS_GOV",
            Subjects = ["orders.gov"],
        }, default);
        meta.StepDown();
        var after = meta.GetState();

        after.Streams.ShouldContain("ORDERS_GOV");
        after.LeaderId.ShouldNotBe(before.LeaderId);
        after.LeadershipVersion.ShouldBe(before.LeadershipVersion + 1);
    }
}
