summaryrefslogtreecommitdiff
path: root/internal/tui/entries_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-04 13:58:36 +0200
committerPaul Buetow <paul@buetow.org>2026-03-04 13:58:36 +0200
commitb547dc4372175bc54ca3bfdeb215b9734987c669 (patch)
tree758a4c302ec1eca8502e6f02280c64941e0fd635 /internal/tui/entries_test.go
parent0df060769b7f43fa0cd7c5ed81992f122d7af8a9 (diff)
tui: fix entry editing keys and show session durationsv0.6.0
Bump version to v0.6.0.
Diffstat (limited to 'internal/tui/entries_test.go')
-rw-r--r--internal/tui/entries_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/tui/entries_test.go b/internal/tui/entries_test.go
index f8f9378..e1541a0 100644
--- a/internal/tui/entries_test.go
+++ b/internal/tui/entries_test.go
@@ -202,6 +202,44 @@ func TestEntriesEditFlow(t *testing.T) {
}
}
+func TestEntriesEditModeAcceptsSpaceKey(t *testing.T) {
+ model := NewEntriesModel(sampleEntries(1))
+ model.editMode = true
+ model.input = "hello"
+
+ model, _ = model.Update(tea.KeyMsg{Type: tea.KeySpace})
+ if model.input != "hello " {
+ t.Fatalf("input after space = %q, want %q", model.input, "hello ")
+ }
+}
+
+func TestEntriesValueShowsSessionDurationForLoginLogoutPairs(t *testing.T) {
+ entries := []worktime.Entry{
+ {
+ Action: "login",
+ What: "work",
+ Epoch: localEpoch(2026, 1, 5, 9),
+ Source: "host-a",
+ Human: time.Unix(localEpoch(2026, 1, 5, 9), 0).Format("Mon 02.01.2006 15:04:05"),
+ },
+ {
+ Action: "logout",
+ What: "work",
+ Epoch: localEpoch(2026, 1, 5, 11),
+ Source: "host-a",
+ Human: time.Unix(localEpoch(2026, 1, 5, 11), 0).Format("Mon 02.01.2006 15:04:05"),
+ },
+ }
+
+ model := NewEntriesModel(entries)
+ model.SetSize(120, 12)
+
+ table := model.renderTimelineTable(DefaultStyles())
+ if count := strings.Count(table, "+2.00h"); count != 2 {
+ t.Fatalf("rendered session duration count = %d, want 2 in table:\n%s", count, table)
+ }
+}
+
func TestEntriesValueEditFlow(t *testing.T) {
model := NewEntriesModel(sampleEntries(3))
model.SetSize(120, 12)