@@ -36,23 +36,112 @@ func TestCardLifecycle(t *testing.T) {
3636 h := newHarness (t )
3737 num := createCard (t , h , fixture .BoardID )
3838 numStr := strconv .Itoa (num )
39+ currentUser := currentUserID (t , h )
40+ updatedTitle := "Updated Card"
41+ tagTitle := "cli-test"
42+
43+ assertOK (t , h .Run ("card" , "update" , numStr , "--title" , updatedTitle ))
44+ show := h .Run ("card" , "show" , numStr )
45+ assertOK (t , show )
46+ if got := show .GetDataString ("title" ); got != updatedTitle {
47+ t .Fatalf ("expected updated title %q, got %q" , updatedTitle , got )
48+ }
3949
40- assertOK (t , h .Run ("card" , "update" , numStr , "--title" , "Updated Card" ))
4150 assertOK (t , h .Run ("card" , "column" , numStr , "--column" , fixture .ColumnID ))
51+ show = h .Run ("card" , "show" , numStr )
52+ assertOK (t , show )
53+ if got := mapValueString (asMap (show .GetDataMap ()["column" ]), "id" ); got != fixture .ColumnID {
54+ t .Fatalf ("expected card column %q, got %q" , fixture .ColumnID , got )
55+ }
56+
57+ // Watch/unwatch currently have no CLI readback path on card show/list.
4258 assertOK (t , h .Run ("card" , "watch" , numStr ))
4359 assertOK (t , h .Run ("card" , "unwatch" , numStr ))
60+
61+ // Mark-read/mark-unread likewise have no card-scoped CLI readback state today.
4462 assertOK (t , h .Run ("card" , "mark-read" , numStr ))
4563 assertOK (t , h .Run ("card" , "mark-unread" , numStr ))
64+
4665 assertOK (t , h .Run ("card" , "pin" , numStr ))
66+ pins := h .Run ("pin" , "list" )
67+ assertOK (t , pins )
68+ if listMapByNumber (pins .GetDataArray (), num ) == nil {
69+ t .Fatalf ("expected pin list to include card #%d after pin" , num )
70+ }
4771 assertOK (t , h .Run ("card" , "unpin" , numStr ))
72+ pins = h .Run ("pin" , "list" )
73+ assertOK (t , pins )
74+ if listMapByNumber (pins .GetDataArray (), num ) != nil {
75+ t .Fatalf ("expected pin list to exclude card #%d after unpin" , num )
76+ }
77+
4878 assertOK (t , h .Run ("card" , "golden" , numStr ))
79+ show = h .Run ("card" , "show" , numStr )
80+ assertOK (t , show )
81+ if ! show .GetDataBool ("golden" ) {
82+ t .Fatal ("expected card to be golden after golden command" )
83+ }
4984 assertOK (t , h .Run ("card" , "ungolden" , numStr ))
50- assertOK (t , h .Run ("card" , "tag" , numStr , "--tag" , "cli-test" ))
85+ show = h .Run ("card" , "show" , numStr )
86+ assertOK (t , show )
87+ if show .GetDataBool ("golden" ) {
88+ t .Fatal ("expected card to no longer be golden after ungolden command" )
89+ }
90+
91+ assertOK (t , h .Run ("card" , "tag" , numStr , "--tag" , tagTitle ))
92+ tags := h .Run ("tag" , "list" )
93+ assertOK (t , tags )
94+ var tagID string
95+ for _ , item := range tags .GetDataArray () {
96+ m := asMap (item )
97+ if mapValueString (m , "title" ) == tagTitle {
98+ tagID = mapValueString (m , "id" )
99+ break
100+ }
101+ }
102+ if tagID == "" {
103+ t .Fatalf ("expected tag list to include %q" , tagTitle )
104+ }
105+ taggedCards := h .Run ("card" , "list" , "--tag" , tagID )
106+ assertOK (t , taggedCards )
107+ if listMapByNumber (taggedCards .GetDataArray (), num ) == nil {
108+ t .Fatalf ("expected card list for tag %q to include card #%d" , tagTitle , num )
109+ }
110+
51111 assertOK (t , h .Run ("card" , "self-assign" , numStr ))
112+ show = h .Run ("card" , "show" , numStr )
113+ assertOK (t , show )
114+ if listMapByID (asSlice (show .GetDataMap ()["assignees" ]), currentUser ) == nil {
115+ t .Fatalf ("expected assignees to include current user %q" , currentUser )
116+ }
117+
52118 assertOK (t , h .Run ("card" , "close" , numStr ))
119+ show = h .Run ("card" , "show" , numStr )
120+ assertOK (t , show )
121+ if ! show .GetDataBool ("closed" ) {
122+ t .Fatal ("expected card to be closed after close command" )
123+ }
124+
53125 assertOK (t , h .Run ("card" , "reopen" , numStr ))
126+ show = h .Run ("card" , "show" , numStr )
127+ assertOK (t , show )
128+ if show .GetDataBool ("closed" ) {
129+ t .Fatal ("expected card to be open after reopen command" )
130+ }
131+
54132 assertOK (t , h .Run ("card" , "postpone" , numStr ))
133+ show = h .Run ("card" , "show" , numStr )
134+ assertOK (t , show )
135+ if ! show .GetDataBool ("postponed" ) {
136+ t .Fatal ("expected card to be postponed after postpone command" )
137+ }
138+
55139 assertOK (t , h .Run ("card" , "untriage" , numStr ))
140+ show = h .Run ("card" , "show" , numStr )
141+ assertOK (t , show )
142+ if show .GetDataBool ("postponed" ) {
143+ t .Fatal ("expected card to no longer be postponed after untriage command" )
144+ }
56145}
57146
58147func TestCardAssignToCurrentUser (t * testing.T ) {
@@ -115,6 +204,11 @@ func TestCardMoveBetweenBoards(t *testing.T) {
115204 destinationBoardID := createBoard (t , h )
116205 num := createCard (t , h , fixture .BoardID )
117206 assertOK (t , h .Run ("card" , "move" , strconv .Itoa (num ), "--to" , destinationBoardID ))
207+ show := h .Run ("card" , "show" , strconv .Itoa (num ))
208+ assertOK (t , show )
209+ if got := mapValueString (asMap (show .GetDataMap ()["board" ]), "id" ); got != destinationBoardID {
210+ t .Fatalf ("expected moved card board %q, got %q" , destinationBoardID , got )
211+ }
118212}
119213
120214func TestCardAttachmentsShow (t * testing.T ) {
@@ -124,7 +218,12 @@ func TestCardAttachmentsShow(t *testing.T) {
124218func TestCardDelete (t * testing.T ) {
125219 h := newHarness (t )
126220 num := createCard (t , h , fixture .BoardID )
127- assertOK (t , h .Run ("card" , "delete" , strconv .Itoa (num )))
221+ deleteResult := h .Run ("card" , "delete" , strconv .Itoa (num ))
222+ assertOK (t , deleteResult )
223+ if ! deleteResult .GetDataBool ("deleted" ) {
224+ t .Fatal ("expected deleted=true" )
225+ }
226+ assertResult (t , h .Run ("card" , "show" , strconv .Itoa (num )), harness .ExitNotFound )
128227}
129228
130229func TestCardCreateRoundTrip (t * testing.T ) {
@@ -141,8 +240,11 @@ func TestCardCreateRoundTrip(t *testing.T) {
141240 t .Cleanup (func () { newHarness (t ).Run ("card" , "delete" , strconv .Itoa (num )) })
142241 show := h .Run ("card" , "show" , strconv .Itoa (num ))
143242 assertOK (t , show )
144- if title := show .GetDataString ("title" ); title == "" {
145- t .Fatal ("expected title in card show response" )
243+ if got := show .GetDataString ("title" ); got != "Round Trip Card" {
244+ t .Fatalf ("expected card title %q, got %q" , "Round Trip Card" , got )
245+ }
246+ if got := mapValueString (asMap (show .GetDataMap ()["board" ]), "id" ); got != fixture .BoardID {
247+ t .Fatalf ("expected card board %q, got %q" , fixture .BoardID , got )
146248 }
147249}
148250
@@ -159,4 +261,9 @@ func TestCardCreateWithUniqueTitle(t *testing.T) {
159261 t .Fatal ("no card number in create response" )
160262 }
161263 t .Cleanup (func () { newHarness (t ).Run ("card" , "delete" , strconv .Itoa (num )) })
264+ show := h .Run ("card" , "show" , strconv .Itoa (num ))
265+ assertOK (t , show )
266+ if got := show .GetDataString ("title" ); got != title {
267+ t .Fatalf ("expected card title %q, got %q" , title , got )
268+ }
162269}
0 commit comments