Fix test DTO fields

This commit is contained in:
2026-04-20 07:33:05 -06:00
parent aa48d2428d
commit 0b8bf02bd4

View File

@@ -50,7 +50,7 @@ check_field_gt() {
else FAIL=$((FAIL+1)); echo "FAIL: $label — expected > $threshold got '$actual'"; fi
}
id_from_body() { jq -r '.id // .userId // empty' /tmp/qa_body.json 2>/dev/null; }
id_from_body() { jq -r '.id // .userId // .prodId // .categoryId // .petId // .serviceId // .storeId // .appointmentId // .adoptionId // .saleId // .couponId // .supId // empty' /tmp/qa_body.json 2>/dev/null; }
echo "========================================="
echo " PET SHOP QA — Full Backend Test Suite"
@@ -109,21 +109,21 @@ check "GET /products?q=dog" 200 GET "/products?q=dog"
check "GET /products?categoryId=1" 200 GET "/products?categoryId=1"
check "GET /products/999999" 404 GET "/products/999999"
check "Create product (admin)" 201 POST "/products" "${A[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_Product","description":"QA test","price":9.99,"categoryId":1}'
check "Create product (admin)" 201 POST "/products" "${A[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_Product","prodDesc":"QA test","prodPrice":9.99,"categoryId":1}'
PROD_ID=$(id_from_body)
[ -n "$PROD_ID" ] && CLEANUP_PRODUCT_IDS+=("$PROD_ID")
check_field "Product name" ".prodName" "QA_TEST_Product"
check "Create product (customer)" 403 POST "/products" "${C[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_Nope","price":1,"categoryId":1}'
check "Create product (no auth)" 401 POST "/products" "${J[@]}" -d '{"prodName":"QA_TEST_Nope2","price":1,"categoryId":1}'
check "Create product missing name" 400 POST "/products" "${A[@]}" "${J[@]}" -d '{"price":1,"categoryId":1}'
check "Create product (customer)" 403 POST "/products" "${C[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_Nope","prodPrice":1,"categoryId":1}'
check "Create product (no auth)" 401 POST "/products" "${J[@]}" -d '{"prodName":"QA_TEST_Nope2","prodPrice":1,"categoryId":1}'
check "Create product missing name" 400 POST "/products" "${A[@]}" "${J[@]}" -d '{"prodPrice":1,"categoryId":1}'
if [ -n "$PROD_ID" ]; then
check "Update product" 200 PUT "/products/$PROD_ID" "${A[@]}" "${J[@]}" -d "{\"prodName\":\"QA_TEST_Updated\",\"description\":\"updated\",\"price\":19.99,\"categoryId\":1}"
check "Update product" 200 PUT "/products/$PROD_ID" "${A[@]}" "${J[@]}" -d "{\"prodName\":\"QA_TEST_Updated\",\"prodDesc\":\"updated\",\"prodPrice\":19.99,\"categoryId\":1}"
check_field "Updated name" ".prodName" "QA_TEST_Updated"
fi
check "Create product to delete" 201 POST "/products" "${A[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_DeleteMe","description":"del","price":1,"categoryId":1}'
check "Create product to delete" 201 POST "/products" "${A[@]}" "${J[@]}" -d '{"prodName":"QA_TEST_DeleteMe","prodDesc":"del","prodPrice":1,"categoryId":1}'
DEL_PROD_ID=$(id_from_body)
if [ -n "$DEL_PROD_ID" ]; then
check "Delete product" 200 DELETE "/products/$DEL_PROD_ID" "${A[@]}"
@@ -131,7 +131,7 @@ if [ -n "$DEL_PROD_ID" ]; then
fi
check "GET /products paginated" 200 GET "/products?page=0&size=5"
check "GET /products sorted" 200 GET "/products?sort=price,desc"
check "GET /products sorted" 200 GET "/products?sort=prodName,asc"
echo "--- 3. CATEGORIES ---"
@@ -139,19 +139,19 @@ check "GET /categories" 200 GET "/categories"
check "GET /categories/1" 200 GET "/categories/1"
check "GET /categories/999999" 404 GET "/categories/999999"
check "Create category (admin)" 201 POST "/categories" "${A[@]}" "${J[@]}" -d '{"catName":"QA_TEST_Category","description":"qa"}'
check "Create category (admin)" 201 POST "/categories" "${A[@]}" "${J[@]}" -d '{"categoryName":"QA_TEST_Category","categoryType":"qa"}'
CAT_ID=$(id_from_body)
[ -n "$CAT_ID" ] && CLEANUP_CATEGORY_IDS+=("$CAT_ID")
check "Create category (customer)" 403 POST "/categories" "${C[@]}" "${J[@]}" -d '{"catName":"QA_TEST_Nope"}'
check "Create category missing name" 400 POST "/categories" "${A[@]}" "${J[@]}" -d '{"description":"no name"}'
check "Create category (customer)" 403 POST "/categories" "${C[@]}" "${J[@]}" -d '{"categoryName":"QA_TEST_Nope"}'
check "Create category missing name" 400 POST "/categories" "${A[@]}" "${J[@]}" -d '{"categoryType":"no name"}'
if [ -n "$CAT_ID" ]; then
check "Update category" 200 PUT "/categories/$CAT_ID" "${A[@]}" "${J[@]}" -d "{\"catName\":\"QA_TEST_CatUpdated\",\"description\":\"updated\"}"
check_field "Updated cat name" ".catName" "QA_TEST_CatUpdated"
check "Update category" 200 PUT "/categories/$CAT_ID" "${A[@]}" "${J[@]}" -d "{\"categoryName\":\"QA_TEST_CatUpdated\",\"categoryType\":\"updated\"}"
check_field "Updated cat name" ".categoryName" "QA_TEST_CatUpdated"
fi
check "Create category to delete" 201 POST "/categories" "${A[@]}" "${J[@]}" -d '{"catName":"QA_TEST_CatDel","description":"del"}'
check "Create category to delete" 201 POST "/categories" "${A[@]}" "${J[@]}" -d '{"categoryName":"QA_TEST_CatDel","categoryType":"del"}'
DEL_CAT_ID=$(id_from_body)
if [ -n "$DEL_CAT_ID" ]; then
check "Delete category" 200 DELETE "/categories/$DEL_CAT_ID" "${A[@]}"
@@ -167,31 +167,31 @@ check "GET /pets?status=Available" 200 GET "/pets?status=Available"
check "GET /pets/999999" 404 GET "/pets/999999"
check "GET /my-pets (customer)" 200 GET "/my-pets" "${C[@]}"
check "Admin create pet" 201 POST "/pets" "${A[@]}" "${J[@]}" -d '{"name":"QA_TEST_Pet","species":"Dog","breed":"Labrador","age":2,"gender":"Male","status":"Available","storeId":1,"price":100,"description":"QA test pet"}'
check "Admin create pet" 201 POST "/pets" "${A[@]}" "${J[@]}" -d '{"petName":"QA_TEST_Pet","petSpecies":"Dog","petBreed":"Labrador","petAge":2,"petStatus":"Available","storeId":1,"petPrice":100}'
PET_ID=$(id_from_body)
[ -n "$PET_ID" ] && CLEANUP_PET_IDS+=("$PET_ID")
check_field "Pet name" ".name" "QA_TEST_Pet"
check_field "Pet species" ".species" "Dog"
check_field "Pet name" ".petName" "QA_TEST_Pet"
check_field "Pet species" ".petSpecies" "Dog"
if [ -n "$PET_ID" ]; then
check "Update pet" 200 PUT "/pets/$PET_ID" "${A[@]}" "${J[@]}" -d "{\"name\":\"QA_TEST_PetUpd\",\"species\":\"Dog\",\"breed\":\"Labrador\",\"age\":3,\"gender\":\"Male\",\"status\":\"Available\",\"storeId\":1,\"price\":150,\"description\":\"updated\"}"
check_field "Updated pet name" ".name" "QA_TEST_PetUpd"
check "Update pet" 200 PUT "/pets/$PET_ID" "${A[@]}" "${J[@]}" -d "{\"petName\":\"QA_TEST_PetUpd\",\"petSpecies\":\"Dog\",\"petBreed\":\"Labrador\",\"petAge\":3,\"petStatus\":\"Available\",\"storeId\":1,\"petPrice\":150}"
check_field "Updated pet name" ".petName" "QA_TEST_PetUpd"
fi
check "Admin create pet to delete" 201 POST "/pets" "${A[@]}" "${J[@]}" -d '{"name":"QA_TEST_PetDel","species":"Cat","breed":"Siamese","age":1,"gender":"Female","status":"Available","storeId":1,"price":50,"description":"del"}'
check "Admin create pet to delete" 201 POST "/pets" "${A[@]}" "${J[@]}" -d '{"petName":"QA_TEST_PetDel","petSpecies":"Cat","petBreed":"Siamese","petAge":1,"petStatus":"Available","storeId":1,"petPrice":50}'
DEL_PET_ID=$(id_from_body)
if [ -n "$DEL_PET_ID" ]; then
check "Delete pet" 200 DELETE "/pets/$DEL_PET_ID" "${A[@]}"
check "GET deleted pet" 404 GET "/pets/$DEL_PET_ID"
fi
check "Customer create my-pet" 201 POST "/my-pets" "${C[@]}" "${J[@]}" -d '{"name":"QA_TEST_MyPet","species":"Rabbit","breed":"Holland Lop","age":1,"gender":"Female","description":"my pet"}'
check "Customer create my-pet" 201 POST "/my-pets" "${C[@]}" "${J[@]}" -d '{"petName":"QA_TEST_MyPet","species":"Rabbit","breed":"Holland Lop","petAge":1}'
MY_PET_ID=$(id_from_body)
[ -n "$MY_PET_ID" ] && CLEANUP_MYPET_IDS+=("$MY_PET_ID")
check "GET /my-pets has new pet" 200 GET "/my-pets" "${C[@]}"
check "Create pet (customer direct)" 403 POST "/pets" "${C[@]}" "${J[@]}" -d '{"name":"QA_TEST_Nope","species":"Dog","breed":"Lab","age":1,"gender":"Male","status":"Available","storeId":1,"price":10}'
check "Create pet (no auth)" 401 POST "/pets" "${J[@]}" -d '{"name":"QA_TEST_Nope2","species":"Dog","breed":"Lab","age":1,"gender":"Male","status":"Available","storeId":1,"price":10}'
check "Create pet (customer direct)" 403 POST "/pets" "${C[@]}" "${J[@]}" -d '{"petName":"QA_TEST_Nope","petSpecies":"Dog","petBreed":"Lab","petAge":1,"petStatus":"Available","storeId":1,"petPrice":10}'
check "Create pet (no auth)" 401 POST "/pets" "${J[@]}" -d '{"petName":"QA_TEST_Nope2","petSpecies":"Dog","petBreed":"Lab","petAge":1,"petStatus":"Available","storeId":1,"petPrice":10}'
check "GET /pets paginated" 200 GET "/pets?page=0&size=5"
echo "--- 5. SERVICES ---"
@@ -201,21 +201,21 @@ check "GET /services/1" 200 GET "/services/1"
check "GET /services?species=Dog" 200 GET "/services?species=Dog"
check "GET /services/999999" 404 GET "/services/999999"
check "Create service (admin)" 201 POST "/services" "${A[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_Service","description":"qa svc","basePrice":25.00,"duration":30,"species":["Dog","Cat"]}'
check "Create service (admin)" 201 POST "/services" "${A[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_Service","serviceDesc":"qa svc","servicePrice":25.00,"serviceDuration":30,"species":["Dog","Cat"]}'
SVC_ID=$(id_from_body)
[ -n "$SVC_ID" ] && CLEANUP_SERVICE_IDS+=("$SVC_ID")
check_field "Service name" ".serviceName" "QA_TEST_Service"
if [ -n "$SVC_ID" ]; then
check "Update service" 200 PUT "/services/$SVC_ID" "${A[@]}" "${J[@]}" -d "{\"serviceName\":\"QA_TEST_SvcUpd\",\"description\":\"upd\",\"basePrice\":30,\"duration\":45,\"species\":[\"Dog\"]}"
check "Update service" 200 PUT "/services/$SVC_ID" "${A[@]}" "${J[@]}" -d "{\"serviceName\":\"QA_TEST_SvcUpd\",\"serviceDesc\":\"upd\",\"servicePrice\":30,\"serviceDuration\":45,\"species\":[\"Dog\"]}"
fi
check "Create service to delete" 201 POST "/services" "${A[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_SvcDel","description":"del","basePrice":10,"duration":15,"species":["Cat"]}'
check "Create service to delete" 201 POST "/services" "${A[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_SvcDel","serviceDesc":"del","servicePrice":10,"serviceDuration":15,"species":["Cat"]}'
DEL_SVC_ID=$(id_from_body)
if [ -n "$DEL_SVC_ID" ]; then
check "Delete service" 200 DELETE "/services/$DEL_SVC_ID" "${A[@]}"
fi
check "Create service (customer)" 403 POST "/services" "${C[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_Nope","basePrice":10,"duration":10,"species":["Dog"]}'
check "Create service (customer)" 403 POST "/services" "${C[@]}" "${J[@]}" -d '{"serviceName":"QA_TEST_Nope","servicePrice":10,"serviceDuration":10,"species":["Dog"]}'
echo "--- 6. STORES ---"
@@ -223,21 +223,21 @@ check "GET /stores" 200 GET "/stores"
check "GET /stores/1" 200 GET "/stores/1"
check "GET /stores/999999" 404 GET "/stores/999999"
check "Create store (admin)" 201 POST "/stores" "${A[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_Store","address":"123 QA St","city":"Testville","state":"QA","zipCode":"00000","phone":"5559999999"}'
check "Create store (admin)" 201 POST "/stores" "${A[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_Store","address":"123 QA St","phone":"5559999999","email":"qastore@test.com"}'
STORE_ID=$(id_from_body)
[ -n "$STORE_ID" ] && CLEANUP_STORE_IDS+=("$STORE_ID")
if [ -n "$STORE_ID" ]; then
check "Update store" 200 PUT "/stores/$STORE_ID" "${A[@]}" "${J[@]}" -d "{\"storeName\":\"QA_TEST_StoreUpd\",\"address\":\"456 QA Ave\",\"city\":\"Testville\",\"state\":\"QA\",\"zipCode\":\"00001\",\"phone\":\"5559999998\"}"
check "Update store" 200 PUT "/stores/$STORE_ID" "${A[@]}" "${J[@]}" -d "{\"storeName\":\"QA_TEST_StoreUpd\",\"address\":\"456 QA Ave\",\"phone\":\"5559999998\",\"email\":\"qastoreupd@test.com\"}"
fi
check "Create store to delete" 201 POST "/stores" "${A[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_StoreDel","address":"789 Del Rd","city":"Gone","state":"QA","zipCode":"00002","phone":"5559999997"}'
check "Create store to delete" 201 POST "/stores" "${A[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_StoreDel","address":"789 Del Rd","phone":"5559999997","email":"qastoredel@test.com"}'
DEL_STORE_ID=$(id_from_body)
if [ -n "$DEL_STORE_ID" ]; then
check "Delete store" 200 DELETE "/stores/$DEL_STORE_ID" "${A[@]}"
fi
check "Create store (staff)" 403 POST "/stores" "${S[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_Nope","address":"x","city":"x","state":"x","zipCode":"x","phone":"x"}'
check "Create store (staff)" 403 POST "/stores" "${S[@]}" "${J[@]}" -d '{"storeName":"QA_TEST_Nope","address":"x","phone":"x","email":"x@x.com"}'
echo "--- 7. USERS / EMPLOYEES / CUSTOMERS ---"
@@ -276,34 +276,34 @@ check "GET /appointments?status=Scheduled" 200 GET "/appointments?status=Schedul
check "GET /appointments/availability" 200 GET "/appointments/availability?storeId=1&serviceId=1&date=2027-06-01" "${A[@]}"
check "GET /appointments/999999" 404 GET "/appointments/999999" "${A[@]}"
check "Create appointment" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-06-15","appointmentTime":"10:00","notes":"QA_TEST"}'
check "Create appointment" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-06-15","appointmentTime":"10:00","appointmentStatus":"Scheduled"}'
APPT_ID=$(id_from_body)
[ -n "$APPT_ID" ] && CLEANUP_APPT_IDS+=("$APPT_ID")
check_field "Appointment status" ".status" "Scheduled"
check_field "Appointment status" ".appointmentStatus" "Scheduled"
if [ -n "$APPT_ID" ]; then
check "Cancel appointment" 200 PUT "/appointments/$APPT_ID" "${A[@]}" "${J[@]}" -d "{\"petId\":53,\"customerId\":32,\"storeId\":2,\"employeeId\":7,\"serviceId\":1,\"appointmentDate\":\"2027-06-15\",\"appointmentTime\":\"10:00\",\"status\":\"Cancelled\",\"notes\":\"QA_TEST cancelled\"}"
check_field "Cancelled status" ".status" "Cancelled"
check "Cancel appointment" 200 PUT "/appointments/$APPT_ID" "${A[@]}" "${J[@]}" -d "{\"petId\":53,\"customerId\":32,\"storeId\":2,\"employeeId\":7,\"serviceId\":1,\"appointmentDate\":\"2027-06-15\",\"appointmentTime\":\"10:00\",\"appointmentStatus\":\"Cancelled\"}"
check_field "Cancelled status" ".appointmentStatus" "Cancelled"
fi
check "Create appointment to delete" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-07-01","appointmentTime":"14:00","notes":"QA_TEST_DEL"}'
check "Create appointment to delete" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-07-01","appointmentTime":"14:00","appointmentStatus":"Scheduled"}'
DEL_APPT_ID=$(id_from_body)
if [ -n "$DEL_APPT_ID" ]; then
check "Delete appointment" 200 DELETE "/appointments/$DEL_APPT_ID" "${A[@]}"
fi
check "Appointment past date" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2020-01-01","appointmentTime":"10:00","notes":"QA_TEST past"}'
check "Appointment past date" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2020-01-01","appointmentTime":"10:00","appointmentStatus":"Scheduled"}'
check "Pet-service mismatch" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":38,"customerId":17,"storeId":1,"employeeId":4,"serviceId":1,"appointmentDate":"2027-08-01","appointmentTime":"10:00","notes":"QA_TEST mismatch"}'
check "Pet-service mismatch" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":38,"customerId":17,"storeId":1,"employeeId":4,"serviceId":1,"appointmentDate":"2027-08-01","appointmentTime":"10:00","appointmentStatus":"Scheduled"}'
check "Create appt for duplicate test" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-09-01","appointmentTime":"09:00","notes":"QA_TEST dup1"}'
check "Create appt for duplicate test" 201 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-09-01","appointmentTime":"09:00","appointmentStatus":"Scheduled"}'
DUP_APPT_ID=$(id_from_body)
[ -n "$DUP_APPT_ID" ] && CLEANUP_APPT_IDS+=("$DUP_APPT_ID")
check "Duplicate time/employee" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-09-01","appointmentTime":"09:00","notes":"QA_TEST dup2"}'
check "Duplicate time/employee" 400 POST "/appointments" "${A[@]}" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":2,"employeeId":7,"serviceId":1,"appointmentDate":"2027-09-01","appointmentTime":"09:00","appointmentStatus":"Scheduled"}'
check "GET /appointments (customer)" 200 GET "/appointments" "${C[@]}"
check "GET /appointments (staff)" 200 GET "/appointments" "${S[@]}"
check "Create appointment (no auth)" 401 POST "/appointments" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":1,"employeeId":4,"serviceId":1,"appointmentDate":"2027-10-01","appointmentTime":"10:00"}'
check "Create appointment (no auth)" 401 POST "/appointments" "${J[@]}" -d '{"petId":53,"customerId":32,"storeId":1,"employeeId":4,"serviceId":1,"appointmentDate":"2027-10-01","appointmentTime":"10:00","appointmentStatus":"Scheduled"}'
echo "--- 9. ADOPTIONS ---"
@@ -315,52 +315,52 @@ AVAIL_PET_1=""
AVAIL_PET_2=""
AVAIL_PET_3=""
curl -s "$BASE/pets?status=Available&size=5" "${A[@]}" -o /tmp/qa_avail.json 2>/dev/null
AVAIL_PET_1=$(jq -r '.content[0].id // empty' /tmp/qa_avail.json 2>/dev/null)
AVAIL_PET_2=$(jq -r '.content[1].id // empty' /tmp/qa_avail.json 2>/dev/null)
AVAIL_PET_3=$(jq -r '.content[2].id // empty' /tmp/qa_avail.json 2>/dev/null)
AVAIL_PET_1=$(jq -r '.content[0].petId // empty' /tmp/qa_avail.json 2>/dev/null)
AVAIL_PET_2=$(jq -r '.content[1].petId // empty' /tmp/qa_avail.json 2>/dev/null)
AVAIL_PET_3=$(jq -r '.content[2].petId // empty' /tmp/qa_avail.json 2>/dev/null)
if [ -n "$AVAIL_PET_1" ]; then
check "Staff create adoption (Pending)" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_1,\"customerId\":32,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST adopt1\"}"
check "Staff create adoption (Pending)" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_1,\"customerId\":32,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
ADOPT_ID_1=$(id_from_body)
[ -n "$ADOPT_ID_1" ] && CLEANUP_ADOPTION_IDS+=("$ADOPT_ID_1")
check "Pet now Pending" 200 GET "/pets/$AVAIL_PET_1"
check_field "Pet status Pending" ".status" "Pending"
check_field "Pet status Pending" ".petStatus" "Pending"
if [ -n "$ADOPT_ID_1" ]; then
check "Cancel adoption" 200 PUT "/adoptions/$ADOPT_ID_1" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_1,\"customerId\":32,\"storeId\":1,\"status\":\"Cancelled\",\"notes\":\"QA_TEST cancelled\"}"
check "Cancel adoption" 200 PUT "/adoptions/$ADOPT_ID_1" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_1,\"customerId\":32,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Cancelled\"}"
check "Pet back to Available" 200 GET "/pets/$AVAIL_PET_1"
check_field "Pet status Available" ".status" "Available"
check_field "Pet status Available" ".petStatus" "Available"
fi
fi
if [ -n "$AVAIL_PET_2" ]; then
check "Staff create adoption 2" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_2,\"customerId\":33,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST adopt2\"}"
check "Staff create adoption 2" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_2,\"customerId\":33,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
ADOPT_ID_2=$(id_from_body)
[ -n "$ADOPT_ID_2" ] && CLEANUP_ADOPTION_IDS+=("$ADOPT_ID_2")
if [ -n "$ADOPT_ID_2" ]; then
check "Complete adoption" 200 PUT "/adoptions/$ADOPT_ID_2" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_2,\"customerId\":33,\"storeId\":1,\"status\":\"Completed\",\"notes\":\"QA_TEST completed\"}"
check "Complete adoption" 200 PUT "/adoptions/$ADOPT_ID_2" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_2,\"customerId\":33,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Completed\"}"
check "Pet now Adopted" 200 GET "/pets/$AVAIL_PET_2"
check_field "Pet status Adopted" ".status" "Adopted"
check_field "Pet status Adopted" ".petStatus" "Adopted"
fi
fi
if [ -n "$AVAIL_PET_3" ]; then
check "Customer request adoption" 201 POST "/adoptions" "${C[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"storeId\":1,\"notes\":\"QA_TEST customer adopt\"}"
check "Customer request adoption" 201 POST "/adoptions" "${C[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\"}"
ADOPT_ID_3=$(id_from_body)
[ -n "$ADOPT_ID_3" ] && CLEANUP_ADOPTION_IDS+=("$ADOPT_ID_3")
if [ -n "$ADOPT_ID_3" ]; then
check "Cancel customer adoption" 200 PUT "/adoptions/$ADOPT_ID_3" "${C[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"storeId\":1,\"status\":\"Cancelled\",\"notes\":\"QA_TEST cust cancelled\"}"
check "Cancel customer adoption" 200 PUT "/adoptions/$ADOPT_ID_3" "${C[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Cancelled\"}"
check "Pet Available again" 200 GET "/pets/$AVAIL_PET_3"
check_field "Pet Available after cancel" ".status" "Available"
check_field "Pet Available after cancel" ".petStatus" "Available"
fi
check "Adopt already pending" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"customerId\":34,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST pending block\"}"
check "Adopt already pending" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"customerId\":34,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
ADOPT_BLOCK_ID=$(id_from_body)
[ -n "$ADOPT_BLOCK_ID" ] && CLEANUP_ADOPTION_IDS+=("$ADOPT_BLOCK_ID")
check "Duplicate adoption for pending pet" 400 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"customerId\":35,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST dup\"}"
check "Duplicate adoption for pending pet" 400 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$AVAIL_PET_3,\"customerId\":35,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
fi
check "GET /adoptions (staff)" 200 GET "/adoptions" "${S[@]}"
@@ -375,15 +375,15 @@ check "GET /sales (customer)" 403 GET "/sales" "${C[@]}"
check "GET /sales/999999" 404 GET "/sales/999999" "${A[@]}"
curl -s "$BASE/inventory?storeId=1" "${A[@]}" -o /tmp/qa_inv_before.json 2>/dev/null
INV_BEFORE=$(jq -r '.content[] | select(.productId == 1) | .quantity // 0' /tmp/qa_inv_before.json 2>/dev/null | head -1)
INV_BEFORE=$(jq -r '.content[] | select(.prodId == 1) | .quantity // 0' /tmp/qa_inv_before.json 2>/dev/null | head -1)
check "Staff create sale" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":1,"quantity":1}],"notes":"QA_TEST sale"}'
check "Staff create sale" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":1,"quantity":1}]}'
SALE_ID=$(id_from_body)
[ -n "$SALE_ID" ] && CLEANUP_SALE_IDS+=("$SALE_ID")
if [ -n "$INV_BEFORE" ] && [ "$INV_BEFORE" != "" ] && [ "$INV_BEFORE" != "null" ]; then
curl -s "$BASE/inventory?storeId=1" "${A[@]}" -o /tmp/qa_inv_after.json 2>/dev/null
INV_AFTER=$(jq -r '.content[] | select(.productId == 1) | .quantity // 0' /tmp/qa_inv_after.json 2>/dev/null | head -1)
INV_AFTER=$(jq -r '.content[] | select(.prodId == 1) | .quantity // 0' /tmp/qa_inv_after.json 2>/dev/null | head -1)
if [ -n "$INV_AFTER" ] && [ "$INV_AFTER" != "null" ] && [ "$((INV_BEFORE - 1))" = "$INV_AFTER" ]; then
PASS=$((PASS+1))
else
@@ -391,12 +391,12 @@ if [ -n "$INV_BEFORE" ] && [ "$INV_BEFORE" != "" ] && [ "$INV_BEFORE" != "null"
fi
fi
check "Sale non-existent product" 404 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":999999,"quantity":1}]}'
check "Sale zero quantity" 400 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":1,"quantity":0}]}'
check "Sale (no auth)" 401 POST "/sales" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":1,"quantity":1}]}'
check "Sale (customer)" 403 POST "/sales" "${C[@]}" "${J[@]}" -d '{"storeId":1,"customerId":15,"items":[{"productId":1,"quantity":1}]}'
check "Sale non-existent product" 404 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":999999,"quantity":1}]}'
check "Sale zero quantity" 400 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":1,"quantity":0}]}'
check "Sale (no auth)" 401 POST "/sales" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":1,"quantity":1}]}'
check "Sale (customer)" 403 POST "/sales" "${C[@]}" "${J[@]}" -d '{"storeId":1,"customerId":15,"items":[{"prodId":1,"quantity":1}]}'
check "Staff create sale 2" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":2,"quantity":1}],"notes":"QA_TEST sale2"}'
check "Staff create sale 2" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":2,"quantity":1}]}'
SALE_ID_2=$(id_from_body)
[ -n "$SALE_ID_2" ] && CLEANUP_SALE_IDS+=("$SALE_ID_2")
@@ -407,46 +407,46 @@ echo "--- 11. CART ---"
check "GET /cart (customer)" 200 GET "/cart?storeId=1" "${C[@]}"
check "Add cart item" 200 POST "/cart/items" "${C[@]}" "${J[@]}" -d '{"productId":1,"storeId":1,"quantity":1}'
if [ "$(jq -r '.status // empty' /tmp/qa_body.json 2>/dev/null)" = "" ]; then
check "Add cart item alt" 201 POST "/cart/items" "${C[@]}" "${J[@]}" -d '{"productId":2,"storeId":1,"quantity":1}'
check "Add cart item" 200 POST "/cart/add" "${C[@]}" "${J[@]}" -d '{"prodId":1,"storeId":1,"quantity":1}'
if [ "$(jq -r '.cartStatus // empty' /tmp/qa_body.json 2>/dev/null)" = "" ]; then
check "Add cart item alt" 200 POST "/cart/add" "${C[@]}" "${J[@]}" -d '{"prodId":2,"storeId":1,"quantity":1}'
fi
check "GET cart with item" 200 GET "/cart?storeId=1" "${C[@]}"
CART_SUBTOTAL=$(jq -r '.subtotal // .totalBeforeDiscount // 0' /tmp/qa_body.json 2>/dev/null)
CART_ITEM_ID=$(jq -r '.items[0].id // .items[0].cartItemId // empty' /tmp/qa_body.json 2>/dev/null)
CART_SUBTOTAL=$(jq -r '.subtotalAmount // 0' /tmp/qa_body.json 2>/dev/null)
CART_ITEM_ID=$(jq -r '.items[0].cartItemId // empty' /tmp/qa_body.json 2>/dev/null)
if [ -n "$CART_ITEM_ID" ]; then
check "Update cart qty" 200 PUT "/cart/items/$CART_ITEM_ID" "${C[@]}" "${J[@]}" -d '{"quantity":2}'
check "Update cart qty" 200 PUT "/cart/update" "${C[@]}" "${J[@]}" -d "{\"cartItemId\":$CART_ITEM_ID,\"quantity\":2}"
check "GET cart after qty update" 200 GET "/cart?storeId=1" "${C[@]}"
fi
check "Apply coupon WELCOME10" 200 POST "/cart/coupon" "${C[@]}" "${J[@]}" -d '{"couponCode":"WELCOME10","storeId":1}'
check "Apply coupon WELCOME10" 200 POST "/cart/apply-coupon?storeId=1" "${C[@]}" "${J[@]}" -d '{"couponCode":"WELCOME10"}'
check "GET cart with coupon" 200 GET "/cart?storeId=1" "${C[@]}"
DISCOUNT=$(jq -r '.discount // .totalDiscount // 0' /tmp/qa_body.json 2>/dev/null)
DISCOUNT=$(jq -r '.discountAmount // 0' /tmp/qa_body.json 2>/dev/null)
check "Remove coupon" 200 DELETE "/cart/coupon?storeId=1" "${C[@]}"
check "Remove coupon" 200 DELETE "/cart/coupon?storeId=1" "${C[@]}" "${J[@]}"
check "GET cart no coupon" 200 GET "/cart?storeId=1" "${C[@]}"
check "Apply points" 200 POST "/cart/points" "${C[@]}" "${J[@]}" -d '{"points":10,"storeId":1}'
check "Remove points" 200 DELETE "/cart/points?storeId=1" "${C[@]}"
check "Apply points" 200 POST "/cart/apply-points?storeId=1&useLoyaltyPoints=true" "${C[@]}" "${J[@]}"
check "Remove points" 200 POST "/cart/apply-points?storeId=1&useLoyaltyPoints=false" "${C[@]}" "${J[@]}"
if [ -n "$CART_ITEM_ID" ]; then
check "Remove cart item" 200 DELETE "/cart/items/$CART_ITEM_ID" "${C[@]}"
check "Remove cart item" 200 DELETE "/cart/remove/$CART_ITEM_ID" "${C[@]}"
fi
check "Clear cart" 200 DELETE "/cart?storeId=1" "${C[@]}"
check "Clear cart" 204 DELETE "/cart/clear?storeId=1" "${C[@]}"
check "Add item qty 0" 400 POST "/cart/items" "${C[@]}" "${J[@]}" -d '{"productId":1,"storeId":1,"quantity":0}'
check "Apply invalid coupon" 400 POST "/cart/coupon" "${C[@]}" "${J[@]}" -d '{"couponCode":"FAKECOUPON999","storeId":1}'
check "Add item qty 0" 400 POST "/cart/add" "${C[@]}" "${J[@]}" -d '{"prodId":1,"storeId":1,"quantity":0}'
check "Apply invalid coupon" 400 POST "/cart/apply-coupon?storeId=1" "${C[@]}" "${J[@]}" -d '{"couponCode":"FAKECOUPON999"}'
check "Checkout empty cart" 400 POST "/cart/checkout" "${C[@]}" "${J[@]}" -d '{"storeId":1}'
check "Add item for checkout test" 200 POST "/cart/items" "${C[@]}" "${J[@]}" -d '{"productId":1,"storeId":1,"quantity":1}'
check "Add item for checkout test" 200 POST "/cart/add" "${C[@]}" "${J[@]}" -d '{"prodId":1,"storeId":1,"quantity":1}'
check "Checkout" 200 POST "/cart/checkout" "${C[@]}" "${J[@]}" -d '{"storeId":1}'
CHECKOUT_SALE_ID=$(jq -r '.id // .saleId // empty' /tmp/qa_body.json 2>/dev/null)
CHECKOUT_SALE_ID=$(jq -r '.cartId // empty' /tmp/qa_body.json 2>/dev/null)
[ -n "$CHECKOUT_SALE_ID" ] && CLEANUP_SALE_IDS+=("$CHECKOUT_SALE_ID")
check "Clear cart final" 200 DELETE "/cart?storeId=1" "${C[@]}"
check "Clear cart final" 204 DELETE "/cart/clear?storeId=1" "${C[@]}"
echo "--- 12. REFUNDS ---"
@@ -458,21 +458,21 @@ if [ -n "$CHECKOUT_SALE_ID" ]; then
CUST_SALE_ID="$CHECKOUT_SALE_ID"
else
curl -s "$BASE/sales/my" "${C[@]}" -o /tmp/qa_my_sales.json 2>/dev/null
CUST_SALE_ID=$(jq -r '.content[0].id // .[0].id // empty' /tmp/qa_my_sales.json 2>/dev/null)
CUST_SALE_ID=$(jq -r '.content[0].saleId // .[0].saleId // empty' /tmp/qa_my_sales.json 2>/dev/null)
fi
if [ -n "$CUST_SALE_ID" ]; then
check "Customer create refund" 201 POST "/refunds" "${C[@]}" "${J[@]}" -d "{\"saleId\":$CUST_SALE_ID,\"reason\":\"QA_TEST refund reason\"}"
check "Customer create refund" 201 POST "/refunds" "${C[@]}" "${J[@]}" -d "{\"saleId\":$CUST_SALE_ID,\"reason\":\"QA_TEST refund reason\",\"items\":[{\"prodId\":1,\"quantity\":1}]}"
REFUND_ID=$(id_from_body)
if [ -n "$REFUND_ID" ]; then
check "Staff approve refund" 200 PUT "/refunds/$REFUND_ID" "${S[@]}" "${J[@]}" -d "{\"status\":\"Approved\",\"saleId\":$CUST_SALE_ID,\"reason\":\"QA_TEST approved\"}"
check "Staff approve refund" 200 PUT "/refunds/$REFUND_ID" "${S[@]}" "${J[@]}" -d '{"status":"Approved"}'
check_field "Refund approved" ".status" "Approved"
fi
fi
check "Refund non-existent sale" 404 POST "/refunds" "${C[@]}" "${J[@]}" -d '{"saleId":999999,"reason":"QA_TEST nope"}'
check "Refund missing reason" 400 POST "/refunds" "${C[@]}" "${J[@]}" -d '{"saleId":1}'
check "Refund non-existent sale" 404 POST "/refunds" "${C[@]}" "${J[@]}" -d '{"saleId":999999,"reason":"QA_TEST nope","items":[{"prodId":1,"quantity":1}]}'
check "Refund missing reason" 400 POST "/refunds" "${C[@]}" "${J[@]}" -d '{"saleId":1,"items":[{"prodId":1,"quantity":1}]}'
check "GET /refunds (staff)" 200 GET "/refunds" "${S[@]}"
check "GET /refunds paginated" 200 GET "/refunds?page=0&size=5" "${A[@]}"
@@ -483,30 +483,30 @@ check "GET /coupons/1" 200 GET "/coupons/1" "${A[@]}"
check "GET /coupons/code/WELCOME10" 200 GET "/coupons/code/WELCOME10" "${A[@]}"
check "GET /coupons (customer)" 403 GET "/coupons" "${C[@]}"
check "Create coupon" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"QA_TEST_CPN","discountPercent":10,"description":"QA test coupon","expiryDate":"2028-12-31","maxUses":100}'
check "Create coupon" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_CPN","discountType":"PERCENTAGE","discountValue":10,"usageLimit":100}'
CPN_ID=$(id_from_body)
[ -n "$CPN_ID" ] && CLEANUP_COUPON_IDS+=("$CPN_ID")
check_field "Coupon code" ".code" "QA_TEST_CPN"
check_field "Coupon code" ".couponCode" "QA_TEST_CPN"
if [ -n "$CPN_ID" ]; then
check "Update coupon" 200 PUT "/coupons/$CPN_ID" "${A[@]}" "${J[@]}" -d "{\"code\":\"QA_TEST_CPN\",\"discountPercent\":15,\"description\":\"updated\",\"expiryDate\":\"2028-12-31\",\"maxUses\":50}"
check "Update coupon" 200 PUT "/coupons/$CPN_ID" "${A[@]}" "${J[@]}" -d "{\"couponCode\":\"QA_TEST_CPN\",\"discountType\":\"PERCENTAGE\",\"discountValue\":15,\"usageLimit\":50}"
fi
check "Create coupon to delete" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"QA_TEST_DEL","discountPercent":5,"description":"del","expiryDate":"2028-12-31","maxUses":10}'
check "Create coupon to delete" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_DEL","discountType":"PERCENTAGE","discountValue":5,"usageLimit":10}'
DEL_CPN_ID=$(id_from_body)
if [ -n "$DEL_CPN_ID" ]; then
check "Delete coupon" 200 DELETE "/coupons/$DEL_CPN_ID" "${A[@]}"
fi
check "Coupon 100% discount" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"QA_TEST_100","discountPercent":100,"description":"bad","expiryDate":"2028-12-31","maxUses":1}'
check "Coupon 150% discount" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"QA_TEST_150","discountPercent":150,"description":"bad","expiryDate":"2028-12-31","maxUses":1}'
check "Coupon 100% discount" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_100","discountType":"PERCENTAGE","discountValue":100,"usageLimit":1}'
check "Coupon 150% discount" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_150","discountType":"PERCENTAGE","discountValue":150,"usageLimit":1}'
check "Coupon 99.99%" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"QA_TEST_99","discountPercent":99.99,"description":"boundary","expiryDate":"2028-12-31","maxUses":1}'
check "Coupon 99.99%" 201 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_99","discountType":"PERCENTAGE","discountValue":99.99,"usageLimit":1}'
BOUNDARY_CPN_ID=$(id_from_body)
[ -n "$BOUNDARY_CPN_ID" ] && CLEANUP_COUPON_IDS+=("$BOUNDARY_CPN_ID")
check "Duplicate coupon code" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"code":"WELCOME10","discountPercent":5,"description":"dup","expiryDate":"2028-12-31","maxUses":1}'
check "Create coupon (customer)" 403 POST "/coupons" "${C[@]}" "${J[@]}" -d '{"code":"QA_TEST_NOPE","discountPercent":5,"description":"nope","expiryDate":"2028-12-31","maxUses":1}'
check "Duplicate coupon code" 400 POST "/coupons" "${A[@]}" "${J[@]}" -d '{"couponCode":"WELCOME10","discountType":"PERCENTAGE","discountValue":5,"usageLimit":1}'
check "Create coupon (customer)" 403 POST "/coupons" "${C[@]}" "${J[@]}" -d '{"couponCode":"QA_TEST_NOPE","discountType":"PERCENTAGE","discountValue":5,"usageLimit":1}'
echo "--- 14. SUPPLIERS / PRODUCT-SUPPLIERS / INVENTORY / PURCHASE-ORDERS ---"
@@ -514,15 +514,15 @@ check "GET /suppliers (admin)" 200 GET "/suppliers" "${A[@]}"
check "GET /suppliers/1" 200 GET "/suppliers/1" "${A[@]}"
check "GET /suppliers (customer)" 403 GET "/suppliers" "${C[@]}"
check "Create supplier" 201 POST "/suppliers" "${A[@]}" "${J[@]}" -d '{"supplierName":"QA_TEST_Supplier","contactName":"QA Contact","email":"qa_supplier@test.com","phone":"5553333333","address":"100 Supply Rd"}'
check "Create supplier" 201 POST "/suppliers" "${A[@]}" "${J[@]}" -d '{"supCompany":"QA_TEST_Supplier","supContactFirstName":"QA","supContactLastName":"Contact","supEmail":"qa_supplier@test.com","supPhone":"5553333333"}'
SUPP_ID=$(id_from_body)
[ -n "$SUPP_ID" ] && CLEANUP_SUPPLIER_IDS+=("$SUPP_ID")
if [ -n "$SUPP_ID" ]; then
check "Update supplier" 200 PUT "/suppliers/$SUPP_ID" "${A[@]}" "${J[@]}" -d "{\"supplierName\":\"QA_TEST_SuppUpd\",\"contactName\":\"QA Updated\",\"email\":\"qa_supp_upd@test.com\",\"phone\":\"5553333334\",\"address\":\"101 Supply Rd\"}"
check "Update supplier" 200 PUT "/suppliers/$SUPP_ID" "${A[@]}" "${J[@]}" -d "{\"supCompany\":\"QA_TEST_SuppUpd\",\"supContactFirstName\":\"QA\",\"supContactLastName\":\"Updated\",\"supEmail\":\"qa_supp_upd@test.com\",\"supPhone\":\"5553333334\"}"
fi
check "Create supplier to delete" 201 POST "/suppliers" "${A[@]}" "${J[@]}" -d '{"supplierName":"QA_TEST_SuppDel","contactName":"Del","email":"del@test.com","phone":"5550000000","address":"x"}'
check "Create supplier to delete" 201 POST "/suppliers" "${A[@]}" "${J[@]}" -d '{"supCompany":"QA_TEST_SuppDel","supContactFirstName":"Del","supContactLastName":"Test","supEmail":"del@test.com","supPhone":"5550000000"}'
DEL_SUPP_ID=$(id_from_body)
if [ -n "$DEL_SUPP_ID" ]; then
check "Delete supplier" 200 DELETE "/suppliers/$DEL_SUPP_ID" "${A[@]}"
@@ -551,7 +551,7 @@ if [ -n "$CONV_ID" ]; then
check "GET messages" 200 GET "/chat/conversations/$CONV_ID/messages" "${C[@]}"
check "Request human takeover" 200 POST "/chat/conversations/$CONV_ID/takeover" "${C[@]}" "${J[@]}" -d '{}'
check "Request human takeover" 200 POST "/chat/conversations/$CONV_ID/request-human" "${C[@]}" "${J[@]}" -d '{}'
check "Staff view conversations" 200 GET "/chat/conversations" "${S[@]}"
@@ -559,7 +559,7 @@ if [ -n "$CONV_ID" ]; then
check "GET conversation detail" 200 GET "/chat/conversations/$CONV_ID" "${S[@]}"
check "Close conversation" 200 PUT "/chat/conversations/$CONV_ID/close" "${S[@]}" "${J[@]}" -d '{}'
check "Close conversation" 200 PUT "/chat/conversations/$CONV_ID" "${S[@]}" "${J[@]}" -d '{"status":"CLOSED"}'
check "GET closed conversation" 200 GET "/chat/conversations/$CONV_ID" "${C[@]}"
check_field "Conversation closed" ".status" "CLOSED"
@@ -594,15 +594,15 @@ check "GET /dropdowns/customers/32/pets" 200 GET "/dropdowns/customers/32/pets"
echo "--- 17. CROSS-ENTITY ---"
curl -s "$BASE/inventory?storeId=1" "${A[@]}" -o /tmp/qa_cross_inv1.json 2>/dev/null
CROSS_INV_BEFORE=$(jq -r '.content[] | select(.productId == 2) | .quantity // 0' /tmp/qa_cross_inv1.json 2>/dev/null | head -1)
CROSS_INV_BEFORE=$(jq -r '.content[] | select(.prodId == 2) | .quantity // 0' /tmp/qa_cross_inv1.json 2>/dev/null | head -1)
check "Cross: create sale" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"productId":2,"quantity":1}],"notes":"QA_TEST_CROSS"}'
check "Cross: create sale" 201 POST "/sales" "${S[@]}" "${J[@]}" -d '{"storeId":1,"customerId":32,"items":[{"prodId":2,"quantity":1}]}'
CROSS_SALE_ID=$(id_from_body)
[ -n "$CROSS_SALE_ID" ] && CLEANUP_SALE_IDS+=("$CROSS_SALE_ID")
if [ -n "$CROSS_INV_BEFORE" ] && [ "$CROSS_INV_BEFORE" != "null" ] && [ "$CROSS_INV_BEFORE" != "" ]; then
curl -s "$BASE/inventory?storeId=1" "${A[@]}" -o /tmp/qa_cross_inv2.json 2>/dev/null
CROSS_INV_AFTER=$(jq -r '.content[] | select(.productId == 2) | .quantity // 0' /tmp/qa_cross_inv2.json 2>/dev/null | head -1)
CROSS_INV_AFTER=$(jq -r '.content[] | select(.prodId == 2) | .quantity // 0' /tmp/qa_cross_inv2.json 2>/dev/null | head -1)
if [ "$((CROSS_INV_BEFORE - 1))" = "$CROSS_INV_AFTER" ]; then
PASS=$((PASS+1))
else
@@ -611,12 +611,12 @@ if [ -n "$CROSS_INV_BEFORE" ] && [ "$CROSS_INV_BEFORE" != "null" ] && [ "$CROSS_
fi
if [ -n "$CROSS_SALE_ID" ]; then
check "Cross: create refund" 201 POST "/refunds" "${C[@]}" "${J[@]}" -d "{\"saleId\":$CROSS_SALE_ID,\"reason\":\"QA_TEST cross refund\"}"
check "Cross: create refund" 201 POST "/refunds" "${C[@]}" "${J[@]}" -d "{\"saleId\":$CROSS_SALE_ID,\"reason\":\"QA_TEST cross refund\",\"items\":[{\"prodId\":2,\"quantity\":1}]}"
CROSS_REFUND_ID=$(id_from_body)
if [ -n "$CROSS_REFUND_ID" ]; then
check "Cross: approve refund" 200 PUT "/refunds/$CROSS_REFUND_ID" "${S[@]}" "${J[@]}" -d "{\"status\":\"Approved\",\"saleId\":$CROSS_SALE_ID,\"reason\":\"QA_TEST cross approved\"}"
check "Cross: approve refund" 200 PUT "/refunds/$CROSS_REFUND_ID" "${S[@]}" "${J[@]}" -d '{"status":"Approved"}'
curl -s "$BASE/inventory?storeId=1" "${A[@]}" -o /tmp/qa_cross_inv3.json 2>/dev/null
CROSS_INV_RESTORED=$(jq -r '.content[] | select(.productId == 2) | .quantity // 0' /tmp/qa_cross_inv3.json 2>/dev/null | head -1)
CROSS_INV_RESTORED=$(jq -r '.content[] | select(.prodId == 2) | .quantity // 0' /tmp/qa_cross_inv3.json 2>/dev/null | head -1)
if [ -n "$CROSS_INV_RESTORED" ] && [ "$CROSS_INV_RESTORED" = "$CROSS_INV_BEFORE" ]; then
PASS=$((PASS+1))
else
@@ -626,35 +626,35 @@ if [ -n "$CROSS_SALE_ID" ]; then
fi
curl -s "$BASE/pets?status=Available&size=5&page=1" "${A[@]}" -o /tmp/qa_cross_avail.json 2>/dev/null
CROSS_PET=$(jq -r '.content[0].id // empty' /tmp/qa_cross_avail.json 2>/dev/null)
CROSS_PET=$(jq -r '.content[0].petId // empty' /tmp/qa_cross_avail.json 2>/dev/null)
if [ -n "$CROSS_PET" ]; then
check "Cross: create adoption Pending" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET,\"customerId\":35,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST cross adopt\"}"
check "Cross: create adoption Pending" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET,\"customerId\":35,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
CROSS_ADOPT_ID=$(id_from_body)
[ -n "$CROSS_ADOPT_ID" ] && CLEANUP_ADOPTION_IDS+=("$CROSS_ADOPT_ID")
check "Cross: pet is Pending" 200 GET "/pets/$CROSS_PET"
check_field "Cross pet Pending" ".status" "Pending"
check_field "Cross pet Pending" ".petStatus" "Pending"
if [ -n "$CROSS_ADOPT_ID" ]; then
check "Cross: complete adoption" 200 PUT "/adoptions/$CROSS_ADOPT_ID" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET,\"customerId\":35,\"storeId\":1,\"status\":\"Completed\",\"notes\":\"QA_TEST cross completed\"}"
check "Cross: complete adoption" 200 PUT "/adoptions/$CROSS_ADOPT_ID" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET,\"customerId\":35,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Completed\"}"
check "Cross: pet is Adopted" 200 GET "/pets/$CROSS_PET"
check_field "Cross pet Adopted" ".status" "Adopted"
check_field "Cross pet Adopted" ".petStatus" "Adopted"
fi
fi
curl -s "$BASE/pets?status=Available&size=5&page=2" "${A[@]}" -o /tmp/qa_cross_avail2.json 2>/dev/null
CROSS_PET_2=$(jq -r '.content[0].id // empty' /tmp/qa_cross_avail2.json 2>/dev/null)
CROSS_PET_2=$(jq -r '.content[0].petId // empty' /tmp/qa_cross_avail2.json 2>/dev/null)
if [ -n "$CROSS_PET_2" ]; then
check "Cross: adopt then cancel" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET_2,\"customerId\":36,\"storeId\":1,\"status\":\"Pending\",\"notes\":\"QA_TEST cross cancel\"}"
check "Cross: adopt then cancel" 201 POST "/adoptions" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET_2,\"customerId\":36,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Pending\"}"
CROSS_ADOPT_ID_2=$(id_from_body)
[ -n "$CROSS_ADOPT_ID_2" ] && CLEANUP_ADOPTION_IDS+=("$CROSS_ADOPT_ID_2")
if [ -n "$CROSS_ADOPT_ID_2" ]; then
check "Cross: cancel adoption" 200 PUT "/adoptions/$CROSS_ADOPT_ID_2" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET_2,\"customerId\":36,\"storeId\":1,\"status\":\"Cancelled\",\"notes\":\"QA_TEST cross cancelled\"}"
check "Cross: cancel adoption" 200 PUT "/adoptions/$CROSS_ADOPT_ID_2" "${S[@]}" "${J[@]}" -d "{\"petId\":$CROSS_PET_2,\"customerId\":36,\"sourceStoreId\":1,\"adoptionDate\":\"2027-06-15\",\"adoptionStatus\":\"Cancelled\"}"
check "Cross: pet Available" 200 GET "/pets/$CROSS_PET_2"
check_field "Cross pet Available" ".status" "Available"
check_field "Cross pet Available" ".petStatus" "Available"
fi
fi
@@ -662,7 +662,7 @@ echo ""
echo "--- CLEANUP ---"
for id in "${CLEANUP_CONV_IDS[@]}"; do
curl -s -o /dev/null -X PUT "$BASE/chat/conversations/$id/close" "${S[@]}" "${J[@]}" -d '{}' 2>/dev/null
curl -s -o /dev/null -X PUT "$BASE/chat/conversations/$id" "${S[@]}" "${J[@]}" -d '{"status":"CLOSED"}' 2>/dev/null
done
for id in "${CLEANUP_ADOPTION_IDS[@]}"; do