package commandcenter import ( "strings" "testing" ) func strPtr(s string) *string { return &s } func TestExecutiveCardsHonestEmptyStates(t *testing.T) { v := View{Meta: Meta{Empty: true}} cards := buildExecutiveCards(v, 0, 0) if len(cards) != 4 { t.Fatalf("want 4 cards, got %d", len(cards)) } for _, c := range cards { if !c.NoData { t.Fatalf("card %s must report no data on an empty org", c.Key) } if c.DataNote == "" || !strings.Contains(c.DataNote, "Feeds from") { t.Fatalf("card %s must NAME what feeds it, got %q", c.Key, c.DataNote) } if c.Value != "" && c.Key != "revenue_at_risk" { t.Fatalf("card %s must not fake a number, got %q", c.Key, c.Value) } } } func TestExecutiveCardsRealNumbers(t *testing.T) { v := View{ MissionReadiness: MissionReadiness{Score: "86.00", Band: "yellow", Status: "Watch"}, Banner: Banner{TotalClearedWorkforce: 40, ProposalReadyCandidates: 12, ActiveRequirements: 9}, StaffingGaps: []Gap{ {Unmet: 5, ValueAtRisk: strPtr("1200000"), PricedOpportunities: 2, UnpricedOpportunities: 1, ValueRepresentative: true}, {Unmet: 3, ValueAtRisk: strPtr("300000"), PricedOpportunities: 1}, }, } cards := buildExecutiveCards(v, 6, 9) byKey := map[string]ExecutiveCard{} for _, c := range cards { byKey[c.Key] = c } if byKey["mission_readiness"].Value != "86.00" || byKey["mission_readiness"].State != "watch" { t.Fatalf("mission readiness card wrong: %+v", byKey["mission_readiness"]) } if byKey["revenue_at_risk"].Value != "$1500000" { t.Fatalf("revenue at risk must sum the gap exposure exactly, got %q", byKey["revenue_at_risk"].Value) } if !strings.Contains(byKey["revenue_at_risk"].Detail, "3 priced") || !strings.Contains(byKey["revenue_at_risk"].Detail, "representative") { t.Fatalf("revenue detail must state the counted basis: %q", byKey["revenue_at_risk"].Detail) } if byKey["growth_capacity"].Value != "4" { t.Fatalf("growth capacity = ready 12 minus unmet 8 = 4, got %q", byKey["growth_capacity"].Value) } if byKey["staffing_confidence"].Value != "67%" { t.Fatalf("staffing confidence = 6 of 9 = 67 percent, got %q", byKey["staffing_confidence"].Value) } }