package userapi

import (
	"testing"

	userv1 "hyapp.local/api/proto/user/v1"
)

func TestCPRelationshipFromProtoIncludesLevelProgress(t *testing.T) {
	item := &userv1.CPRelationship{
		RelationshipId:        "cp_rel:1:2",
		RelationType:          "brother",
		Status:                "active",
		IntimacyValue:         180,
		Level:                 2,
		CurrentLevelThreshold: 100,
		NextLevelThreshold:    300,
		NeededForNextLevel:    120,
		LevelProgressPercent:  40,
		MaxLevel:              false,
		BreakupCostCoins:      88,
		FormedAtMs:            1700000000000,
		EndedAtMs:             1700000002000,
		UpdatedAtMs:           1700000001000,
	}

	got := cpRelationshipFromProto(item)
	if got.CurrentLevelThreshold != 100 ||
		got.NextLevelThreshold != 300 ||
		got.NeededForNextLevel != 120 ||
		got.LevelProgressPercent != 40 ||
		got.MaxLevel ||
		got.BreakupCostCoins != 88 ||
		got.EndedAtMS != 1700000002000 {
		t.Fatalf("relationship progress fields not mapped: %+v", got)
	}
}
