carlos / platform Public

economics page: label after the source, test the whole-bill hint

Move the cost-basis label after the heading's closing parenthesis, the
shape Paul approved in the preview. TestEconomicsPageShowsBillBasis now
checks the literal approved labels (C1/C2) rather than recomputing them,
asserts each hint sits in a co-note under the bill table, and adds an
explicit "whole" bill under the CARLOS-only scope: C2 in the heading,
the C7 hint, never C1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c1596c49d7cfc6ebee90c2f3aae811c3ce379a68 parent 69a0a1d
2 files changed, +31 −19
  • internal/console/economicspage_test.go +30 −18
  • internal/console/templates/economics.html +1 −1

CI passed — run details

diff --git a/internal/console/economicspage_test.go b/internal/console/economicspage_test.go
index b7217c6ed..3f6702564 100644
--- a/internal/console/economicspage_test.go
+++ b/internal/console/economicspage_test.go
@@ -951,31 +951,38 @@ func TestEconomicsAccountsPageTierFormOnlyForConsoleRows(t *testing.T) {
}
// TestEconomicsPageShowsBillBasis: the bill table says what the AWS bill
-// covers. An unstated bill on a console declared CARLOS-only reads "CARLOS
-// only" with no hint; under the zero scope it reads "not only CARLOS" and
-// the hint says how to declare the account. The bill is this month's: the
-// page reads bills against the real clock (loadRecentBills), so a fixed
-// month would fall off it.
+// covers, with the label after the heading's closing parenthesis. An
+// unstated bill on a console declared CARLOS-only reads "CARLOS only" with
+// no hint; under the zero scope it reads "not only CARLOS" and the hint says
+// how to declare the account. A bill stated as "whole" reads "not only
+// CARLOS" even on a CARLOS-only console, and its hint says it does not
+// count. The bill is this month's: the page reads bills against the real
+// clock (loadRecentBills), so a fixed month would fall off it.
func TestEconomicsPageShowsBillBasis(t *testing.T) {
const (
c1 = "AWS, whole account: CARLOS only"
c2 = "AWS, whole account: not only CARLOS"
c3 = "This bill covers the whole AWS account, which may hold more than CARLOS. If the account runs only CARLOS, set CONSOLE_COST_ACCOUNT_CARLOS_ONLY=true on the console."
+ c7 = "This bill was entered as covering the whole AWS account, CARLOS and other things, so it does not count as CARLOS cost."
)
month := usage.MonthOf(time.Now().UTC())
for _, tc := range []struct {
- name string
- scope CostScope
- want, deny []string
+ name string
+ scope CostScope
+ basis string
+ label string
+ hint string // "" when the page shows none
+ deny []string
}{
- {"account", CostScope{AccountCarlosOnly: true}, []string{c1}, []string{c2, c3}},
- {"zero", CostScope{}, []string{c2, c3}, []string{c1}},
+ {"account", CostScope{AccountCarlosOnly: true}, economics.BasisUnstated, c1, "", []string{c2, c3, c7}},
+ {"zero", CostScope{}, economics.BasisUnstated, c2, c3, []string{c1, c7}},
+ {"whole under account", CostScope{AccountCarlosOnly: true}, economics.BasisWhole, c2, c7, []string{c1, c3}},
} {
t.Run(tc.name, func(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.CostScope = tc.scope
putStoreJSON(t, fx.rel, economics.BillKey(month), economics.Bill{
- Schema: 1, Month: month, TotalUSD: 12,
+ Schema: 1, Month: month, TotalUSD: 12, Basis: tc.basis,
Services: map[string]float64{"AmazonEC2": 12}, Source: economics.SourceCostExplorer,
})
c := signInPaul(t, fx)
@@ -986,14 +993,19 @@ func TestEconomicsPageShowsBillBasis(t *testing.T) {
if status != 200 {
t.Fatalf("/fleet/economics = %d, want 200:\n%s", status, body)
}
- heading := "Bill service (" + month + ", " + economics.SourceCostExplorer + ", "
- for _, want := range tc.want {
- if !strings.Contains(body, want) {
- t.Fatalf("page missing %q in:\n%s", want, body)
- }
+ heading := "Bill service (" + month + ", " + economics.SourceCostExplorer + ") " + tc.label + "</th>"
+ if !strings.Contains(body, heading) {
+ t.Fatalf("bill heading missing %q in:\n%s", heading, body)
}
- if !strings.Contains(body, heading+costBasisLabel(effectiveBillBasis(economics.Bill{}, tc.scope), "")+")") {
- t.Fatalf("bill heading does not carry the label; want prefix %q in:\n%s", heading, body)
+ if tc.hint != "" {
+ note := "<p co-note>" + tc.hint + "</p>"
+ i := strings.Index(body, note)
+ if i < 0 {
+ t.Fatalf("page missing hint %q in:\n%s", note, body)
+ }
+ if j := strings.Index(body, heading); i < strings.Index(body[j:], "</table>")+j {
+ t.Fatalf("hint %q is not under the bill table:\n%s", tc.hint, body)
+ }
}
for _, deny := range tc.deny {
if strings.Contains(body, deny) {
diff --git a/internal/console/templates/economics.html b/internal/console/templates/economics.html
index 675f25a0c..d7ea3373d 100644
--- a/internal/console/templates/economics.html
+++ b/internal/console/templates/economics.html
@@ -210,7 +210,7 @@
{{$delta := sub $billChecked $modelTotal}}
<div rst-card class="co-table-wrap">
<table co-table>
- <tr><th>Bill service ({{$curBill.Month}}, {{$curBill.Source}}, {{index .Economics.BillBasisLabels $curBill.Month}})</th><th>USD</th><th>Counts as CARLOS</th></tr>
+ <tr><th>Bill service ({{$curBill.Month}}, {{$curBill.Source}}) {{index .Economics.BillBasisLabels $curBill.Month}}</th><th>USD</th><th>Counts as CARLOS</th></tr>
{{range $svc, $amt := $curBill.Services}}
<tr>
<td>{{$svc}}</td>