package transcript

import "testing"

func TestNormalizeToolCallMetaMarksWriteStdinShellAsPlainRenderHint(t *testing.T) {
	meta := NormalizeToolCallMeta(ToolCallMeta{
		ToolName:       "write_stdin",
		RenderBehavior: ToolCallRenderBehaviorShell,
	})

	if meta.RenderHint == nil || meta.RenderHint.Kind != ToolRenderKindPlain {
		t.Fatalf("expected write_stdin shell metadata to use plain render hint, got %+v", meta.RenderHint)
	}
}

func TestNormalizeToolCallMetaPreservesExplicitRenderHint(t *testing.T) {
	meta := NormalizeToolCallMeta(ToolCallMeta{
		ToolName:       "write_stdin",
		RenderBehavior: ToolCallRenderBehaviorShell,
		RenderHint:     &ToolRenderHint{Kind: ToolRenderKindShell, ShellDialect: ToolShellDialectPowerShell},
	})

	if meta.RenderHint == nil || meta.RenderHint.Kind != ToolRenderKindShell || meta.RenderHint.ShellDialect != ToolShellDialectPowerShell {
		t.Fatalf("expected explicit render hint preserved, got %+v", meta.RenderHint)
	}
}

func TestToolCallMetaEqualIncludesShellOutputStatus(t *testing.T) {
	left := &ToolCallMeta{ToolName: "exec_command", IsShell: true, RawOutputRequested: true}
	right := &ToolCallMeta{ToolName: "exec_command", IsShell: true}

	if ToolCallMetaEqual(left, right) {
		t.Fatal("expected raw output status to affect tool metadata equality")
	}

	right.RawOutputRequested = true
	if !ToolCallMetaEqual(left, right) {
		t.Fatal("expected matching raw output status to be equal")
	}

	right.OutputTruncated = true
	if ToolCallMetaEqual(left, right) {
		t.Fatal("expected truncation status to affect tool metadata equality")
	}
}
