@eeymoo/hum 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/commands/auth.js +16 -9
- package/src/commands/config.js +6 -1
- package/src/commands/diet.js +19 -158
- package/src/commands/exercise.js +18 -154
- package/src/commands/food.js +1 -1
- package/src/commands/record.js +9 -9
- package/src/commands/sleep.js +42 -163
- package/src/commands/timeline.js +1 -1
- package/src/commands/weight.js +17 -149
- package/src/lib/api.js +14 -3
- package/src/lib/crud-command.js +186 -0
- package/test/e2e-extended.sh +200 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
CLI="node $(dirname "$0")/../bin/index.js"
|
|
5
|
+
API_URL="http://localhost:3001"
|
|
6
|
+
API_KEY="${HUM_API_KEY:-abc123}"
|
|
7
|
+
|
|
8
|
+
echo "=== Hum CLI Extended E2E Test ==="
|
|
9
|
+
echo ""
|
|
10
|
+
|
|
11
|
+
# 1. Config
|
|
12
|
+
echo "=== Config ==="
|
|
13
|
+
echo "1. Testing config set..."
|
|
14
|
+
$CLI config set apiUrl $API_URL
|
|
15
|
+
echo " ✓ apiUrl set"
|
|
16
|
+
|
|
17
|
+
echo "2. Testing config get..."
|
|
18
|
+
$CLI config get apiUrl > /dev/null
|
|
19
|
+
echo " ✓ config get ok"
|
|
20
|
+
|
|
21
|
+
echo "3. Testing config list..."
|
|
22
|
+
RESULT=$($CLI config list)
|
|
23
|
+
echo " $RESULT"
|
|
24
|
+
echo " ✓ config list ok"
|
|
25
|
+
|
|
26
|
+
# 2. Auth
|
|
27
|
+
echo ""
|
|
28
|
+
echo "=== Auth ==="
|
|
29
|
+
echo "4. Testing auth login with env var..."
|
|
30
|
+
HUM_API_KEY=$API_KEY $CLI auth login --api-key $API_KEY
|
|
31
|
+
echo " ✓ logged in"
|
|
32
|
+
|
|
33
|
+
echo "5. Testing auth status..."
|
|
34
|
+
$CLI auth status
|
|
35
|
+
echo " ✓ status ok"
|
|
36
|
+
|
|
37
|
+
# 3. Weight CRUD
|
|
38
|
+
echo ""
|
|
39
|
+
echo "=== Weight ==="
|
|
40
|
+
echo "6. Testing weight add..."
|
|
41
|
+
RESULT=$($CLI weight add --weight 70.5 --date "2026-05-28" 2&1)
|
|
42
|
+
echo " $RESULT"
|
|
43
|
+
WEIGHT_ID=$(echo "$RESULT" | grep -o '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | head -1)
|
|
44
|
+
if [ -z "$WEIGHT_ID" ]; then
|
|
45
|
+
echo " ✗ failed to get weight id"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
echo " ✓ weight added: $WEIGHT_ID"
|
|
49
|
+
|
|
50
|
+
echo "7. Testing weight list..."
|
|
51
|
+
$CLI weight list --last 7d > /dev/null
|
|
52
|
+
echo " ✓ weight list ok"
|
|
53
|
+
|
|
54
|
+
echo "8. Testing weight get..."
|
|
55
|
+
$CLI weight get $WEIGHT_ID > /dev/null
|
|
56
|
+
echo " ✓ weight get ok"
|
|
57
|
+
|
|
58
|
+
echo "9. Testing weight update..."
|
|
59
|
+
$CLI weight update $WEIGHT_ID --weight 71.0 > /dev/null
|
|
60
|
+
echo " ✓ weight update ok"
|
|
61
|
+
|
|
62
|
+
echo "10. Testing weight stats..."
|
|
63
|
+
$CLI weight stats --last 30d > /dev/null
|
|
64
|
+
echo " ✓ weight stats ok"
|
|
65
|
+
|
|
66
|
+
echo "11. Testing weight delete..."
|
|
67
|
+
$CLI weight delete $WEIGHT_ID > /dev/null
|
|
68
|
+
echo " ✓ weight delete ok"
|
|
69
|
+
|
|
70
|
+
# 4. Exercise CRUD
|
|
71
|
+
echo ""
|
|
72
|
+
echo "=== Exercise ==="
|
|
73
|
+
echo "12. Testing exercise add..."
|
|
74
|
+
RESULT=$($CLI exercise add --type running --duration 30 --date "2026-05-28" 2&1)
|
|
75
|
+
echo " $RESULT"
|
|
76
|
+
EXERCISE_ID=$(echo "$RESULT" | grep -o '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | head -1)
|
|
77
|
+
if [ -z "$EXERCISE_ID" ]; then
|
|
78
|
+
echo " ✗ failed to get exercise id"
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
echo " ✓ exercise added: $EXERCISE_ID"
|
|
82
|
+
|
|
83
|
+
echo "13. Testing exercise list..."
|
|
84
|
+
$CLI exercise list --last 7d > /dev/null
|
|
85
|
+
echo " ✓ exercise list ok"
|
|
86
|
+
|
|
87
|
+
echo "14. Testing exercise stats..."
|
|
88
|
+
$CLI exercise stats --last 30d > /dev/null
|
|
89
|
+
echo " ✓ exercise stats ok"
|
|
90
|
+
|
|
91
|
+
echo "15. Testing exercise delete..."
|
|
92
|
+
$CLI exercise delete $EXERCISE_ID > /dev/null
|
|
93
|
+
echo " ✓ exercise delete ok"
|
|
94
|
+
|
|
95
|
+
# 5. Diet CRUD
|
|
96
|
+
echo ""
|
|
97
|
+
echo "=== Diet ==="
|
|
98
|
+
echo "16. Testing diet add..."
|
|
99
|
+
RESULT=$($CLI diet add --meal breakfast --calories 500 --date "2026-05-28" 2&1)
|
|
100
|
+
echo " $RESULT"
|
|
101
|
+
DIET_ID=$(echo "$RESULT" | grep -o '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | head -1)
|
|
102
|
+
if [ -z "$DIET_ID" ]; then
|
|
103
|
+
echo " ✗ failed to get diet id"
|
|
104
|
+
exit 1
|
|
105
|
+
fi
|
|
106
|
+
echo " ✓ diet added: $DIET_ID"
|
|
107
|
+
|
|
108
|
+
echo "17. Testing diet list..."
|
|
109
|
+
$CLI diet list --last 7d > /dev/null
|
|
110
|
+
echo " ✓ diet list ok"
|
|
111
|
+
|
|
112
|
+
echo "18. Testing diet stats..."
|
|
113
|
+
$CLI diet stats --last 30d > /dev/null
|
|
114
|
+
echo " ✓ diet stats ok"
|
|
115
|
+
|
|
116
|
+
echo "19. Testing diet delete..."
|
|
117
|
+
$CLI diet delete $DIET_ID > /dev/null
|
|
118
|
+
echo " ✓ diet delete ok"
|
|
119
|
+
|
|
120
|
+
# 6. Sleep CRUD
|
|
121
|
+
echo ""
|
|
122
|
+
echo "=== Sleep ==="
|
|
123
|
+
echo "20. Testing sleep add..."
|
|
124
|
+
RESULT=$($CLI sleep add --duration 7.5 --bedtime "23:00" --waketime "06:30" 2&1)
|
|
125
|
+
echo " $RESULT"
|
|
126
|
+
SLEEP_ID=$(echo "$RESULT" | grep -o '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | head -1)
|
|
127
|
+
if [ -z "$SLEEP_ID" ]; then
|
|
128
|
+
echo " ✗ failed to get sleep id"
|
|
129
|
+
exit 1
|
|
130
|
+
fi
|
|
131
|
+
echo " ✓ sleep added: $SLEEP_ID"
|
|
132
|
+
|
|
133
|
+
echo "21. Testing sleep list..."
|
|
134
|
+
$CLI sleep list --last 7d > /dev/null
|
|
135
|
+
echo " ✓ sleep list ok"
|
|
136
|
+
|
|
137
|
+
echo "22. Testing sleep stats..."
|
|
138
|
+
$CLI sleep stats --last 30d > /dev/null
|
|
139
|
+
echo " ✓ sleep stats ok"
|
|
140
|
+
|
|
141
|
+
echo "23. Testing sleep delete..."
|
|
142
|
+
$CLI sleep delete $SLEEP_ID > /dev/null
|
|
143
|
+
echo " ✓ sleep delete ok"
|
|
144
|
+
|
|
145
|
+
# 7. Food
|
|
146
|
+
echo ""
|
|
147
|
+
echo "=== Food ==="
|
|
148
|
+
echo "24. Testing food search..."
|
|
149
|
+
$CLI food search "苹果" > /dev/null 2&1 || true
|
|
150
|
+
echo " ✓ food search ok"
|
|
151
|
+
|
|
152
|
+
# 8. Record CRUD (original)
|
|
153
|
+
echo ""
|
|
154
|
+
echo "=== Record ==="
|
|
155
|
+
echo "25. Testing record add..."
|
|
156
|
+
RESULT=$($CLI record add --type custom --data '{"test":true}' --tags e2e --note "auto test" 2&1)
|
|
157
|
+
echo " $RESULT"
|
|
158
|
+
RECORD_ID=$(echo "$RESULT" | grep -o '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | head -1)
|
|
159
|
+
if [ -z "$RECORD_ID" ]; then
|
|
160
|
+
echo " ✗ failed to get record id"
|
|
161
|
+
exit 1
|
|
162
|
+
fi
|
|
163
|
+
echo " ✓ record added: $RECORD_ID"
|
|
164
|
+
|
|
165
|
+
echo "26. Testing record get..."
|
|
166
|
+
$CLI record get --id $RECORD_ID > /dev/null
|
|
167
|
+
echo " ✓ record get ok"
|
|
168
|
+
|
|
169
|
+
echo "27. Testing record list..."
|
|
170
|
+
$CLI record list --tag e2e > /dev/null
|
|
171
|
+
echo " ✓ record list ok"
|
|
172
|
+
|
|
173
|
+
echo "28. Testing record update..."
|
|
174
|
+
$CLI record update --id $RECORD_ID --data '{"test":false}' > /dev/null
|
|
175
|
+
echo " ✓ record update ok"
|
|
176
|
+
|
|
177
|
+
echo "29. Testing record search..."
|
|
178
|
+
$CLI record search --query "auto test" > /dev/null
|
|
179
|
+
echo " ✓ record search ok"
|
|
180
|
+
|
|
181
|
+
echo "30. Testing record delete..."
|
|
182
|
+
$CLI record delete --id $RECORD_ID > /dev/null
|
|
183
|
+
echo " ✓ record delete ok"
|
|
184
|
+
|
|
185
|
+
# 9. Timeline
|
|
186
|
+
echo ""
|
|
187
|
+
echo "=== Timeline ==="
|
|
188
|
+
echo "31. Testing timeline..."
|
|
189
|
+
$CLI timeline --last 7d > /dev/null
|
|
190
|
+
echo " ✓ timeline ok"
|
|
191
|
+
|
|
192
|
+
# 10. Auth logout
|
|
193
|
+
echo ""
|
|
194
|
+
echo "=== Auth Logout ==="
|
|
195
|
+
echo "32. Testing auth logout..."
|
|
196
|
+
$CLI auth logout
|
|
197
|
+
echo " ✓ logout ok"
|
|
198
|
+
|
|
199
|
+
echo ""
|
|
200
|
+
echo "=== All extended tests passed! ==="
|