operator-people-detail: review fixes: run facts kept, missing exit neutral, truncation cause-free, exact address first
Astra round 1, READY AFTER FIXES; the four P2s: - Run rows keep what they recorded: operators always get the escaped, indented JSON under the sentence; customer sentences name the uploaded files with their sizes (OPS-178, OPS-179) and the box's explanation of a result (OPS-180). - A result with a missing or null exit reads as 'Run ended with no exit code recorded' (OPS-181), never exit code 0. - OPS-175 states the cut-off without a cause: a failed output upload also truncates. Luna kept OPS-175 and OPS-178 to OPS-181 as drafted. - The person page and ?who= try the exact stored address first, then the lower-cased one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+201
−45
approved_operator_pages_copy_test.go+11 −8docs/superpowers/plans/2026-10-27-operator-people-detail-copy.md+24 −2internal/console/auditdetail.go+68 −22internal/console/auditdetail_test.go+38 −4internal/console/opperson.go+12 −7internal/console/opperson_test.go+45 −0internal/console/templates/opparts.html+3 −2
diff --git a/approved_operator_pages_copy_test.go b/approved_operator_pages_copy_test.go| index 2956c928d..f18189df9 100644 |
| --- a/approved_operator_pages_copy_test.go |
| +++ b/approved_operator_pages_copy_test.go |
| @@ -13,7 +13,7 @@ import ( |
| // The copy gate of the operator pages plan (spec 2026-10-25, Part 3). The |
| // record is docs/superpowers/plans/2026-10-25-operator-pages-copy.md, and |
| // the operator people detail change's record continues its ids |
| -// (2026-10-27-operator-people-detail-copy.md, OPS-155 to OPS-177). It |
| +// (2026-10-27-operator-people-detail-copy.md, OPS-155 to OPS-181). It |
| // reuses the moves gate's helpers (parseCopyTable, checkMovesInventory, |
| // checkMovesNoEmDash, checkRunBuilt, checkRunApplied) as the edge asset cache |
| // gate does. |
| @@ -25,7 +25,7 @@ import ( |
| // it names. No pending string reaches code or templates. |
| // - TestOperatorPeopleDetailCopyInventory and |
| // TestOperatorPeopleDetailCopyBuiltRowsAreApprovedAndPresent: the same |
| -// two checks for the second record, its rows OPS-155 to OPS-177 and its |
| +// two checks for the second record, its rows OPS-155 to OPS-181 and its |
| // built list operatorPeopleDetailCopyBuilt. |
| // |
| // A row's file is a path relative to internal/console/, so the built rows are |
| @@ -50,17 +50,17 @@ var operatorPagesCopyIDs = func() []string { |
| }() |
| // operatorPeopleDetailCopyIDs is the second record's inventory, pinned: |
| -// OPS-155 to OPS-177. |
| +// OPS-155 to OPS-181. |
| var operatorPeopleDetailCopyIDs = func() []string { |
| - ids := make([]string, 0, 23) |
| - for i := 155; i <= 177; i++ { |
| + ids := make([]string, 0, 27) |
| + for i := 155; i <= 181; i++ { |
| ids = append(ids, "OPS-"+strconv.Itoa(i)) |
| } |
| return ids |
| }() |
| // operatorPeopleDetailCopyBuilt is every row of the second record the code |
| -// or templates carry: all of them. OPS-174 and OPS-177 are checked through |
| +// or templates carry: all of them. OPS-174, OPS-177 and OPS-180 are checked through |
| // operatorPagesShortGoText. |
| var operatorPeopleDetailCopyBuilt = []string{ |
| // The person page (opperson.go, templates/ops_person.html). |
| @@ -72,6 +72,8 @@ var operatorPeopleDetailCopyBuilt = []string{ |
| "OPS-171", "OPS-172", "OPS-173", "OPS-174", "OPS-175", "OPS-176", |
| // A service's run (auditdetail.go). |
| "OPS-177", |
| + // Review fixes: uploaded files, the box's explanation, no exit code. |
| + "OPS-178", "OPS-179", "OPS-180", "OPS-181", |
| } |
| // operatorPagesCopyBuilt is every row whose text the code or templates carry. |
| @@ -135,6 +137,7 @@ var operatorPagesShortGoText = map[string]bool{ |
| "OPS-80": true, // "OK", jobs.go |
| "OPS-174": true, // "<run> on <box>", auditdetail.go's "%s on %s" |
| "OPS-177": true, // "<sentence>. <requester>", auditdetail.go's "%s. %s" |
| + "OPS-180": true, // "<run>. <detail>", auditdetail.go's "%s. %s" |
| } |
| // checkOperatorPagesBuilt is every problem with the built entries: not |
| @@ -217,8 +220,8 @@ func TestOperatorPeopleDetailCopyInventory(t *testing.T) { |
| rows := mustParseOperatorCopyRecordAt(t, operatorPeopleDetailCopyRecordPath) |
| reportAll(t, checkMovesInventory(rows, operatorPeopleDetailCopyIDs)) |
| reportAll(t, checkMovesNoEmDash(rows)) |
| - if len(rows) != 23 { |
| - t.Errorf("the record has %d rows, want 23", len(rows)) |
| + if len(rows) != 27 { |
| + t.Errorf("the record has %d rows, want 27", len(rows)) |
| } |
| } |
diff --git a/docs/superpowers/plans/2026-10-27-operator-people-detail-copy.md b/docs/superpowers/plans/2026-10-27-operator-people-detail-copy.md| index 0c2ef0bb9..1b52b9ac4 100644 |
| --- a/docs/superpowers/plans/2026-10-27-operator-people-detail-copy.md |
| +++ b/docs/superpowers/plans/2026-10-27-operator-people-detail-copy.md |
| @@ -32,7 +32,8 @@ number; `<signal>` a signal number; `<reason>` why a box interrupted or |
| refused a run, as the box recorded it; `<duration>` how long a run took, |
| such as `2m3s`; `<box>` a box's label; `<run>` one of OPS-165 to OPS-170 or OPS-172; |
| `<action>` an audit action name, such as `store-apply`; `<sentence>` one of |
| -OPS-163 to OPS-175; `<requester>` the run package's line for a service's run. |
| +OPS-163 to OPS-175; `<requester>` the run package's line for a service's run; `<files>` and |
| +`<name>` uploaded file names; `<detail>` the box's explanation of a result. |
| ## The person page |
| @@ -68,7 +69,7 @@ OPS-163 to OPS-175; `<requester>` the run package's line for a service's run. |
| | OPS-172 | auditdetail.go (run-end, no result recorded) | Run ended | approved | |
| | OPS-173 | auditdetail.go (run-end, when it started and ended) | <run> after <duration> | approved | |
| | OPS-174 | auditdetail.go (run-end, when a box ran it) | <run> on <box> | approved | |
| -| OPS-175 | auditdetail.go (run-end, output cut off) | <run>. Its output was larger than 64 MB and was cut off | approved | |
| +| OPS-175 | auditdetail.go (run-end, output cut off) | <run>. Its output was cut off | approved | |
| | OPS-176 | auditdetail.go (any other row that stored data, with the data below it) | Recorded <action> | approved | |
| ## A service's run |
| @@ -85,3 +86,24 @@ lower-case line stays exactly as approved; its text is applied verbatim. |
| | id | file | text | status | |
| |---|---|---|---| |
| | OPS-177 | auditdetail.go (a service's run-start or run-end) | <sentence>. <requester> | approved | |
| + |
| +## Review fixes |
| + |
| +Astra's review (round 1, READY AFTER FIXES) found that the sentences |
| +dropped facts the stored rows showed, and that OPS-175 named a cause the |
| +result does not establish: a run's output is also cut off when its upload |
| +to storage fails. OPS-175 now states the cut-off alone. A run-start row |
| +keeps the files the run uploaded (OPS-178, each OPS-179); a run-end row |
| +keeps the box's own explanation (OPS-180), such as why an instance did not |
| +wake; and a result with no exit code says so (OPS-181) rather than reading |
| +as exit code 0. |
| + |
| +Approved 2026-10-27 by a Luna check (`gpt-5.6-luna`, same house rules) of |
| +the five rows. Luna kept all five as drafted. |
| + |
| +| id | file | text | status | |
| +|---|---|---|---| |
| +| OPS-178 | auditdetail.go (run-start, files uploaded) | <sentence>. Uploaded <files> | approved | |
| +| OPS-179 | auditdetail.go (one uploaded file; <files> is these joined by commas) | <name> (<n> bytes) | approved | |
| +| OPS-180 | auditdetail.go (run-end, the box's explanation) | <run>. <detail> | approved | |
| +| OPS-181 | auditdetail.go (run-end, no exit code recorded) | Run ended with no exit code recorded | approved | |
diff --git a/internal/console/auditdetail.go b/internal/console/auditdetail.go| index 5aa35c694..912b28e20 100644 |
| --- a/internal/console/auditdetail.go |
| +++ b/internal/console/auditdetail.go |
| @@ -20,9 +20,9 @@ import ( |
| // apirunsfollow.go's auditRunEnd); they read as sentences built from it. Any |
| // other row whose Detail is a JSON object reads as a short summary, and the |
| // operator pages hold the data itself, indented, under it (copy record |
| -// 2026-10-27-operator-people-detail-copy.md, OPS-163 to OPS-177). |
| +// 2026-10-27-operator-people-detail-copy.md, OPS-163 to OPS-181). |
| -// The words (OPS-163 to OPS-177). The run-end heads but auditRunNotPickedUp |
| +// The words (OPS-163 to OPS-181). The run-end heads but auditRunNotPickedUp |
| // are sentences the tails (after, on, truncated) are appended to. |
| const ( |
| auditRunStart = "Started %s (%s)" |
| @@ -37,11 +37,18 @@ const ( |
| auditRunEnded = "Run ended" |
| auditRunAfter = "%s after %s" |
| auditRunOn = "%s on %s" |
| - auditRunTruncated = "%s. Its output was larger than 64 MB and was cut off" |
| + auditRunTruncated = "%s. Its output was cut off" |
| auditRecordedAction = "Recorded %s" |
| // auditRunRequester follows a service's run sentence with the run |
| // package's own line for it (runs.Request.ServiceLine). |
| auditRunRequester = "%s. %s" |
| + // Review fixes (OPS-178 to OPS-181): the files a run uploaded, each |
| + // with its size; the box's explanation of a result; a result with no |
| + // exit code. |
| + auditRunUploaded = "%s. Uploaded %s" |
| + auditRunFileSize = "%s (%s bytes)" |
| + auditRunDetail = "%s. %s" |
| + auditRunNoExit = "Run ended with no exit code recorded" |
| ) |
| // The rows the formatter reads, and how it lays them out. |
| @@ -60,7 +67,9 @@ const ( |
| // auditWhat is how one audit row's Detail shows. Text is the sentence, the |
| // summary or the stored text. Title, when set, is the whole of a Text long |
| // enough that a one-line cell may cut it. JSON, when set, is the stored |
| -// object indented, for a <details> under Text. |
| +// object indented, for a <details> under Text: every row that stored an |
| +// object keeps it there, a run row's sentence included, so nothing it |
| +// recorded is out of an operator's reach. |
| type auditWhat struct { |
| Text, Title, JSON string |
| } |
| @@ -68,16 +77,17 @@ type auditWhat struct { |
| // auditWhatOf is how the row with action and detail shows. |
| func auditWhatOf(action, detail string) auditWhat { |
| var w auditWhat |
| - switch text, ok := auditRunSentence(action, detail); { |
| - case ok: |
| - w.Text = text |
| - case auditJSONObject(detail): |
| - w.Text = fmt.Sprintf(auditRecordedAction, action) |
| + if auditJSONObject(detail) { |
| var buf bytes.Buffer |
| if json.Indent(&buf, []byte(strings.TrimSpace(detail)), "", auditJSONIndent) == nil { |
| w.JSON = buf.String() |
| } |
| - return w |
| + } |
| + switch text, ok := auditRunSentence(action, detail); { |
| + case ok: |
| + w.Text = text |
| + case w.JSON != "": |
| + w.Text = fmt.Sprintf(auditRecordedAction, action) |
| default: |
| w.Text = detail |
| } |
| @@ -88,7 +98,9 @@ func auditWhatOf(action, detail string) auditWhat { |
| } |
| // auditText is auditWhatOf's Text: the words alone, for the customer |
| -// console's lists, which show a row's text and nothing else. |
| +// console's lists, which show a row's text and nothing else. A run row's |
| +// sentence keeps the facts those lists showed in its stored JSON: the |
| +// files the run uploaded and the box's own explanation of its result. |
| func auditText(action, detail string) string { return auditWhatOf(action, detail).Text } |
| // auditJSONObject reports whether detail is one JSON object. |
| @@ -101,6 +113,12 @@ func auditJSONObject(detail string) bool { |
| return json.Unmarshal([]byte(d), &v) == nil |
| } |
| +// auditRunFile is one file a run-start row records (runStartDetail). |
| +type auditRunFile struct { |
| + Name string `json:"name"` |
| + Size int64 `json:"size"` |
| +} |
| + |
| // auditRunSentence is the sentence of a run-start or run-end row whose |
| // Detail reads as the JSON that row stores; ok is false for any other row, |
| // and for one whose Detail does not read. |
| @@ -108,9 +126,10 @@ func auditRunSentence(action, detail string) (string, bool) { |
| switch action { |
| case auditActionRunStart: |
| var d struct { |
| - Argv []string `json:"argv"` |
| - Version string `json:"version"` |
| - Requester string `json:"requester"` |
| + Argv []string `json:"argv"` |
| + Files []auditRunFile `json:"files"` |
| + Version string `json:"version"` |
| + Requester string `json:"requester"` |
| } |
| if json.Unmarshal([]byte(detail), &d) != nil || len(d.Argv) == 0 { |
| return "", false |
| @@ -120,17 +139,36 @@ func auditRunSentence(action, detail string) (string, bool) { |
| if d.Version == "" { |
| s = fmt.Sprintf(auditRunStartBare, command) |
| } |
| + if len(d.Files) > 0 { |
| + files := make([]string, 0, len(d.Files)) |
| + for _, f := range d.Files { |
| + files = append(files, fmt.Sprintf(auditRunFileSize, f.Name, opNumber(int(f.Size)))) |
| + } |
| + s = fmt.Sprintf(auditRunUploaded, s, strings.Join(files, ", ")) |
| + } |
| return auditRunBy(s, d.Requester), true |
| case auditActionRunEnd: |
| var d struct { |
| - Outcome string `json:"outcome"` |
| - Result *runs.Result `json:"result"` |
| - Requester string `json:"requester"` |
| + Outcome string `json:"outcome"` |
| + Result json.RawMessage `json:"result"` |
| + Requester string `json:"requester"` |
| } |
| if json.Unmarshal([]byte(detail), &d) != nil || d.Outcome == "" { |
| return "", false |
| } |
| - return auditRunBy(auditRunEndSentence(d.Outcome, d.Result), d.Requester), true |
| + // The result as recorded, and whether it holds an exit code at |
| + // all: runs.Result reads a missing or null exit as 0. |
| + var res *runs.Result |
| + var exit struct { |
| + Exit *int `json:"exit"` |
| + } |
| + if len(d.Result) > 0 && string(d.Result) != "null" { |
| + res = new(runs.Result) |
| + if json.Unmarshal(d.Result, res) != nil || json.Unmarshal(d.Result, &exit) != nil { |
| + return "", false |
| + } |
| + } |
| + return auditRunBy(auditRunEndSentence(d.Outcome, res, exit.Exit != nil), d.Requester), true |
| } |
| return "", false |
| } |
| @@ -147,9 +185,12 @@ func auditRunBy(sentence, requester string) string { |
| // auditRunEndSentence is a run-end row's sentence: how the run ended (the |
| // CLI's runExit order: refused, cancelled, timed out, interrupted, a |
| // signal, an exit code), how long it ran when it started and ended, the |
| -// box that ran it, and whether its output was cut off. outcome is |
| -// auditRunEnd's (runEndOutcome); res is nil when no result was recorded. |
| -func auditRunEndSentence(outcome string, res *runs.Result) string { |
| +// box that ran it, the box's own explanation, and whether its output was |
| +// cut off (which says nothing of why: a full output and a failed upload |
| +// both cut it). outcome is auditRunEnd's (runEndOutcome); res is nil when |
| +// no result was recorded; exitKnown says whether res records an exit code, |
| +// and a result that ended without one never reads as exit code 0. |
| +func auditRunEndSentence(outcome string, res *runs.Result, exitKnown bool) string { |
| if res == nil { |
| switch outcome { |
| case provision.RunExpired: |
| @@ -175,8 +216,10 @@ func auditRunEndSentence(outcome string, res *runs.Result) string { |
| s = fmt.Sprintf(auditRunInterrupted, res.Interrupted) |
| case res.Signal != "": |
| s = fmt.Sprintf(auditRunSignal, res.Signal) |
| - case outcome == auditRunOutcomeEnded || outcome == "": |
| + case (outcome == auditRunOutcomeEnded || outcome == "") && exitKnown: |
| s = fmt.Sprintf(auditRunExit, res.Exit) |
| + case outcome == auditRunOutcomeEnded || outcome == "": |
| + s = auditRunNoExit |
| default: |
| s = auditRunEnded |
| } |
| @@ -186,6 +229,9 @@ func auditRunEndSentence(outcome string, res *runs.Result) string { |
| if res.Box != "" { |
| s = fmt.Sprintf(auditRunOn, s, res.Box) |
| } |
| + if res.Detail != "" { |
| + s = fmt.Sprintf(auditRunDetail, s, res.Detail) |
| + } |
| if res.Truncated { |
| s = fmt.Sprintf(auditRunTruncated, s) |
| } |
diff --git a/internal/console/auditdetail_test.go b/internal/console/auditdetail_test.go| index 390bf9325..721a71e77 100644 |
| --- a/internal/console/auditdetail_test.go |
| +++ b/internal/console/auditdetail_test.go |
| @@ -1,6 +1,7 @@ |
| package console |
| import ( |
| + "bytes" |
| "encoding/json" |
| "html" |
| "net/http" |
| @@ -77,12 +78,35 @@ func TestAuditWhatOfRunRows(t *testing.T) { |
| `{"id":"r-1","outcome":"result","result":{"exit":0},"requester":"run by service ci (scheduled)"}`, |
| "Run ended with exit code 0. run by service ci (scheduled)"}, |
| {"output cut off", "run-end", runEndJSON(t, "result", ran(runs.Result{Exit: 0, Truncated: true})), |
| - "Run ended with exit code 0 after 2m3s on uk-1. Its output was larger than 64 MB and was cut off"}, |
| + "Run ended with exit code 0 after 2m3s on uk-1. Its output was cut off"}, |
| + // The shape a run whose every output upload failed leaves |
| + // (internal/host's TestRunOutputIsBoundedWhenEveryChunkFails): a |
| + // few bytes of output, nothing stored, cut off. No cause is named. |
| + {"output uploads failed", "run-end", runEndJSON(t, "result", &runs.Result{Exit: 1, Truncated: true, LastSeq: 0, Box: "uk-1"}), |
| + "Run ended with exit code 1 on uk-1. Its output was cut off"}, |
| + {"files uploaded", "run-start", |
| + runStartDetail(runs.Request{ID: "r-1", Argv: []string{"import", "x.csv"}, |
| + Files: []runs.File{{Name: "x.csv", Size: 1234}, {Name: "notes.txt", Size: 7}}}, "v2"), |
| + "Started import x.csv (v2). Uploaded x.csv (1,234 bytes), notes.txt (7 bytes)"}, |
| + {"a refusal with the box's explanation", "run-end", |
| + runEndJSON(t, "result", &runs.Result{Refused: runs.RefusedWake, Detail: "the instance stopped while it was waking", Box: "uk-1"}), |
| + "Run was refused (wake) on uk-1. the instance stopped while it was waking"}, |
| + {"no exit field", "run-end", `{"id":"r-1","outcome":"result","result":{}}`, |
| + "Run ended with no exit code recorded"}, |
| + {"a null exit", "run-end", `{"id":"r-1","outcome":"result","result":{"exit":null,"box":"uk-1"}}`, |
| + "Run ended with no exit code recorded on uk-1"}, |
| + {"an explicit exit 0", "run-end", `{"id":"r-1","outcome":"result","result":{"exit":0}}`, |
| + "Run ended with exit code 0"}, |
| } { |
| t.Run(c.name, func(t *testing.T) { |
| w := auditWhatOf(c.action, c.detail) |
| - if w.Text != c.want || w.JSON != "" { |
| - t.Errorf("auditWhatOf(%s, %s) = %+v, want %q and no JSON", c.action, c.detail, w, c.want) |
| + if w.Text != c.want { |
| + t.Errorf("auditWhatOf(%s, %s) = %+v, want %q", c.action, c.detail, w, c.want) |
| + } |
| + // The operator pages keep everything the row recorded. |
| + var want bytes.Buffer |
| + if err := json.Indent(&want, []byte(c.detail), "", " "); err != nil || w.JSON != want.String() { |
| + t.Errorf("auditWhatOf(%s, %s).JSON = %q, want the row's JSON indented", c.action, c.detail, w.JSON) |
| } |
| if got := auditText(c.action, c.detail); got != c.want { |
| t.Errorf("auditText = %q, want %q", got, c.want) |
| @@ -165,7 +189,8 @@ func TestRunRowsReadAsSentences(t *testing.T) { |
| fx.setUser("paul@keymail.dev") // runFixture's last sign-in was alice's |
| c := signInOperator(t, fx.consoleFixture) |
| pages := map[string]string{} |
| - for _, path := range []string{fx.u("/apps/shop/activity"), fx.u("/apps/shop"), fx.ts.URL + "/fleet/activity"} { |
| + operator := fx.ts.URL + "/fleet/activity" |
| + for _, path := range []string{fx.u("/apps/shop/activity"), fx.u("/apps/shop"), operator} { |
| status, _, body := get(t, c, path) |
| if status != http.StatusOK { |
| t.Fatalf("GET %s = %d", path, status) |
| @@ -178,6 +203,15 @@ func TestRunRowsReadAsSentences(t *testing.T) { |
| t.Errorf("%s has no %q", path, want) |
| } |
| } |
| + if path == operator { |
| + // The sentence opens onto everything the row recorded. |
| + for _, want := range []string{"<details co-what><summary>Started import x.csv", ""argv": [", ""outcome": "result""} { |
| + if !strings.Contains(body, want) { |
| + t.Errorf("%s has no %q", path, want) |
| + } |
| + } |
| + continue |
| + } |
| if strings.Contains(body, `"argv"`) || strings.Contains(body, `"outcome"`) || strings.Contains(body, `"argv"`) { |
| t.Errorf("%s shows a run row's JSON", path) |
| } |
diff --git a/internal/console/opperson.go b/internal/console/opperson.go| index 55a3bcea8..e0fd45ce6 100644 |
| --- a/internal/console/opperson.go |
| +++ b/internal/console/opperson.go |
| @@ -51,17 +51,22 @@ func opCanonicalAddress(address string) string { |
| } |
| // operatorPersonNamed is the person an operator's URL names: the users row |
| -// with the address in its stored, lower-cased form, else the row with the |
| -// address exactly as given (a row made before addresses were lower-cased |
| -// keeps its own case, and its links carry it). nil when neither exists. |
| +// with exactly that address when there is one (every link the pages build |
| +// carries a row's stored address, so a row made before addresses were |
| +// lower-cased is reached by its own link even beside a lower-cased twin), |
| +// else the row with the address lower-cased, as canonicalAddress stores a |
| +// typed one. nil when neither exists. |
| func (s *Server) operatorPersonNamed(address string) (*PersonDetail, error) { |
| - canon := opCanonicalAddress(address) |
| - p, err := s.store.OperatorPerson(canon) |
| + raw := strings.TrimSpace(address) |
| + if raw == "" { |
| + return nil, nil |
| + } |
| + p, err := s.store.OperatorPerson(raw) |
| if err != nil || p != nil { |
| return p, err |
| } |
| - if raw := strings.TrimSpace(address); raw != canon && raw != "" { |
| - return s.store.OperatorPerson(raw) |
| + if canon := opCanonicalAddress(raw); canon != raw { |
| + return s.store.OperatorPerson(canon) |
| } |
| return nil, nil |
| } |
diff --git a/internal/console/opperson_test.go b/internal/console/opperson_test.go| index 3a00bfcdc..ebfd1400d 100644 |
| --- a/internal/console/opperson_test.go |
| +++ b/internal/console/opperson_test.go |
| @@ -5,6 +5,7 @@ import ( |
| "html" |
| "net/http" |
| "regexp" |
| + "slices" |
| "strings" |
| "testing" |
| "time" |
| @@ -317,3 +318,47 @@ func TestActivityFiltersByPerson(t *testing.T) { |
| t.Error("an unknown person's feed is not empty") |
| } |
| } |
| + |
| +// TestPersonLookupPrefersTheExactAddress: a row made before addresses were |
| +// lower-cased (Ann@example.com) beside its lower-cased twin: each one's own |
| +// link, on the person page and in Activity's ?who=, reaches that row, and |
| +// a case no row has falls back to the lower-cased one. |
| +func TestPersonLookupPrefersTheExactAddress(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + w := seedOperatorWorld(t, fx) |
| + const legacy = "Ann@example.com" |
| + if _, err := fx.st.EnsureUser(legacy, w.now.Add(-time.Hour)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := fx.st.AddMember(w.notes.ID, legacy, RoleMember, w.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := fx.st.RecordActivity(w.notes.ID, "notes", legacy, Activity{Action: "rename", Detail: "Renamed by the legacy row"}, w.now); err != nil { |
| + t.Fatal(err) |
| + } |
| + shopLink := fmt.Sprintf(`href="/fleet/activity?account=%s">shop</a>`, w.shop.Sqid) |
| + notesLink := fmt.Sprintf(`href="/fleet/activity?account=%s">notes</a>`, w.notes.Sqid) |
| + for _, c := range []struct { |
| + path, h1, has, hasNot, did, didNot string |
| + }{ |
| + {legacy, legacy, notesLink, shopLink, "Renamed by the legacy row", "Made v2 live"}, |
| + {"ann@example.com", "ann@example.com", shopLink, notesLink, "Made v2 live", "Renamed by the legacy row"}, |
| + {"ANN@example.com", "ann@example.com", shopLink, notesLink, "Made v2 live", "Renamed by the legacy row"}, |
| + } { |
| + body := personGet(t, fx, w.c, c.path) |
| + accounts := personSection(t, body, "Accounts") |
| + activity := personSection(t, body, "Latest activity") |
| + if !strings.Contains(body, "<h1>"+c.h1+"</h1>") || !strings.Contains(accounts, c.has) || strings.Contains(accounts, c.hasNot) || |
| + !strings.Contains(activity, c.did) || strings.Contains(activity, c.didNot) { |
| + t.Errorf("/fleet/people/%s is not %s's page:\n%s", c.path, c.h1, body) |
| + } |
| + whos := feedWhats(feedRows(t, peopleGet(t, fx, w.c, "/fleet/activity?who="+c.path))) |
| + if !slices.Contains(whos, c.did) || slices.Contains(whos, c.didNot) { |
| + t.Errorf("?who=%s shows %q, want %s's rows", c.path, whos, c.h1) |
| + } |
| + } |
| + // The People list's link for the legacy row carries its own case. |
| + if !strings.Contains(peopleGet(t, fx, w.c, "/fleet/people"), `<a class="rst-nm" href="/fleet/people/Ann@example.com">Ann@example.com</a>`) { |
| + t.Error("People does not link the legacy row by its stored address") |
| + } |
| +} |
diff --git a/internal/console/templates/opparts.html b/internal/console/templates/opparts.html| index d89dfe929..ad4ec960a 100644 |
| --- a/internal/console/templates/opparts.html |
| +++ b/internal/console/templates/opparts.html |
| @@ -104,5 +104,6 @@ |
| {{/* An audit row's What (a FeedRow): its sentence or stored text on one |
| line, cut with its whole text in title when long; or, for a row that |
| - stored data, a summary that opens onto the data (auditdetail.go). */}} |
| -{{define "op_what"}}{{with opWhat .Action .Detail}}{{if .JSON}}<details co-what><summary>{{.Text}}</summary><pre>{{.JSON}}</pre></details>{{else}}<span co-clip{{with .Title}} title="{{.}}"{{end}}>{{.Text}}</span>{{end}}{{end}}{{end}} |
| + stored data (a run row included), its sentence or summary opening onto |
| + the data (auditdetail.go). */}} |
| +{{define "op_what"}}{{with opWhat .Action .Detail}}{{if .JSON}}<details co-what><summary{{with .Title}} title="{{.}}"{{end}}>{{.Text}}</summary><pre>{{.JSON}}</pre></details>{{else}}<span co-clip{{with .Title}} title="{{.}}"{{end}}>{{.Text}}</span>{{end}}{{end}}{{end}} |