forked from davidjpnelson/linear-mcp-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tools.sh
More file actions
executable file
·1255 lines (1111 loc) · 54.7 KB
/
Copy pathtest_tools.sh
File metadata and controls
executable file
·1255 lines (1111 loc) · 54.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Comprehensive test harness for linear-mcp-rs
# Tests ALL 253 tools against a real Linear API via MCP stdio protocol.
#
# Usage: ./test_tools.sh [--tier N] [--tool TOOL_NAME] [--list-only] [--discover]
# --tier N Run only tier N tests (1=reads, 2=create+delete, 3=mutations, 4=updates)
# --tool NAME Run only the named tool test
# --list-only Just verify tools/list registration
# --discover Run workspace discovery
set -uo pipefail
BINARY="./target/release/linear-mcp"
PASS=0
FAIL=0
SKIP=0
ERRORS=()
TIER_FILTER=""
TOOL_FILTER=""
LIST_ONLY=false
DISCOVER=false
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
# Parse args
while [[ $# -gt 0 ]]; do
case $1 in
--tier) TIER_FILTER="$2"; shift 2 ;;
--tool) TOOL_FILTER="$2"; shift 2 ;;
--list-only) LIST_ONLY=true; shift ;;
--discover) DISCOVER=true; shift ;;
*) echo "Unknown arg: $1"; exit 1 ;;
esac
done
# ---- FIFO-based MCP Server Communication ----
TMPDIR_TEST=$(mktemp -d)
FIFO_IN="$TMPDIR_TEST/mcp_in"
FIFO_OUT="$TMPDIR_TEST/mcp_out"
mkfifo "$FIFO_IN" "$FIFO_OUT"
SERVER_PID=""
REQ_ID=1
cleanup() {
if [[ -n "$SERVER_PID" ]] && kill -0 "$SERVER_PID" 2>/dev/null; then
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
rm -rf "$TMPDIR_TEST"
}
trap cleanup EXIT
stop_server() {
# Close FDs if open
exec 3>&- 2>/dev/null || true
exec 4<&- 2>/dev/null || true
if [[ -n "$SERVER_PID" ]] && kill -0 "$SERVER_PID" 2>/dev/null; then
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
SERVER_PID=""
# Recreate FIFOs
rm -f "$FIFO_IN" "$FIFO_OUT"
mkfifo "$FIFO_IN" "$FIFO_OUT"
}
SERVER_LOG="$TMPDIR_TEST/server.log"
start_server() {
"$BINARY" < "$FIFO_IN" > "$FIFO_OUT" 2>"$SERVER_LOG" &
SERVER_PID=$!
sleep 0.5
exec 3>"$FIFO_IN"
exec 4<"$FIFO_OUT"
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo -e "${RED}ERROR: Server failed to start${NC}"
exit 1
fi
}
ensure_server() {
if [[ -z "$SERVER_PID" ]] || ! kill -0 "$SERVER_PID" 2>/dev/null; then
echo -e " ${YELLOW}(restarting server — PID $SERVER_PID dead)${NC}" >&2
if [[ -f "$SERVER_LOG" ]]; then
local last_lines
last_lines=$(tail -5 "$SERVER_LOG" 2>/dev/null)
if [[ -n "$last_lines" ]]; then
echo -e " ${YELLOW}Server log: $last_lines${NC}" >&2
fi
fi
stop_server
start_server
do_handshake >&2
fi
}
send_request() {
local method="$1"
local params="$2"
local id=$REQ_ID
REQ_ID=$((REQ_ID + 1))
local msg
if [[ "$params" == "null" ]]; then
msg="{\"jsonrpc\":\"2.0\",\"id\":$id,\"method\":\"$method\"}"
else
msg="{\"jsonrpc\":\"2.0\",\"id\":$id,\"method\":\"$method\",\"params\":$params}"
fi
if ! echo "$msg" >&3 2>/dev/null; then
ensure_server
echo "$msg" >&3 2>/dev/null
fi
}
send_notification() {
local method="$1"
local params="$2"
local msg
if [[ "$params" == "null" ]]; then
msg="{\"jsonrpc\":\"2.0\",\"method\":\"$method\"}"
else
msg="{\"jsonrpc\":\"2.0\",\"method\":\"$method\",\"params\":$params}"
fi
if ! echo "$msg" >&3 2>/dev/null; then
ensure_server
echo "$msg" >&3 2>/dev/null
fi
}
read_response() {
local timeout="${1:-15}"
local response=""
if read -t "$timeout" -r response <&4; then
echo "$response"
else
echo '{"error":"timeout"}'
fi
}
do_handshake() {
local init_params='{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-harness","version":"1.0"}}'
send_request "initialize" "$init_params"
local resp
resp=$(read_response 10)
if echo "$resp" | jq -e '.result.serverInfo' >/dev/null 2>&1; then
local server_name
server_name=$(echo "$resp" | jq -r '.result.serverInfo.name // "unknown"')
echo -e "${GREEN}Handshake OK${NC} — server: $server_name"
else
echo -e "${RED}Handshake FAILED${NC}: $resp"
exit 1
fi
send_notification "notifications/initialized" "null"
sleep 0.3
}
do_list_tools() {
send_request "tools/list" "null"
local resp
resp=$(read_response 15)
local count
count=$(echo "$resp" | jq '.result.tools | length' 2>/dev/null || echo 0)
echo -e "${CYAN}Tools registered: $count${NC}"
if [[ "$count" -lt 240 ]]; then
echo -e "${YELLOW}WARNING: Expected ~253 tools, got $count${NC}"
fi
echo "$resp" | jq -r '.result.tools[].name' 2>/dev/null | sort
}
call_tool() {
local tool_name="$1"
local args="$2"
ensure_server
send_request "tools/call" "{\"name\":\"$tool_name\",\"arguments\":$args}"
local resp
resp=$(read_response 30)
echo "$resp"
}
# Call tool and return the text content (for extracting IDs)
call_tool_text() {
local tool_name="$1"
local args="$2"
local resp
resp=$(call_tool "$tool_name" "$args")
echo "$resp" | jq -r '.result.content[0].text // ""' 2>/dev/null
}
# Extract first UUID from text
extract_uuid() {
echo "$1" | grep -oE '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' | head -1
}
test_tool() {
local tier="$1"
local tool_name="$2"
local args="$3"
local description="$4"
if [[ -n "$TIER_FILTER" && "$tier" != "$TIER_FILTER" ]]; then
return
fi
if [[ -n "$TOOL_FILTER" && "$tool_name" != "$TOOL_FILTER" ]]; then
return
fi
printf " [T%s] %-40s " "$tier" "$tool_name"
local resp
resp=$(call_tool "$tool_name" "$args")
# Check for timeout
if echo "$resp" | jq -e '.error == "timeout"' >/dev/null 2>&1; then
echo -e "${RED}TIMEOUT${NC}"
ERRORS+=("$tool_name: timeout")
FAIL=$((FAIL + 1))
return 1
fi
# Check for JSON-RPC error
local has_error
has_error=$(echo "$resp" | jq -e '.error != null' 2>/dev/null || echo "false")
if [[ "$has_error" == "true" ]]; then
local err_msg
err_msg=$(echo "$resp" | jq -r '.error.message // .error // "unknown"' 2>/dev/null)
echo -e "${RED}FAIL${NC} — $err_msg"
ERRORS+=("$tool_name: $err_msg")
FAIL=$((FAIL + 1))
return 1
fi
# Check for isError in result
local is_error
is_error=$(echo "$resp" | jq -e '.result.isError == true' 2>/dev/null || echo "false")
if [[ "$is_error" == "true" ]]; then
local content_text
content_text=$(echo "$resp" | jq -r '.result.content[0].text // "no detail"' 2>/dev/null | head -c 200)
echo -e "${RED}FAIL${NC} — $content_text"
ERRORS+=("$tool_name: $content_text")
FAIL=$((FAIL + 1))
return 1
fi
# Check we got content
local has_content
has_content=$(echo "$resp" | jq -e '.result.content[0].text' >/dev/null 2>&1 && echo "true" || echo "false")
if [[ "$has_content" == "true" ]]; then
local preview
preview=$(echo "$resp" | jq -r '.result.content[0].text' 2>/dev/null | head -1 | head -c 120)
echo -e "${GREEN}PASS${NC} — ${preview}"
PASS=$((PASS + 1))
return 0
else
echo -e "${YELLOW}WARN${NC} — unexpected response shape"
echo "$resp" | jq '.' 2>/dev/null | head -5
PASS=$((PASS + 1))
return 0
fi
}
# Inline test for create ops — prints pass/fail, sets a variable with the UUID
test_create() {
local tool_name="$1"
local args="$2"
local uuid_var="$3"
printf " [T2] %-40s " "$tool_name"
local resp
resp=$(call_tool "$tool_name" "$args")
# Check for JSON-RPC error (top-level)
local has_rpc_error
has_rpc_error=$(echo "$resp" | jq -e '.error != null' 2>/dev/null || echo "false")
if [[ "$has_rpc_error" == "true" ]]; then
local err_msg
err_msg=$(echo "$resp" | jq -r '.error.message // .error // "unknown"' 2>/dev/null)
echo -e "${RED}FAIL${NC} — $err_msg"
ERRORS+=("$tool_name: $err_msg")
FAIL=$((FAIL + 1))
eval "$uuid_var=''"
return 1
fi
local text
text=$(echo "$resp" | jq -r '.result.content[0].text // ""' 2>/dev/null)
local is_error
is_error=$(echo "$resp" | jq -e '.result.isError == true' 2>/dev/null || echo "false")
if [[ "$is_error" == "true" ]]; then
echo -e "${RED}FAIL${NC} — $(echo "$text" | head -c 200)"
ERRORS+=("$tool_name: $text")
FAIL=$((FAIL + 1))
eval "$uuid_var=''"
return 1
fi
local uuid
uuid=$(extract_uuid "$text")
if [[ -n "$uuid" ]]; then
echo -e "${GREEN}PASS${NC} — id: $uuid"
PASS=$((PASS + 1))
eval "$uuid_var='$uuid'"
return 0
elif [[ -n "$text" ]]; then
echo -e "${GREEN}PASS${NC} — $(echo "$text" | head -1 | head -c 100)"
PASS=$((PASS + 1))
eval "$uuid_var=''"
return 0
else
echo -e "${RED}FAIL${NC} — empty response (server may have died)"
ERRORS+=("$tool_name: empty response")
FAIL=$((FAIL + 1))
eval "$uuid_var=''"
return 1
fi
}
skip_tool() {
local tier="$1"
local tool_name="$2"
local reason="$3"
if [[ -n "$TIER_FILTER" && "$tier" != "$TIER_FILTER" ]]; then return; fi
if [[ -n "$TOOL_FILTER" && "$tool_name" != "$TOOL_FILTER" ]]; then return; fi
printf " [T%s] %-40s ${YELLOW}SKIP${NC} — %s\n" "$tier" "$tool_name" "$reason"
SKIP=$((SKIP + 1))
}
# ---- Discovery Mode ----
run_discovery() {
echo -e "\n${CYAN}=== Workspace Discovery ===${NC}\n"
echo "Teams:"; call_tool_text "list_teams" '{}' | head -20
echo -e "\nProjects:"; call_tool_text "list_projects" '{"limit": 5}' | head -20
echo -e "\nLabels:"; call_tool_text "list_labels" '{"limit": 5}' | head -20
echo -e "\nInitiatives:"; call_tool_text "list_initiatives" '{"limit": 3}' | head -20
echo -e "\nUsers:"; call_tool_text "list_users" '{"limit": 5}' | head -20
echo -e "\nCustomers:"; call_tool_text "list_customers" '{"limit": 5}' | head -20
echo -e "\nStates (first team):"; call_tool_text "list_states" '{}' | head -20
echo -e "\nViews:"; call_tool_text "list_views" '{"limit": 3}' | head -10
echo -e "\nWebhooks:"; call_tool_text "list_webhooks" '{}' | head -10
echo -e "\nRoadmaps:"; call_tool_text "list_roadmaps" '{"limit": 3}' | head -10
}
# ---- Main ----
echo -e "${CYAN}${BOLD}========================================================${NC}"
echo -e "${CYAN}${BOLD} linear-mcp-rs Comprehensive Test Harness (253 tools) ${NC}"
echo -e "${CYAN}${BOLD}========================================================${NC}"
echo ""
echo "Building..."
if ! cargo build --release 2>/dev/null; then
echo -e "${RED}Build failed!${NC}"
exit 1
fi
echo -e "${GREEN}Build OK${NC}"
echo ""
echo "Starting MCP server..."
start_server
do_handshake
echo ""
echo -e "${CYAN}=== Tool Registration ===${NC}"
TOOL_LIST=$(do_list_tools)
TOOL_COUNT=$(echo "$TOOL_LIST" | tail -n +2 | wc -l | tr -d ' ')
echo ""
if $LIST_ONLY; then
echo "$TOOL_LIST" | tail -n +2
echo -e "\nTotal: $TOOL_COUNT tools"
exit 0
fi
if $DISCOVER; then
run_discovery
exit 0
fi
# ============================================================
# First, discover the workspace so we know what entities exist
# ============================================================
echo -e "${CYAN}=== Discovering workspace entities... ===${NC}"
# Get first team key — skip any leftover TEST-HARNESS teams
TEAM_KEY=$(call_tool_text "list_teams" '{}' | grep '|' | grep -v 'TEST-HARNESS' | head -1 | awk '{print $1}')
if [[ -z "$TEAM_KEY" ]]; then TEAM_KEY="TEST"; fi
echo " Team: $TEAM_KEY"
# Get first user email
USER_EMAIL=$(call_tool_text "list_users" '{"limit": 1}' | grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]+' | head -1)
echo " User: ${USER_EMAIL:-none}"
echo ""
# ============================================================
# TIER 1: Read-Only Tests (all list/get/search tools)
# ============================================================
if [[ -z "$TIER_FILTER" || "$TIER_FILTER" == "1" ]]; then
echo -e "${CYAN}${BOLD}=== Tier 1: Read-Only Tests ===${NC}"
test_tool 1 "list_teams" '{}' ""
test_tool 1 "list_issues" "{\"team\": \"$TEAM_KEY\", \"limit\": 3}" ""
test_tool 1 "search_issues" '{"query": "test", "limit": 3}' ""
test_tool 1 "list_projects" '{"limit": 3}' ""
test_tool 1 "list_labels" '{"limit": 5}' ""
test_tool 1 "list_cycles" "{\"team\": \"$TEAM_KEY\", \"limit\": 3}" ""
test_tool 1 "list_initiatives" '{"limit": 3}' ""
test_tool 1 "list_users" '{"limit": 3}' ""
test_tool 1 "list_states" "{\"team\": \"$TEAM_KEY\"}" ""
test_tool 1 "list_views" '{"limit": 3}' ""
test_tool 1 "list_templates" '{"limit": 3}' ""
test_tool 1 "list_documents" '{"limit": 3}' ""
test_tool 1 "list_webhooks" '{}' ""
test_tool 1 "list_integrations" '{}' ""
test_tool 1 "list_favorites" '{}' ""
test_tool 1 "list_notifications" '{"limit": 3}' ""
test_tool 1 "my_issues" '{}' ""
test_tool 1 "list_triage_issues" "{\"team\": \"$TEAM_KEY\"}" ""
test_tool 1 "list_customers" '{"limit": 3}' ""
test_tool 1 "list_customer_needs" '{"limit": 3}' ""
test_tool 1 "list_agent_sessions" '{"limit": 3}' ""
skip_tool 1 "list_releases" "requires Release Management feature flag"
test_tool 1 "search_projects" '{"query": "test", "limit": 3}' ""
test_tool 1 "search_documents" '{"term": "test", "limit": 3}' ""
test_tool 1 "issue_vcs_branch_search" '{"branchName": "main"}' ""
test_tool 1 "query_audit_log" '{}' ""
# Enriched field filter tests
test_tool 1 "list_issues" "{\"team\": \"$TEAM_KEY\", \"limit\": 1, \"completed_after\": \"2025-01-01\"}" ""
# --- New Phase 2 read-only tools ---
test_tool 1 "get_viewer" '{}' ""
test_tool 1 "get_issue_priority_values" '{}' ""
test_tool 1 "list_customer_statuses" '{}' ""
test_tool 1 "list_customer_tiers" '{}' ""
test_tool 1 "list_project_statuses" '{}' ""
test_tool 1 "list_project_labels" '{}' ""
test_tool 1 "list_team_memberships" '{}' ""
test_tool 1 "list_notification_subscriptions" '{}' ""
test_tool 1 "get_notifications_unread_count" '{}' ""
test_tool 1 "list_emojis" '{}' ""
test_tool 1 "list_initiative_relations" '{}' ""
test_tool 1 "list_time_schedules" '{}' ""
test_tool 1 "list_triage_responsibilities" '{}' ""
test_tool 1 "list_archived_teams" '{}' ""
test_tool 1 "get_rate_limit_status" '{}' ""
test_tool 1 "get_organization" '{}' ""
skip_tool 1 "get_application_info" "requires OAuth app clientId"
test_tool 1 "semantic_search" '{"query": "test", "limit": 3}' ""
test_tool 1 "list_comments_all" '{"limit": 3}' ""
test_tool 1 "list_issue_relations" '{"limit": 3}' ""
test_tool 1 "list_external_users" '{"limit": 3}' ""
skip_tool 1 "list_roadmaps" "deprecated by Linear — no roadmaps API"
test_tool 1 "get_issue_filter_suggestion" '{"prompt": "bugs assigned to me"}' ""
skip_tool 1 "get_project_filter_suggestion" "AI filter suggestion — unreliable with API keys"
test_tool 1 "get_team" "{\"id\": \"$TEAM_KEY\"}" ""
# Release-gated read tools
skip_tool 1 "list_release_pipelines" "requires Release Management feature"
skip_tool 1 "list_release_stages" "requires Release Management feature"
skip_tool 1 "list_issue_to_releases" "requires Release Management feature"
skip_tool 1 "search_releases" "requires Release Management feature"
echo ""
fi
# ============================================================
# TIER 2: Create → Read → Update → Delete full lifecycle
# ============================================================
if [[ -z "$TIER_FILTER" || "$TIER_FILTER" == "2" ]]; then
echo -e "${CYAN}${BOLD}=== Tier 2: Full CRUD Lifecycle Tests ===${NC}"
# ------- Issue lifecycle -------
echo -e " ${CYAN}--- Issue lifecycle ---${NC}"
test_create "create_issue" "{\"team\": \"$TEAM_KEY\", \"title\": \"TEST-HARNESS: Delete me\", \"description\": \"Automated test\"}" ISSUE_ID
if [[ -n "$ISSUE_ID" ]]; then
# Get the issue identifier from get_issue
ISSUE_TEXT=$(call_tool_text "get_issue" "{\"id\": \"$ISSUE_ID\"}")
ISSUE_IDENT=$(echo "$ISSUE_TEXT" | head -1 | grep -oE '[A-Z]+-[0-9]+' | head -1)
echo " (identifier: ${ISSUE_IDENT:-$ISSUE_ID})"
test_tool 2 "get_issue" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
test_tool 2 "get_issue_history" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
test_tool 2 "list_comments" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
test_tool 2 "list_attachments" "{\"issueId\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
# Update issue
test_tool 2 "update_issue" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"title\": \"TEST-HARNESS: Updated title\"}" ""
# Add comment
COMMENT_TEXT=$(call_tool_text "add_comment" "{\"issueId\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"body\": \"Test comment from harness\"}")
COMMENT_ID=$(extract_uuid "$COMMENT_TEXT")
if [[ -n "$COMMENT_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "add_comment" "$COMMENT_ID"
PASS=$((PASS + 1))
# Update comment
test_tool 2 "update_comment" "{\"id\": \"$COMMENT_ID\", \"body\": \"Updated test comment\"}" ""
# Resolve / unresolve comment
test_tool 2 "resolve_comment" "{\"id\": \"$COMMENT_ID\"}" ""
test_tool 2 "unresolve_comment" "{\"id\": \"$COMMENT_ID\"}" ""
# Add reaction / remove reaction
REACTION_TEXT=$(call_tool_text "add_reaction" "{\"commentId\": \"$COMMENT_ID\", \"emoji\": \"thumbsup\"}")
REACTION_ID=$(extract_uuid "$REACTION_TEXT")
if [[ -n "$REACTION_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "add_reaction" "$REACTION_ID"
PASS=$((PASS + 1))
test_tool 2 "remove_reaction" "{\"id\": \"$REACTION_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC} — no UUID in response\n" "add_reaction"
ERRORS+=("add_reaction: no UUID in response: $REACTION_TEXT")
FAIL=$((FAIL + 1))
fi
# Get comment
test_tool 2 "get_comment" "{\"id\": \"$COMMENT_ID\"}" ""
# Delete comment
test_tool 2 "delete_comment" "{\"id\": \"$COMMENT_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC} — no UUID: %s\n" "add_comment" "$(echo "$COMMENT_TEXT" | head -c 100)"
ERRORS+=("add_comment: no UUID")
FAIL=$((FAIL + 1))
fi
# Add/remove label (need a temp label)
ILABEL_SUFFIX=$(date +%s)
ILABEL_TEXT=$(call_tool_text "create_label" "{\"name\": \"TH-ILABEL-$ILABEL_SUFFIX\", \"team\": \"$TEAM_KEY\", \"color\": \"#0000ff\"}")
ILABEL_ID=$(extract_uuid "$ILABEL_TEXT")
if [[ -n "$ILABEL_ID" ]]; then
test_tool 2 "add_issue_label" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"label\": \"TH-ILABEL-$ILABEL_SUFFIX\"}" ""
test_tool 2 "remove_issue_label" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"label\": \"TH-ILABEL-$ILABEL_SUFFIX\"}" ""
test_tool 2 "get_issue_label" "{\"id\": \"$ILABEL_ID\"}" ""
call_tool "archive_label" "{\"id\": \"$ILABEL_ID\"}" >/dev/null 2>&1
fi
# Attach link URL
test_tool 2 "attach_link_url" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"url\": \"https://example.com/test\", \"title\": \"Test Link\"}" ""
test_tool 2 "get_attachments_for_url" '{"url": "https://example.com/test"}' ""
# Add attachment
ATTACH_TEXT=$(call_tool_text "add_attachment" "{\"issueId\": \"${ISSUE_IDENT:-$ISSUE_ID}\", \"title\": \"Test Link\", \"url\": \"https://example.com\"}")
ATTACH_ID=$(extract_uuid "$ATTACH_TEXT")
if [[ -n "$ATTACH_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "add_attachment" "$ATTACH_ID"
PASS=$((PASS + 1))
test_tool 2 "get_attachment" "{\"id\": \"$ATTACH_ID\"}" ""
test_tool 2 "update_attachment" "{\"id\": \"$ATTACH_ID\", \"title\": \"Updated Link\"}" ""
test_tool 2 "delete_attachment" "{\"id\": \"$ATTACH_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC} — no UUID\n" "add_attachment"
ERRORS+=("add_attachment: no UUID: $ATTACH_TEXT")
FAIL=$((FAIL + 1))
fi
# Subscribe / unsubscribe
test_tool 2 "subscribe_to_issue" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
test_tool 2 "unsubscribe_from_issue" "{\"issue\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
# Archive / unarchive
test_tool 2 "archive_issue" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
test_tool 2 "unarchive_issue" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
# Delete issue (permanent)
test_tool 2 "delete_issue" "{\"id\": \"${ISSUE_IDENT:-$ISSUE_ID}\"}" ""
fi
# ------- Issue #2 for relation + cycle + bulk tests -------
echo -e " ${CYAN}--- Issue relations & cycles ---${NC}"
test_create "create_issue" "{\"team\": \"$TEAM_KEY\", \"title\": \"TEST-HARNESS: Issue A\"}" ISSUE_A_ID
test_create "create_issue" "{\"team\": \"$TEAM_KEY\", \"title\": \"TEST-HARNESS: Issue B\"}" ISSUE_B_ID
if [[ -n "$ISSUE_A_ID" && -n "$ISSUE_B_ID" ]]; then
ISSUE_A_IDENT=$(call_tool_text "get_issue" "{\"id\": \"$ISSUE_A_ID\"}" | head -1 | grep -oE '[A-Z]+-[0-9]+' | head -1)
ISSUE_B_IDENT=$(call_tool_text "get_issue" "{\"id\": \"$ISSUE_B_ID\"}" | head -1 | grep -oE '[A-Z]+-[0-9]+' | head -1)
# Issue relation
RELATION_TEXT=$(call_tool_text "create_issue_relation" "{\"issueId\": \"${ISSUE_A_IDENT:-$ISSUE_A_ID}\", \"relatedIssueId\": \"${ISSUE_B_IDENT:-$ISSUE_B_ID}\", \"type\": \"related\"}")
RELATION_ID=$(extract_uuid "$RELATION_TEXT")
if [[ -n "$RELATION_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_issue_relation" "$RELATION_ID"
PASS=$((PASS + 1))
test_tool 2 "get_issue_relation" "{\"id\": \"$RELATION_ID\"}" ""
test_tool 2 "update_issue_relation" "{\"id\": \"$RELATION_ID\", \"type\": \"blocks\"}" ""
test_tool 2 "delete_issue_relation" "{\"id\": \"$RELATION_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_issue_relation"
ERRORS+=("create_issue_relation: $RELATION_TEXT")
FAIL=$((FAIL + 1))
fi
# Cycle create → add issue → remove issue → archive cycle
CYCLE_TEXT=$(call_tool_text "create_cycle" "{\"team\": \"$TEAM_KEY\", \"name\": \"TEST-HARNESS-CYCLE\", \"startsAt\": \"2027-01-01\", \"endsAt\": \"2027-01-15\"}")
CYCLE_ID=$(extract_uuid "$CYCLE_TEXT")
if [[ -n "$CYCLE_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_cycle" "$CYCLE_ID"
PASS=$((PASS + 1))
test_tool 2 "get_cycle" "{\"id\": \"$CYCLE_ID\"}" ""
test_tool 2 "update_cycle" "{\"id\": \"$CYCLE_ID\", \"name\": \"TEST-HARNESS-CYCLE-UPDATED\"}" ""
test_tool 2 "add_issue_to_cycle" "{\"issueId\": \"${ISSUE_A_IDENT:-$ISSUE_A_ID}\", \"cycleId\": \"$CYCLE_ID\"}" ""
test_tool 2 "remove_issue_from_cycle" "{\"issueId\": \"${ISSUE_A_IDENT:-$ISSUE_A_ID}\"}" ""
test_tool 2 "archive_cycle" "{\"id\": \"$CYCLE_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_cycle"
ERRORS+=("create_cycle: $CYCLE_TEXT")
FAIL=$((FAIL + 1))
fi
# Bulk update issues
if [[ -n "$ISSUE_A_IDENT" && -n "$ISSUE_B_IDENT" ]]; then
test_tool 2 "bulk_update_issues" "{\"ids\": \"$ISSUE_A_IDENT,$ISSUE_B_IDENT\", \"priority\": \"high\"}" ""
fi
# Triage issue (move to a known state)
if [[ -n "$ISSUE_A_IDENT" ]]; then
test_tool 2 "triage_issue" "{\"id\": \"$ISSUE_A_IDENT\", \"state\": \"Todo\"}" ""
fi
# Clean up issues
test_tool 2 "delete_issue" "{\"id\": \"${ISSUE_A_IDENT:-$ISSUE_A_ID}\"}" ""
test_tool 2 "delete_issue" "{\"id\": \"${ISSUE_B_IDENT:-$ISSUE_B_ID}\"}" ""
fi
# ------- Batch create issues -------
echo -e " ${CYAN}--- Batch create issues ---${NC}"
BATCH_TEXT=$(call_tool_text "batch_create_issues" "{\"team\": \"$TEAM_KEY\", \"issues\": \"[{\\\"title\\\":\\\"BATCH-A\\\"},{\\\"title\\\":\\\"BATCH-B\\\"}]\"}")
printf " [T2] %-40s " "batch_create_issues"
if echo "$BATCH_TEXT" | grep -q "BATCH-A"; then
echo -e "${GREEN}PASS${NC} — $(echo "$BATCH_TEXT" | head -1 | head -c 100)"
PASS=$((PASS + 1))
# Extract identifiers and clean up
for bid in $(echo "$BATCH_TEXT" | grep -oE '[A-Z]+-[0-9]+'); do
call_tool "delete_issue" "{\"id\": \"$bid\"}" >/dev/null 2>&1
done
else
echo -e "${RED}FAIL${NC} — $BATCH_TEXT"
ERRORS+=("batch_create_issues: $BATCH_TEXT")
FAIL=$((FAIL + 1))
fi
# ------- Label lifecycle -------
echo -e " ${CYAN}--- Label lifecycle ---${NC}"
LABEL_SUFFIX=$(date +%s)
test_create "create_label" "{\"name\": \"TEST-HARNESS-LABEL-$LABEL_SUFFIX\", \"team\": \"$TEAM_KEY\", \"color\": \"#ff0000\"}" LABEL_ID
if [[ -n "$LABEL_ID" ]]; then
test_tool 2 "update_label" "{\"id\": \"$LABEL_ID\", \"name\": \"TEST-HARNESS-LABEL-UPD-$LABEL_SUFFIX\", \"color\": \"#00ff00\"}" ""
test_tool 2 "archive_label" "{\"id\": \"$LABEL_ID\"}" ""
fi
# ------- Project lifecycle -------
echo -e " ${CYAN}--- Project lifecycle ---${NC}"
PROJ_SUFFIX=$(date +%s)
test_create "create_project" "{\"name\": \"TEST-HARNESS-PROJECT-$PROJ_SUFFIX\", \"teams\": \"$TEAM_KEY\"}" PROJECT_ID
if [[ -n "$PROJECT_ID" ]]; then
test_tool 2 "get_project" "{\"id\": \"$PROJECT_ID\"}" ""
test_tool 2 "update_project" "{\"id\": \"$PROJECT_ID\", \"description\": \"Test project description\"}" ""
# Project milestone
MILESTONE_TEXT=$(call_tool_text "create_project_milestone" "{\"project\": \"$PROJECT_ID\", \"name\": \"TEST-MILESTONE\"}")
MILESTONE_ID=$(extract_uuid "$MILESTONE_TEXT")
if [[ -n "$MILESTONE_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_project_milestone" "$MILESTONE_ID"
PASS=$((PASS + 1))
test_tool 2 "list_project_milestones" "{\"project\": \"$PROJECT_ID\"}" ""
test_tool 2 "update_project_milestone" "{\"id\": \"$MILESTONE_ID\", \"name\": \"TEST-MILESTONE-UPDATED\"}" ""
test_tool 2 "delete_project_milestone" "{\"id\": \"$MILESTONE_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_project_milestone"
ERRORS+=("create_project_milestone: $MILESTONE_TEXT")
FAIL=$((FAIL + 1))
fi
# Project update
PUPDATE_TEXT=$(call_tool_text "create_project_update" "{\"project\": \"$PROJECT_ID\", \"body\": \"Test status update\", \"health\": \"onTrack\"}")
PUPDATE_ID=$(extract_uuid "$PUPDATE_TEXT")
if [[ -n "$PUPDATE_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_project_update" "$PUPDATE_ID"
PASS=$((PASS + 1))
test_tool 2 "list_project_updates" "{\"project\": \"$PROJECT_ID\"}" ""
test_tool 2 "update_project_update" "{\"id\": \"$PUPDATE_ID\", \"body\": \"Updated status\"}" ""
test_tool 2 "delete_project_update" "{\"id\": \"$PUPDATE_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_project_update"
ERRORS+=("create_project_update: $PUPDATE_TEXT")
FAIL=$((FAIL + 1))
fi
# Archive → unarchive → delete project
test_tool 2 "archive_project" "{\"id\": \"$PROJECT_ID\"}" ""
test_tool 2 "unarchive_project" "{\"id\": \"$PROJECT_ID\"}" ""
test_tool 2 "delete_project" "{\"id\": \"$PROJECT_ID\"}" ""
fi
# ------- Project relations (need 2 projects) -------
echo -e " ${CYAN}--- Project relations ---${NC}"
PROJREL_SUFFIX=$(date +%s)
test_create "create_project" "{\"name\": \"TH-PROJ-A-$PROJREL_SUFFIX\", \"teams\": \"$TEAM_KEY\"}" PROJ_A_ID
test_create "create_project" "{\"name\": \"TH-PROJ-B-$PROJREL_SUFFIX\", \"teams\": \"$TEAM_KEY\"}" PROJ_B_ID
if [[ -n "$PROJ_A_ID" && -n "$PROJ_B_ID" ]]; then
PROJREL_TEXT=$(call_tool_text "create_project_relation" "{\"project\": \"$PROJ_A_ID\", \"relatedProject\": \"$PROJ_B_ID\", \"type\": \"related\"}")
PROJREL_ID=$(extract_uuid "$PROJREL_TEXT")
if [[ -n "$PROJREL_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_project_relation" "$PROJREL_ID"
PASS=$((PASS + 1))
test_tool 2 "list_project_relations" "{\"project\": \"$PROJ_A_ID\"}" ""
test_tool 2 "update_project_relation" "{\"id\": \"$PROJREL_ID\", \"anchor_type\": \"start\"}" ""
test_tool 2 "delete_project_relation" "{\"id\": \"$PROJREL_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_project_relation"
ERRORS+=("create_project_relation: $PROJREL_TEXT")
FAIL=$((FAIL + 1))
fi
# Clean up
call_tool "archive_project" "{\"id\": \"$PROJ_A_ID\"}" >/dev/null 2>&1
call_tool "archive_project" "{\"id\": \"$PROJ_B_ID\"}" >/dev/null 2>&1
fi
# ------- Document lifecycle (needs a project first) -------
echo -e " ${CYAN}--- Document lifecycle ---${NC}"
DOC_SUFFIX=$(date +%s)
DOC_PROJ_TEXT=$(call_tool_text "create_project" "{\"name\": \"TH-DOC-PROJ-$DOC_SUFFIX\", \"teams\": \"$TEAM_KEY\"}")
DOC_PROJ_ID=$(extract_uuid "$DOC_PROJ_TEXT")
if [[ -n "$DOC_PROJ_ID" ]]; then
test_create "create_document" "{\"title\": \"TEST-HARNESS-DOC\", \"content\": \"Test content\", \"project\": \"$DOC_PROJ_ID\"}" DOC_ID
if [[ -n "$DOC_ID" ]]; then
test_tool 2 "get_document" "{\"id\": \"$DOC_ID\"}" ""
test_tool 2 "update_document" "{\"id\": \"$DOC_ID\", \"title\": \"TEST-HARNESS-DOC-UPDATED\"}" ""
test_tool 2 "get_document_content_history" "{\"id\": \"$DOC_ID\"}" ""
test_tool 2 "delete_document" "{\"id\": \"$DOC_ID\"}" ""
fi
# Test unarchive_document with a separate doc
UNDOC_TEXT=$(call_tool_text "create_document" "{\"title\": \"TEST-HARNESS-UNDOC\", \"content\": \"Test\", \"project\": \"$DOC_PROJ_ID\"}")
UNDOC_ID=$(extract_uuid "$UNDOC_TEXT")
if [[ -n "$UNDOC_ID" ]]; then
call_tool "delete_document" "{\"id\": \"$UNDOC_ID\"}" >/dev/null 2>&1
test_tool 2 "unarchive_document" "{\"id\": \"$UNDOC_ID\"}" ""
call_tool "delete_document" "{\"id\": \"$UNDOC_ID\"}" >/dev/null 2>&1
fi
call_tool "archive_project" "{\"id\": \"$DOC_PROJ_ID\"}" >/dev/null 2>&1
else
skip_tool 2 "create_document" "failed to create project for doc"
skip_tool 2 "get_document" "depends on create_document"
skip_tool 2 "update_document" "depends on create_document"
skip_tool 2 "delete_document" "depends on create_document"
fi
# ------- Initiative lifecycle -------
echo -e " ${CYAN}--- Initiative lifecycle ---${NC}"
test_create "create_initiative" "{\"name\": \"TEST-HARNESS-INITIATIVE\", \"description\": \"Test\"}" INIT_ID
if [[ -n "$INIT_ID" ]]; then
test_tool 2 "update_initiative" "{\"id\": \"$INIT_ID\", \"name\": \"TEST-HARNESS-INITIATIVE-UPDATED\"}" ""
test_tool 2 "list_initiative_updates" "{\"initiative\": \"$INIT_ID\"}" ""
# Initiative update
INITUPD_TEXT=$(call_tool_text "create_initiative_update" "{\"initiative\": \"$INIT_ID\", \"body\": \"Test update\", \"health\": \"onTrack\"}")
INITUPD_ID=$(extract_uuid "$INITUPD_TEXT")
if [[ -n "$INITUPD_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_initiative_update" "$INITUPD_ID"
PASS=$((PASS + 1))
test_tool 2 "update_initiative_update" "{\"id\": \"$INITUPD_ID\", \"body\": \"Updated init update\"}" ""
test_tool 2 "archive_initiative_update" "{\"id\": \"$INITUPD_ID\"}" ""
test_tool 2 "unarchive_initiative_update" "{\"id\": \"$INITUPD_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_initiative_update"
ERRORS+=("create_initiative_update: $INITUPD_TEXT")
FAIL=$((FAIL + 1))
fi
# Add project to initiative → remove
# First create a temp project
INITPROJ_SUFFIX=$(date +%s)
TEMP_PROJ_TEXT=$(call_tool_text "create_project" "{\"name\": \"TH-INIT-PROJ-$INITPROJ_SUFFIX\", \"teams\": \"$TEAM_KEY\"}")
TEMP_PROJ_ID=$(extract_uuid "$TEMP_PROJ_TEXT")
if [[ -n "$TEMP_PROJ_ID" ]]; then
INITPROJ_TEXT=$(call_tool_text "add_project_to_initiative" "{\"initiative\": \"$INIT_ID\", \"project\": \"$TEMP_PROJ_ID\"}")
INITPROJ_ID=$(extract_uuid "$INITPROJ_TEXT")
if [[ -n "$INITPROJ_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "add_project_to_initiative" "$INITPROJ_ID"
PASS=$((PASS + 1))
test_tool 2 "update_initiative_to_project" "{\"id\": \"$INITPROJ_ID\", \"sort_order\": 1.0}" ""
test_tool 2 "remove_project_from_initiative" "{\"id\": \"$INITPROJ_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "add_project_to_initiative"
ERRORS+=("add_project_to_initiative: $INITPROJ_TEXT")
FAIL=$((FAIL + 1))
fi
call_tool "archive_project" "{\"id\": \"$TEMP_PROJ_ID\"}" >/dev/null 2>&1
fi
# Archive → unarchive → delete initiative
test_tool 2 "archive_initiative" "{\"id\": \"$INIT_ID\"}" ""
test_tool 2 "unarchive_initiative" "{\"id\": \"$INIT_ID\"}" ""
test_tool 2 "delete_initiative" "{\"id\": \"$INIT_ID\"}" ""
fi
# ------- Customer lifecycle -------
echo -e " ${CYAN}--- Customer lifecycle ---${NC}"
CUST_SUFFIX=$(date +%s)
test_create "create_customer" "{\"name\": \"TEST-HARNESS-CUSTOMER-$CUST_SUFFIX\", \"domains\": \"test-$CUST_SUFFIX.example.com\"}" CUST_ID
if [[ -n "$CUST_ID" ]]; then
test_tool 2 "get_customer" "{\"id\": \"$CUST_ID\"}" ""
test_tool 2 "update_customer" "{\"id\": \"$CUST_ID\", \"name\": \"TEST-HARNESS-CUSTOMER-UPDATED\"}" ""
# Customer need (needs an issue)
NEED_ISSUE_TEXT=$(call_tool_text "create_issue" "{\"team\": \"$TEAM_KEY\", \"title\": \"TEST-HARNESS: Need issue\"}")
NEED_ISSUE_ID=$(extract_uuid "$NEED_ISSUE_TEXT")
NEED_ISSUE_IDENT=""
if [[ -n "$NEED_ISSUE_ID" ]]; then
NEED_ISSUE_IDENT=$(call_tool_text "get_issue" "{\"id\": \"$NEED_ISSUE_ID\"}" | head -1 | grep -oE '[A-Z]+-[0-9]+' | head -1)
fi
if [[ -n "$NEED_ISSUE_IDENT" ]]; then
NEED_TEXT=$(call_tool_text "create_customer_need" "{\"issue\": \"$NEED_ISSUE_IDENT\", \"customer\": \"$CUST_ID\", \"body\": \"Test need\"}")
NEED_ID=$(extract_uuid "$NEED_TEXT")
if [[ -n "$NEED_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_customer_need" "$NEED_ID"
PASS=$((PASS + 1))
test_tool 2 "update_customer_need" "{\"id\": \"$NEED_ID\", \"body\": \"Updated need\"}" ""
test_tool 2 "get_customer_need" "{\"id\": \"$NEED_ID\"}" ""
test_tool 2 "archive_customer_need" "{\"id\": \"$NEED_ID\"}" ""
test_tool 2 "unarchive_customer_need" "{\"id\": \"$NEED_ID\"}" ""
test_tool 2 "delete_customer_need" "{\"id\": \"$NEED_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_customer_need"
ERRORS+=("create_customer_need: $NEED_TEXT")
FAIL=$((FAIL + 1))
fi
# Clean up issue
call_tool "delete_issue" "{\"id\": \"$NEED_ISSUE_IDENT\"}" >/dev/null 2>&1
fi
# Merge customers (create a second, merge into first)
MERGE_CUST_TEXT=$(call_tool_text "create_customer" "{\"name\": \"TEST-HARNESS-MERGE-SRC-$CUST_SUFFIX\"}")
MERGE_CUST_ID=$(extract_uuid "$MERGE_CUST_TEXT")
if [[ -n "$MERGE_CUST_ID" ]]; then
test_tool 2 "merge_customers" "{\"source_id\": \"$MERGE_CUST_ID\", \"target_id\": \"$CUST_ID\"}" ""
fi
test_tool 2 "delete_customer" "{\"id\": \"$CUST_ID\"}" ""
fi
# ------- View lifecycle -------
echo -e " ${CYAN}--- View lifecycle ---${NC}"
test_create "create_view" "{\"name\": \"TEST-HARNESS-VIEW\"}" VIEW_ID
if [[ -n "$VIEW_ID" ]]; then
test_tool 2 "update_view" "{\"id\": \"$VIEW_ID\", \"name\": \"TEST-HARNESS-VIEW-UPDATED\"}" ""
test_tool 2 "get_view_issues" "{\"id\": \"$VIEW_ID\"}" ""
test_tool 2 "check_custom_view_has_subscribers" "{\"id\": \"$VIEW_ID\"}" ""
test_tool 2 "delete_view" "{\"id\": \"$VIEW_ID\"}" ""
fi
# ------- Webhook lifecycle -------
echo -e " ${CYAN}--- Webhook lifecycle ---${NC}"
WEBHOOK_URL="https://example.com/webhook-test-$(date +%s)"
WEBHOOK_TEXT=$(call_tool_text "create_webhook" "{\"url\": \"$WEBHOOK_URL\", \"label\": \"TEST-HARNESS-WEBHOOK\", \"resourceTypes\": \"Issue\"}")
WEBHOOK_ID=$(extract_uuid "$WEBHOOK_TEXT")
if [[ -n "$WEBHOOK_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_webhook" "$WEBHOOK_ID"
PASS=$((PASS + 1))
test_tool 2 "update_webhook" "{\"id\": \"$WEBHOOK_ID\", \"label\": \"TEST-HARNESS-WEBHOOK-UPDATED\"}" ""
test_tool 2 "delete_webhook" "{\"id\": \"$WEBHOOK_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_webhook"
ERRORS+=("create_webhook: $WEBHOOK_TEXT")
FAIL=$((FAIL + 1))
fi
# ------- Agent session lifecycle (requires OAuth, not API key) -------
echo -e " ${CYAN}--- Agent session lifecycle ---${NC}"
skip_tool 2 "create_agent_session" "requires OAuth authentication (not API key)"
skip_tool 2 "get_agent_session" "depends on create_agent_session"
skip_tool 2 "update_agent_session" "depends on create_agent_session"
skip_tool 2 "create_agent_activity" "depends on create_agent_session"
# ------- Favorite lifecycle -------
echo -e " ${CYAN}--- Favorites ---${NC}"
# Create a temp issue to favorite
FAV_ISSUE_TEXT=$(call_tool_text "create_issue" "{\"team\": \"$TEAM_KEY\", \"title\": \"TEST-HARNESS: Favorite me\"}")
FAV_ISSUE_ID=$(extract_uuid "$FAV_ISSUE_TEXT")
FAV_ISSUE_IDENT=""
if [[ -n "$FAV_ISSUE_ID" ]]; then
FAV_ISSUE_IDENT=$(call_tool_text "get_issue" "{\"id\": \"$FAV_ISSUE_ID\"}" | head -1 | grep -oE '[A-Z]+-[0-9]+' | head -1)
fi
if [[ -n "$FAV_ISSUE_IDENT" ]]; then
FAV_TEXT=$(call_tool_text "add_favorite" "{\"issueId\": \"$FAV_ISSUE_IDENT\"}")
FAV_ID=$(extract_uuid "$FAV_TEXT")
if [[ -n "$FAV_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "add_favorite" "$FAV_ID"
PASS=$((PASS + 1))
test_tool 2 "get_favorite" "{\"id\": \"$FAV_ID\"}" ""
test_tool 2 "update_favorite" "{\"id\": \"$FAV_ID\", \"sort_order\": 0.5}" ""
test_tool 2 "remove_favorite" "{\"id\": \"$FAV_ID\"}" ""
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "add_favorite"
ERRORS+=("add_favorite: $FAV_TEXT")
FAIL=$((FAIL + 1))
fi
call_tool "delete_issue" "{\"id\": \"$FAV_ISSUE_IDENT\"}" >/dev/null 2>&1
fi
# ------- Notification -------
echo -e " ${CYAN}--- Notifications ---${NC}"
NOTIF_TEXT=$(call_tool_text "list_notifications" '{"limit": 1}')
NOTIF_ID=$(extract_uuid "$NOTIF_TEXT")
if [[ -n "$NOTIF_ID" ]]; then
test_tool 2 "get_notification" "{\"id\": \"$NOTIF_ID\"}" ""
test_tool 2 "mark_notification_read" "{\"id\": \"$NOTIF_ID\"}" ""
else
skip_tool 2 "mark_notification_read" "no notifications available"
fi
# ------- Team update -------
echo -e " ${CYAN}--- Team ---${NC}"
test_tool 2 "update_team" "{\"id\": \"$TEAM_KEY\", \"description\": \"Updated by test harness\"}" ""
# Restore
test_tool 2 "update_team" "{\"id\": \"$TEAM_KEY\", \"description\": \"\"}" ""
# ------- User -------
echo -e " ${CYAN}--- User ---${NC}"
if [[ -n "$USER_EMAIL" ]]; then
test_tool 2 "get_user" "{\"id\": \"$USER_EMAIL\"}" ""
test_tool 2 "update_user" "{\"id\": \"$USER_EMAIL\", \"status_label\": \"Testing\"}" ""
test_tool 2 "update_user" "{\"id\": \"$USER_EMAIL\", \"status_label\": \"\"}" ""
fi
# ------- Roadmap tools removed (deprecated by Linear) -------
# ------- Custom view extras -------
echo -e " ${CYAN}--- Custom view extras ---${NC}"
test_tool 2 "get_custom_view_suggestion" '{"model_name": "issues", "filter": {}}' ""
# ------- Release lifecycle (may require feature flag) -------
echo -e " ${CYAN}--- Releases ---${NC}"
skip_tool 2 "create_release" "requires pipeline UUID + feature flag"
skip_tool 2 "update_release" "depends on create_release"
# ------- Team create/delete/unarchive -------
echo -e " ${CYAN}--- Team lifecycle ---${NC}"
TM_SUFFIX=$((RANDOM % 9000 + 1000))
test_create "create_team" "{\"name\": \"TEST-HARNESS-TEAM-$TM_SUFFIX\", \"key\": \"TH$TM_SUFFIX\"}" NEW_TEAM_ID
if [[ -n "$NEW_TEAM_ID" ]]; then
test_tool 2 "delete_team" "{\"id\": \"$NEW_TEAM_ID\"}" ""
test_tool 2 "unarchive_team" "{\"id\": \"$NEW_TEAM_ID\"}" ""
# Final cleanup: delete again
call_tool "delete_team" "{\"id\": \"$NEW_TEAM_ID\"}" >/dev/null 2>&1
fi
# ------- Template + Issue from template -------
echo -e " ${CYAN}--- Template lifecycle ---${NC}"
test_create "create_template" "{\"name\": \"TEST-HARNESS-TEMPLATE\", \"type\": \"issue\", \"template_data\": \"{\\\"title\\\":\\\"TEST-TEMPLATE-ISSUE\\\",\\\"description\\\":\\\"Created from template\\\"}\", \"team\": \"$TEAM_KEY\"}" TMPL_ID
if [[ -n "$TMPL_ID" ]]; then
test_tool 2 "get_template" "{\"id\": \"$TMPL_ID\"}" ""
test_tool 2 "update_template" "{\"id\": \"$TMPL_ID\", \"name\": \"TEST-HARNESS-TEMPLATE-UPD\"}" ""
# Create issue from template
FROMTMPL_TEXT=$(call_tool_text "create_issue_from_template" "{\"team\": \"$TEAM_KEY\", \"templateId\": \"$TMPL_ID\"}")
FROMTMPL_ID=$(extract_uuid "$FROMTMPL_TEXT")
if [[ -n "$FROMTMPL_ID" ]]; then
printf " [T2] %-40s ${GREEN}PASS${NC} — id: %s\n" "create_issue_from_template" "$FROMTMPL_ID"
PASS=$((PASS + 1))
# Clean up issue created from template
FROMTMPL_IDENT=$(echo "$FROMTMPL_TEXT" | grep -oE '[A-Z]+-[0-9]+' | head -1)
call_tool "delete_issue" "{\"id\": \"${FROMTMPL_IDENT:-$FROMTMPL_ID}\"}" >/dev/null 2>&1
else
printf " [T2] %-40s ${RED}FAIL${NC}\n" "create_issue_from_template"
ERRORS+=("create_issue_from_template: $FROMTMPL_TEXT")
FAIL=$((FAIL + 1))
fi
test_tool 2 "delete_template" "{\"id\": \"$TMPL_ID\"}" ""
fi
# ------- Workflow state lifecycle -------
echo -e " ${CYAN}--- Workflow state lifecycle ---${NC}"
WFS_SUFFIX=$((RANDOM % 9000 + 1000))
test_create "create_workflow_state" "{\"team\": \"$TEAM_KEY\", \"name\": \"TH-STATE-$WFS_SUFFIX\", \"color\": \"#ff8800\", \"type\": \"started\"}" WF_STATE_ID
if [[ -n "$WF_STATE_ID" ]]; then