|
1 | 1 | #!/bin/bash |
2 | 2 | # 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. |
4 | 4 |
|
5 | 5 | set -euo pipefail |
6 | 6 |
|
@@ -68,7 +68,37 @@ echo "━━━ CodeSensei Profile Tools Tests ━━━" |
68 | 68 | echo "" |
69 | 69 |
|
70 | 70 | # ============================================================ |
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 |
72 | 102 | # ============================================================ |
73 | 103 | echo "▸ doctor.sh" |
74 | 104 |
|
|
93 | 123 | echo "" |
94 | 124 |
|
95 | 125 | # ============================================================ |
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 |
97 | 153 | # ============================================================ |
98 | 154 | echo "▸ import-profile.sh" |
99 | 155 |
|
|
123 | 179 | echo "" |
124 | 180 |
|
125 | 181 | # ============================================================ |
126 | | -# TEST GROUP 3: track-command.sh redaction |
| 182 | +# TEST GROUP 5: track-command.sh redaction |
127 | 183 | # ============================================================ |
128 | 184 | echo "▸ track-command.sh redaction" |
129 | 185 |
|
|
0 commit comments