Allow editing time entry start and end in TUI and web.
Duration is derived from the range so timer sessions can be corrected after the fact. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"task/internal/ticket"
|
||||
)
|
||||
|
||||
func TestTimeEditFormParse(t *testing.T) {
|
||||
start := time.Date(2024, 6, 1, 9, 0, 0, 0, time.Local)
|
||||
end := start.Add(90 * time.Minute)
|
||||
f := NewTimeEditForm(ticket.TimeEntry{Start: start, End: end, Duration: 90 * time.Minute}, 80)
|
||||
|
||||
gotStart, gotEnd, err := f.Parse()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !gotStart.Equal(start.UTC()) {
|
||||
t.Fatalf("start: got %v want %v", gotStart, start.UTC())
|
||||
}
|
||||
if !gotEnd.Equal(end.UTC()) {
|
||||
t.Fatalf("end: got %v want %v", gotEnd, end.UTC())
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeEditFormRejectsBadRange(t *testing.T) {
|
||||
start := time.Date(2024, 6, 1, 9, 0, 0, 0, time.Local)
|
||||
f := NewTimeEditForm(ticket.TimeEntry{Start: start, End: start, Duration: time.Minute}, 80)
|
||||
f.Inputs[FieldTimeEnd].SetValue(start.Format(timeEditLayout))
|
||||
if _, _, err := f.Parse(); err == nil {
|
||||
t.Fatal("expected error for end == start")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user