-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-e2e.sh
More file actions
109 lines (92 loc) · 5.62 KB
/
test-e2e.sh
File metadata and controls
109 lines (92 loc) · 5.62 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
#!/usr/bin/env bash
#
# cmds CLI End-to-End Test Script — core functionality
#
# Prerequisites:
# - cmds installed: npm run build && npm link
# - Runtime index exists: cmds scan (run at least once)
#
# Usage: bash test-e2e.sh
#
set -uo pipefail
source "$(dirname "$0")/scripts/e2e-lib.sh"
CMDS="cmds"
setup_e2e
# ── Pre-flight ────────────────────────────────────────────────
section "Pre-flight"
require_bin $CMDS "run npm run build"
INDEX="$HOME/.config/cmds/index.json"
if [[ -f "$INDEX" ]]; then
pass "Runtime index exists: $INDEX"
else
fail "Runtime index missing — run: cmds scan"; exit 1
fi
# ══════════════════════════════════════════════════════════════
# 1. find — basic search
# ══════════════════════════════════════════════════════════════
section "1. find — basic search"
run_cmd $CMDS find "list files"
assert_exit0
assert_nonempty
# ══════════════════════════════════════════════════════════════
# 2. find --json
# ══════════════════════════════════════════════════════════════
section "2. find --json"
run_cmd $CMDS find "compress files" --json
assert_exit0
assert_json_array
# ══════════════════════════════════════════════════════════════
# 3. find --limit
# ══════════════════════════════════════════════════════════════
section "3. find --limit"
run_cmd $CMDS find "network" --limit 2 --json
assert_exit0
assert_json_array_length_lte "$OUT" 2
# ══════════════════════════════════════════════════════════════
# 4. info — known command
# ══════════════════════════════════════════════════════════════
section "4. info — known command"
run_cmd $CMDS info ls
assert_exit0
assert_nonempty
# ══════════════════════════════════════════════════════════════
# 5. info --json
# ══════════════════════════════════════════════════════════════
section "5. info --json"
run_cmd $CMDS info ls --json
assert_exit0
assert_json_field "$OUT" "name"
# ══════════════════════════════════════════════════════════════
# 6. info — nonexistent command exits 1
# ══════════════════════════════════════════════════════════════
section "6. info — nonexistent command"
run_cmd $CMDS info __nonexistent_cmd_xyz__
assert_exit 1
# ══════════════════════════════════════════════════════════════
# 7. list
# ══════════════════════════════════════════════════════════════
section "7. list"
run_cmd $CMDS list
assert_exit0
assert_nonempty
# ══════════════════════════════════════════════════════════════
# 8. list --category
# ══════════════════════════════════════════════════════════════
section "8. list --category"
run_cmd $CMDS list --category filesystem
assert_exit0
assert_nonempty
# ══════════════════════════════════════════════════════════════
# 9. list --category --json
# ══════════════════════════════════════════════════════════════
section "9. list --category --json"
run_cmd $CMDS list --category network --json
assert_exit0
assert_json_array
# ══════════════════════════════════════════════════════════════
# 10. list — invalid category exits 1
# ══════════════════════════════════════════════════════════════
section "10. list — invalid category"
run_cmd $CMDS list --category __no_such_category__
assert_exit 1
summary_and_exit