okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawntui: replace the generic /quota page with a screen of latest limits, bars and per-limit trails8e3e173

main
1.3 KiB40 linesraw
1//go:build unix
2
3// /quota crosses the composer, the quota screen, the client's read of the
4// daemon's /server route and the daemon's own answer. A fixed Server fixture
5// cannot show the client decoding what the daemon really sends: a hermetic
6// daemon has no accounts to poll, so the screen must say so and still leave.
7package e2e
8
9import (
10	"strings"
11	"testing"
12
13	"albedo/cli/internal/tui"
14
15	tea "charm.land/bubbletea/v2"
16)
17
18func TestTUIQuotaOpensOnTheDaemonsReadingsAndLeaves(t *testing.T) {
19	providerRoute(t, echoReply)
20	t.Parallel()
21	d := newTUIDriver(t)
22	d.Update(tea.WindowSizeMsg{Width: 120, Height: 30})
23
24	d.App.Chat.TextArea.SetValue("/quota")
25	d.Dispatch(tea.KeyPressMsg{Code: tea.KeyEnter})
26	if d.App.State != tui.AppStateQuota {
27		t.Fatalf("/quota did not open the quota screen:\n%s", d.View())
28	}
29	if d.App.Quota.Loading || d.App.Quota.Error != "" {
30		t.Fatalf("the quota read did not settle (loading %v, error %q):\n%s", d.App.Quota.Loading, d.App.Quota.Error, d.View())
31	}
32	if view := d.View(); !strings.Contains(view, "No quota readings yet") {
33		t.Fatalf("a daemon with no accounts should say there are no readings:\n%s", view)
34	}
35
36	d.Dispatch(tea.KeyPressMsg{Code: tea.KeyEscape})
37	if d.App.State != tui.AppStateChat {
38		t.Fatalf("esc did not return to the chat:\n%s", d.View())
39	}
40}