package plan

import (
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/tidbcloud/AgentTeam/internal/core/domain"
)

func TestLegacyForkArtifactIsNotLimitedByTaskWatchHandoffPredecessors(t *testing.T) {
	artifact := compileArtifactForTest(
		t,
		string(projectedArtifactAmplificationSource(
			0,
			domain.MaxWorkflowTaskWatchHandoffPredecessors+1,
		)),
	)
	require.Equal(t, ArtifactVersionV1, artifact.ArtifactVersion)
	require.Len(
		t,
		artifactNodeForTest(artifact, "fan").Config.Fork.Branches,
		domain.MaxWorkflowTaskWatchHandoffPredecessors+1,
	)

	wire, err := artifact.DeterministicJSON()
	require.NoError(t, err)
	decoded, err := DecodeArtifact(wire)
	require.NoError(t, err)
	require.Equal(t, artifact.Digest, decoded.Digest)
}
