Wire manual Y menu and CLI sync for issues and work items, persist per-project credentials, and keep local edits until an explicit push. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package views_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"task/internal/project"
|
|
"task/internal/ui/views"
|
|
)
|
|
|
|
func TestProjectEditMetaKeepsToken(t *testing.T) {
|
|
prev := project.Meta{
|
|
YouTrack: &project.YouTrack{
|
|
BaseURL: "https://yt.example",
|
|
Token: "secret",
|
|
ProjectKey: "ABC",
|
|
},
|
|
}
|
|
f := views.NewProjectEditForm("inbox", prev, 80)
|
|
// Leave token blank → keep previous.
|
|
f.Inputs[views.FieldRemoteURL].SetValue("https://yt.example")
|
|
f.Inputs[views.FieldProjectKey].SetValue("ABC")
|
|
f.Inputs[views.FieldToken].SetValue("")
|
|
|
|
meta := f.Meta(prev)
|
|
if meta.YouTrack == nil || meta.YouTrack.Token != "secret" {
|
|
t.Fatalf("expected kept token, got %+v", meta.YouTrack)
|
|
}
|
|
if err := f.Validate(prev); err != nil {
|
|
t.Fatalf("Validate: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestProjectEditValidateIncomplete(t *testing.T) {
|
|
f := views.NewProjectEditForm("inbox", project.Meta{}, 80)
|
|
f.Inputs[views.FieldRemoteURL].SetValue("https://yt.example")
|
|
// missing token + key
|
|
if err := f.Validate(project.Meta{}); err == nil {
|
|
t.Fatal("expected incomplete error")
|
|
}
|
|
}
|