8000 ✨ enhance dashboard ui by abahmed · Pull Request #610 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ level you pick through the browser's push service (Web Push, encrypted
for that browser), so they arrive with every dashboard tab closed and
stay on screen until closed. They are for confirmed issues only: an
issue still settling is told once it is confirmed, and one that settles
before alerting is never told, neither new nor resolved. **Send a test notification** checks the
before alerting is never told, neither new nor resolved. With browser
alerts off a tab reads nothing for them. **Send a test notification** checks the
path. Signing out, turning them off, 30 days unseen or a new password
stops them; at most 100 browsers are kept. A service worker (`/sw.js`)
shows them and caches nothing.
Expand Down Expand Up @@ -159,16 +160,19 @@ low" (each part opens that level's issues); it is red only while
something is urgent, amber while something needs attention, and calm
otherwise. **Look at these first** lists up to five issues, most urgent
first and then the longest running, each with a short cause, where it
is, its level and how long ago it started. **Bad releases and changes
that caused issues** joins the releases of the last 24 hours that
failed, went down or got worse with the active issues that started right
after a change; it shows only when there is one. **This week** has four
numbers, all over the issues someone was alerted about (alerted,
resolved, the urgent issues that alerted the on-call person, the median
time to resolve an alerted issue), one line saying how many issues
settled on their own before anyone was alerted, the day-by-day chart, and
the top causes beside where the trouble is, each number saying what it
counts ("105 issues this week").
is, its level and how long ago it started. **Bad releases (last 24 h)
and changes behind active issues** joins the releases of the last 24
hours that failed, went down or got worse with the active issues that
started right after a change; each release links the issue it opened
(resolved or not), or says none opened in the 30 minutes after it and
links its workload's issues. It shows only when there is one. **This
week** has four numbers, all over the issues someone was alerted about
(alerted, resolved this week, the urgent issues that alerted the
on-call person, the median time to resolve those same resolved
issues), one line saying how many issues settled on their own before
anyone was alerted, the day-by-day chart, and the top causes beside
where the trouble is, each with a small colour key and each number
saying what it counts ("105 issues this week").

**Issues** (`/issues`) shows one toolbar row: the Active, Resolved and
All tabs, the search box and **Filters (N)**, which opens the other
Expand Down
376 changes: 312 additions & 64 deletions internal/dashboard/UI_NOTES.md

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions internal/dashboard/browser_changes_onset_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//go:build browser

package dashboard

import (
"strings"
"testing"
"time"

"github.com/chromedp/chromedp"
)

// "What changed just before" measures every change from the onset the
// server sorted it by, so a change labelled Before never reads "after
// it started", even when the issue first opened hours earlier. An
// automatic actor is marked as one.
func TestBrowserChangesMeasureFromTheOnset(t *testing.T) {
ago := func(d time.Duration) string {
return time.Now().Add(-d).UTC().Format(time.RFC3339)
}
d := stubDetail()
d["firstSeen"] = ago(10 * time.Hour)
d["onset"] = ago(40 * time.Minute)
d["changes"] = []map[string]any{
{"at": ago(50 * time.Minute), "when": "before",
"kind": "ConfigMap", "namespace": "shop", "name": "cfg",
"summary": "key A changed", "actor": "kubectl-edit"},
{"at": ago(20 * time.Minute), "when": "during",
"kind": "Node", "name": "node-1", "summary": "deleted",
"actor": "karpenter"}}
actx, _ := browserSetup(t)
srv := stubIssueServer(t, d)
tab, problems := browserTab(t, actx)
signInBrowser(t, tab, srv.URL)
err := chromedp.Do(tab, chromedp.EmulateViewport(1280, 900),
chromedp.Navigate(srv.URL+"/issues/stub-1#timeline"),
chromedp.WaitReady(chromedp.CSS(".cx-row")),
chromedp.Sleep(500*time.Millisecond))
if err != nil {
t.Fatal(err)
}
got, err := chromedp.Run(tab, chromedp.Evaluate[string](
`Array.from(document.querySelectorAll(
".cx-row, [data-changes] > .ev-cap")).
map((r) => r.textContent).join("\n")`))
if err != nil {
t.Fatal(err)
}
for _, want := range []string{
"Before", "10 min before it started failing",
"During", "20 min after it started failing",
"by karpenter (automatic)",
"Changes made to this object and what it uses",
"30 minutes before it started failing"} {
if !strings.Contains(got, want) {
t.Errorf("changes lack %q:\n%s", want, got)
}
}
for _, bad := range []string{"h 10 min after", "people made",
"kubectl-edit (automatic)"} {
if strings.Contains(got, bad) {
t.Errorf("changes say %q:\n%s", bad, got)
}
}
for _, p := range problems.take() {
t.Error(p)
}
}
9 changes: 5 additions & 4 deletions internal/dashboard/browser_issue_page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ func TestBrowserIssuePageIsPlain(t *testing.T) {
}
err := chromedp.Do(tab, chromedp.EmulateViewport(1280, 900),
chromedp.Navigate(srv.URL+"/issues/stub-1#timeline"),
chromedp.WaitVisible(chromedp.CSS(".ds-r-why")),
chromedp.WaitReady(chromedp.CSS(".ds-r-why")),
chromedp.WaitVisible(chromedp.CSS("[data-panel=timeline]")),
chromedp.Sleep(time.Second))
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -213,11 +214,11 @@ func TestBrowserIssuePagePhoneFits(t *testing.T) {
srv := stubIssueServer(t, stubDetail())
tab, _ := browserTab(t, actx)
signInBrowser(t, tab, srv.URL)
for _, key := range []string{"timeline", "evidence", "impact",
"alerts", "details"} {
for _, key := range []string{"summary", "timeline", "evidence",
"impact", "alerts", "details"} {
err := chromedp.Do(tab, chromedp.EmulateViewport(390, 844),
chromedp.Navigate(srv.URL+"/issues/stub-1#"+key),
chromedp.WaitVisible(chromedp.CSS(".ds-r-why")),
chromedp.WaitVisible(chromedp.CSS("[data-panel="+key+"]")),
chromedp.Sleep(time.Second))
if err != nil {
t.Fatal(err)
Expand Down
37 changes: 18 additions & 19 deletions internal/dashboard/browser_issue_polish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func polishPage(
}
}

// The heading is the short title; the whole one is a click away, and
// on a phone the heading takes three lines at most.
// The heading is the short title, and on a phone it takes three lines
// at most; the whole title is the description line under it, never cut,
// with no "Full title" fold.
func TestBrowserIssueHeadingIsShort(t *testing.T) {
srv := stubIssueServer(t, stubDetail())
text, done := polishPage(t, srv.URL, "/issues/stub-1",
Expand All @@ -49,8 +50,7 @@ func TestBrowserIssueHeadingIsShort(t *testing.T) {
got := text(`(() => { const h = document.querySelector("h1");
const lines = h.getBoundingClientRect().height /
parseFloat(getComputedStyle(h).lineHeight);
return h.textContent.length + "|" + Math.round(lines) + "|" +
h.title.length; })()`)
return h.textContent.length + "|" + Math.round(lines); })()`)
parts := strings.Split(got, "|")
if parts[0] == "" || len(stubTitle) <= atoiOr(parts[0]) ||
atoiOr(parts[0]) > 80 {
Expand All @@ -59,15 +59,13 @@ func TestBrowserIssueHeadingIsShort(t *testing.T) {
if atoiOr(parts[1]) > 3 {
t.Errorf("heading takes %s lines on a phone", parts[1])
}
if atoiOr(parts[2]) != len(stubTitle) {
t.Errorf("tooltip is not the whole title: %q", got)
}
if got := text(`(() => { const d = document.querySelector(
"[data-full-title]"); const open = d.open;
d.querySelector("summary").click();
return open + "|" + d.open + "|" + d.querySelector(".ds-full-t").
textContent; })()`); got != "false|true|"+stubTitle {
t.Errorf("the full title is not one click away: %q", got)
if got := text(`(() => {
const l = document.querySelector("[data-ds-lead]");
const cut = l.scrollWidth > l.clientWidth + 1;
return (document.querySelector("[data-full-title]") ? "fold|" : "") +
(l.hidden ? "hidden|" : "") + (cut ? "cut|" : "") + l.textContent;
})()`); got != stubTitle {
t.Errorf("the description line is %q, want the whole title", got)
}
}

Expand Down Expand Up @@ -170,12 +168,13 @@ func TestBrowserAlertsWhyThisLevel(t *testing.T) {
}
}

// The top card shows the acknowledge command, to copy, never a button
// that acts; once acknowledged it is gone.
func TestBrowserTopCardShowsAckCommand(t *testing.T) {
// Who was alerted?, at the top of the Alerts tab, shows the
// acknowledge command, to copy, never a button that acts; once
// acknowledged it is gone.
func TestBrowserAlertsTabShowsAckCommand(t *testing.T) {
srv := stubIssueServer(t, stubDetail())
text, done := polishPage(t, srv.URL, "/issues/stub-1",
".ds-r-told", 1280)
text, done := polishPage(t, srv.URL, "/issues/stub-1#alerts",
"[data-panel=alerts] > .ds-alerted .ds-r-told", 1280)
defer done()
got := text(`(() => { const r = document.querySelector(".ds-r-told");
const c = r.querySelector("code, .cmd");
Expand All @@ -189,7 +188,7 @@ func TestBrowserTopCardShowsAckCommand(t *testing.T) {
d["ack"] = map[string]any{"by": "sam", "on": "Deployment/shop/api",
"since": time.Now().Add(-time.Hour).UTC().Format(time.RFC3339)}
srv2 := stubIssueServer(t, d)
text2, done2 := polishPage(t, srv2.URL, "/issues/stub-1",
text2, done2 := polishPage(t, srv2.URL, "/issues/stub-1#alerts",
".ds-r-told", 1280)
defer done2()
got = text2(`document.querySelector(".ds-r-told").textContent`)
Expand Down
Loading
0