57 lines
1.8 KiB
Bash
Executable File
57 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Simple prompts QA - 4 test cases
|
|
|
|
API="http://localhost:8082"
|
|
AUTH="Authorization: Bearer test-token-sophie"
|
|
|
|
echo "=== Prompts QA (no DB changes) ==="
|
|
echo
|
|
|
|
# Get freeform prompt ID (creates one if needed)
|
|
freeform_id=$(curl -s "$API/api/prompts?dossier=4f1ffbc65c0a44d9" -H "$AUTH" | jq -r '.[] | select(.input_type=="freeform") | .id')
|
|
echo "Freeform prompt: $freeform_id"
|
|
echo
|
|
|
|
# Test function - responds to freeform which triggers prompt creation
|
|
test_input() {
|
|
local input="$1"
|
|
local expect_cat="$2"
|
|
echo "Input: $input"
|
|
|
|
result=$(curl -s -X POST "$API/api/prompts/respond" \
|
|
-H "Content-Type: application/json" \
|
|
-H "$AUTH" \
|
|
-d "{\"prompt_id\": \"$freeform_id\", \"response_raw\": \"$input\", \"action\": \"respond\"}")
|
|
|
|
new_prompt=$(echo "$result" | jq -r '.new_prompt // empty')
|
|
|
|
if [ -n "$new_prompt" ] && [ "$new_prompt" != "null" ]; then
|
|
question=$(echo "$new_prompt" | jq -r '.question // empty')
|
|
category=$(echo "$new_prompt" | jq -r '.category // empty')
|
|
type=$(echo "$new_prompt" | jq -r '.type // empty')
|
|
input_type=$(echo "$new_prompt" | jq -r '.input_type // empty')
|
|
|
|
if [ -n "$expect_cat" ] && [ "$category" = "$expect_cat" ]; then
|
|
echo " ✓ $question"
|
|
echo " [$category/$type] $input_type"
|
|
elif [ -n "$expect_cat" ]; then
|
|
echo " ✗ $question"
|
|
echo " Got: $category, Expected: $expect_cat"
|
|
else
|
|
echo " ? $question"
|
|
echo " [$category/$type] $input_type"
|
|
fi
|
|
else
|
|
echo " ✗ No new prompt created"
|
|
echo " Response: $result"
|
|
fi
|
|
echo
|
|
}
|
|
|
|
# Run tests
|
|
test_input "I take 2 capsules of Pure Magnesium Glutaminate every day" "supplement"
|
|
test_input "I stopped drinking coffee" "nutrition"
|
|
test_input "my blood pressure is 87 over 116" "vital"
|
|
test_input "My period started today" "fertility"
|
|
|
|
echo "=== Test finished ===" |