#!/bin/bash # Test Homepage Editor Functionality echo "==========================================" echo "Testing Homepage Editor" echo "==========================================" echo "" # Check if user can access homepage editor echo "1. Testing Homepage Editor Access..." curl -s -c /tmp/homepage_test.txt -X POST http://localhost:5000/admin/login \ -d "email=admin@skyartshop.com&password=Admin123!" -L > /dev/null 2>&1 curl -s -b /tmp/homepage_test.txt http://localhost:5000/admin/homepage | grep -q "Homepage Editor" && \ echo " ✓ Homepage Editor accessible" || echo " ✗ Homepage Editor not accessible" echo "" echo "2. Checking Database Structure..." PGPASSWORD='SkyArt2025Pass!' psql -h localhost -U skyartapp -d skyartshop -t -c \ "SELECT column_name FROM information_schema.columns WHERE table_name = 'homepagesections' ORDER BY ordinal_position;" | \ tr '\n' ', ' && echo "" echo "" echo "3. Current Homepage Sections:" PGPASSWORD='SkyArt2025Pass!' psql -h localhost -U skyartapp -d skyartshop -c \ "SELECT id, sectiontype, title, isactive, displayorder FROM homepagesections ORDER BY displayorder;" echo "" echo "4. Required Fields for Create:" echo " ✓ SectionType (required) - hero, inspiration, collection, promotion, custom" echo " ✓ Title (required)" echo " - Subtitle (optional)" echo " - Content (optional, uses CKEditor)" echo " - ImageUrl (optional, file upload)" echo " - ButtonText (optional)" echo " - ButtonUrl (optional)" echo " ✓ IsActive (checkbox, defaults to true)" echo " ✓ DisplayOrder (auto-calculated)" echo " ✓ AdditionalData (auto-initialized as empty dictionary)" echo "" echo "5. Access URLs:" echo " Admin Editor: https://skyarts.ddns.net/admin/homepage" echo " Create Section: https://skyarts.ddns.net/admin/homepage/section/create" echo " Frontend: https://skyarts.ddns.net/" echo "" echo "6. Testing Section Creation (SQL INSERT)..." PGPASSWORD='SkyArt2025Pass!' psql -h localhost -U skyartapp -d skyartshop << 'EOF' INSERT INTO homepagesections ( id, sectiontype, title, subtitle, content, imageurl, buttontext, buttonurl, isactive, displayorder, additionaldata, createdat, updatedat ) VALUES ( gen_random_uuid()::text, 'hero', 'Welcome to Sky Art Shop', 'Scrapbooking and Journaling Fun', '
Explore the world of creativity and self-expression
', '/uploads/images/hero-banner.jpg', 'Shop Now', '/shop', true, 0, '{}'::jsonb, now(), now() ) ON CONFLICT (id) DO NOTHING; EOF echo "" echo "7. Verifying Section Created:" PGPASSWORD='SkyArt2025Pass!' psql -h localhost -U skyartapp -d skyartshop -c \ "SELECT id, title, sectiontype, isactive FROM homepagesections WHERE sectiontype = 'hero';" echo "" echo "==========================================" echo "✅ Homepage Editor Ready!" echo "==========================================" echo "" echo "Next Steps:" echo "1. Visit: https://skyarts.ddns.net/admin/homepage" echo "2. Click 'Create New Section'" echo "3. Fill in required fields (Section Type, Title)" echo "4. Click 'Create Section'" echo "5. View on homepage: https://skyarts.ddns.net/"