Checking onboardin flow - fix 3
This commit is contained in:
@@ -298,19 +298,40 @@ echo -e "${STEP_ICONS[1]} ${PURPLE}STEP 2: BAKERY REGISTRATION${NC}"
|
||||
echo "Simulating onboarding page step 2 - 'Datos de Panadería'"
|
||||
echo ""
|
||||
|
||||
log_step "2.1. Registering bakery/tenant"
|
||||
log_step "2.1. Registering bakery/tenant with mock coordinates"
|
||||
|
||||
# Using exact schema from BakeryRegistration
|
||||
# Mock coordinates for Madrid locations (since geolocation service is not running)
|
||||
# These are real Madrid coordinates for testing weather and traffic data acquisition
|
||||
MADRID_COORDS=(
|
||||
"40.4168:-3.7038" # Sol (city center)
|
||||
"40.4378:-3.6795" # Retiro area
|
||||
"40.4093:-3.6936" # Atocha area
|
||||
"40.4517:-3.6847" # Chamberí area
|
||||
"40.3897:-3.6774" # Delicias area
|
||||
)
|
||||
|
||||
# Select random coordinates from Madrid locations
|
||||
SELECTED_COORDS=${MADRID_COORDS[$((RANDOM % ${#MADRID_COORDS[@]}))]}
|
||||
IFS=':' read -r MOCK_LATITUDE MOCK_LONGITUDE <<< "$SELECTED_COORDS"
|
||||
|
||||
echo "Using mock coordinates for Madrid:"
|
||||
echo " Latitude: $MOCK_LATITUDE"
|
||||
echo " Longitude: $MOCK_LONGITUDE"
|
||||
echo " (This simulates the address-to-coordinates conversion service)"
|
||||
|
||||
# Using exact schema from BakeryRegistration with added coordinates
|
||||
BAKERY_DATA="{
|
||||
\"name\": \"Panadería Test $(date +%H%M)\",
|
||||
\"business_type\": \"bakery\",
|
||||
\"address\": \"Calle Gran Vía 123\",
|
||||
\"city\": \"Madrid\",
|
||||
\"postal_code\": \"28001\",
|
||||
\"phone\": \"+34600123456\"
|
||||
\"phone\": \"+34600123456\",
|
||||
\"latitude\": $MOCK_LATITUDE,
|
||||
\"longitude\": $MOCK_LONGITUDE
|
||||
}"
|
||||
|
||||
echo "Bakery Data:"
|
||||
echo "Bakery Data with mock coordinates:"
|
||||
echo "$BAKERY_DATA" | python3 -m json.tool
|
||||
|
||||
BAKERY_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST "$API_BASE/api/v1/tenants/register" \
|
||||
@@ -330,6 +351,37 @@ if check_response "$BAKERY_RESPONSE" "Bakery Registration"; then
|
||||
TENANT_ID=$(extract_json_field "$BAKERY_RESPONSE" "id")
|
||||
if [ -n "$TENANT_ID" ]; then
|
||||
log_success "Tenant ID extracted: $TENANT_ID"
|
||||
log_success "Mock coordinates will be used for weather/traffic data: ($MOCK_LATITUDE, $MOCK_LONGITUDE)"
|
||||
|
||||
# Store coordinates for later use in training
|
||||
echo "BAKERY_LATITUDE=$MOCK_LATITUDE" > /tmp/bakery_coords.env
|
||||
echo "BAKERY_LONGITUDE=$MOCK_LONGITUDE" >> /tmp/bakery_coords.env
|
||||
echo "TENANT_ID=$TENANT_ID" >> /tmp/bakery_coords.env
|
||||
|
||||
log_step "2.2. Testing weather data acquisition with mock coordinates"
|
||||
# Test if weather service can use these coordinates
|
||||
WEATHER_TEST_RESPONSE=$(curl -s -X GET "$API_BASE/api/v1/training/$TENANT_ID/weather/current?latitude=$MOCK_LATITUDE&longitude=$MOCK_LONGITUDE" \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "X-Tenant-ID: $TENANT_ID" 2>/dev/null || echo '{"status":"service_unavailable"}')
|
||||
|
||||
if echo "$WEATHER_TEST_RESPONSE" | grep -q '"temperature"\|"weather"'; then
|
||||
log_success "Weather service can use mock coordinates"
|
||||
else
|
||||
log_warning "Weather service test skipped (coordinates stored for training)"
|
||||
fi
|
||||
|
||||
log_step "2.3. Testing traffic data acquisition with mock coordinates"
|
||||
# Test if traffic service can use these coordinates
|
||||
TRAFFIC_TEST_RESPONSE=$(curl -s -X GET "$API_BASE/api/v1/training/$TENANT_ID/traffic/current?latitude=$MOCK_LATITUDE&longitude=$MOCK_LONGITUDE" \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "X-Tenant-ID: $TENANT_ID" 2>/dev/null || echo '{"status":"service_unavailable"}')
|
||||
|
||||
if echo "$TRAFFIC_TEST_RESPONSE" | grep -q '"traffic_volume"\|"intensity"'; then
|
||||
log_success "Traffic service can use mock coordinates"
|
||||
else
|
||||
log_warning "Traffic service test skipped (coordinates stored for training)"
|
||||
fi
|
||||
|
||||
else
|
||||
log_error "Failed to extract tenant ID"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user