Skip to content

Commit 020840c

Browse files
committed
test: cover session start and profile export flows
1 parent 7348923 commit 020840c

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

tests/test-profile-tools.sh

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# CodeSensei — Profile Tools Regression Tests
3-
# Covers doctor/import scripts and secret redaction in command logging.
3+
# Covers session start, doctor/import/export scripts, and secret redaction in command logging.
44

55
set -euo pipefail
66

@@ -68,7 +68,37 @@ echo "━━━ CodeSensei Profile Tools Tests ━━━"
6868
echo ""
6969

7070
# ============================================================
71-
# TEST GROUP 1: doctor.sh
71+
# TEST GROUP 1: session-start.sh
72+
# ============================================================
73+
echo "▸ session-start.sh"
74+
75+
rm -rf "$TEST_HOME/.code-sensei"
76+
START_OUTPUT=$(bash "$SCRIPT_DIR/scripts/session-start.sh")
77+
if [ -f "$TEST_HOME/.code-sensei/profile.json" ]; then
78+
pass "session-start creates a new profile"
79+
else
80+
fail "session-start creates a new profile" "profile not found"
81+
fi
82+
83+
START_BELT=$(jq -r '.belt' "$TEST_HOME/.code-sensei/profile.json")
84+
START_SESSIONS=$(jq -r '.sessions.total' "$TEST_HOME/.code-sensei/profile.json")
85+
START_STREAK=$(jq -r '.streak.current' "$TEST_HOME/.code-sensei/profile.json")
86+
if [ "$START_BELT" = "white" ] && [ "$START_SESSIONS" -eq 1 ] && [ "$START_STREAK" -eq 1 ]; then
87+
pass "session-start initializes default learning state"
88+
else
89+
fail "session-start initializes default learning state" "belt=$START_BELT sessions=$START_SESSIONS streak=$START_STREAK"
90+
fi
91+
92+
if echo "$START_OUTPUT" | grep -q "Welcome to CodeSensei"; then
93+
pass "session-start emits welcome guidance for new users"
94+
else
95+
fail "session-start emits welcome guidance for new users" "$START_OUTPUT"
96+
fi
97+
98+
echo ""
99+
100+
# ============================================================
101+
# TEST GROUP 2: doctor.sh
72102
# ============================================================
73103
echo "▸ doctor.sh"
74104

@@ -93,7 +123,33 @@ fi
93123
echo ""
94124

95125
# ============================================================
96-
# TEST GROUP 2: import-profile.sh
126+
# TEST GROUP 3: export-profile.sh
127+
# ============================================================
128+
echo "▸ export-profile.sh"
129+
130+
setup_profile
131+
export CLAUDE_PLUGIN_ROOT="$SCRIPT_DIR"
132+
EXPORT_RESULT=$(bash "$SCRIPT_DIR/scripts/export-profile.sh")
133+
if [ -f "$EXPORT_RESULT" ]; then
134+
pass "export-profile creates an export file"
135+
else
136+
fail "export-profile creates an export file" "file not found: $EXPORT_RESULT"
137+
fi
138+
139+
EXPORT_SCHEMA=$(jq -r '.schema_version' "$EXPORT_RESULT")
140+
EXPORT_BELT=$(jq -r '.profile.belt' "$EXPORT_RESULT")
141+
EXPORT_PLUGIN_VERSION=$(jq -r '.plugin_version' "$EXPORT_RESULT")
142+
if [ "$EXPORT_SCHEMA" = "1.0" ] && [ "$EXPORT_BELT" = "yellow" ] && [ "$EXPORT_PLUGIN_VERSION" != "unknown" ]; then
143+
pass "export-profile wraps the profile with metadata"
144+
else
145+
fail "export-profile wraps the profile with metadata" "schema=$EXPORT_SCHEMA belt=$EXPORT_BELT plugin_version=$EXPORT_PLUGIN_VERSION"
146+
fi
147+
rm -f "$EXPORT_RESULT"
148+
149+
echo ""
150+
151+
# ============================================================
152+
# TEST GROUP 4: import-profile.sh
97153
# ============================================================
98154
echo "▸ import-profile.sh"
99155

@@ -123,7 +179,7 @@ fi
123179
echo ""
124180

125181
# ============================================================
126-
# TEST GROUP 3: track-command.sh redaction
182+
# TEST GROUP 5: track-command.sh redaction
127183
# ============================================================
128184
echo "▸ track-command.sh redaction"
129185

0 commit comments

Comments
 (0)