#!/bin/bash # Test script for cache management functionality # This script demonstrates the new cache management features in cremote echo "๐Ÿงช Testing Cremote Cache Management Features" echo "=============================================" # Check if daemon is running echo "๐Ÿ“ก Checking daemon status..." if ! ./cremote status > /dev/null 2>&1; then echo "โŒ Daemon is not running. Please start it with: cremotedaemon" exit 1 fi echo "โœ… Daemon is running" # Open a new tab echo "๐ŸŒ Opening new tab..." TAB_ID=$(./cremote open-tab) if [ $? -ne 0 ]; then echo "โŒ Failed to open tab" exit 1 fi echo "โœ… Tab opened: $TAB_ID" # Load a test page echo "๐Ÿ“„ Loading test page..." ./cremote load-url --url="https://httpbin.org/cache/60" --timeout=10 if [ $? -ne 0 ]; then echo "โŒ Failed to load page" exit 1 fi echo "โœ… Page loaded" # Test 1: Disable cache echo "" echo "๐Ÿšซ Test 1: Disabling cache..." ./cremote disable-cache --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Cache disabled successfully" else echo "โŒ Failed to disable cache" fi # Test 2: Enable cache echo "" echo "โœ… Test 2: Enabling cache..." ./cremote enable-cache --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Cache enabled successfully" else echo "โŒ Failed to enable cache" fi # Test 3: Clear cache echo "" echo "๐Ÿงน Test 3: Clearing cache..." ./cremote clear-cache --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Cache cleared successfully" else echo "โŒ Failed to clear cache" fi # Test 4: Test with specific tab ID echo "" echo "๐ŸŽฏ Test 4: Testing with specific tab ID..." ./cremote disable-cache --tab="$TAB_ID" --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Cache disabled for specific tab successfully" else echo "โŒ Failed to disable cache for specific tab" fi # Clean up echo "" echo "๐Ÿงน Cleaning up..." ./cremote close-tab --tab="$TAB_ID" echo "โœ… Tab closed" echo "" # Test 5: Clear all site data echo "" echo "๐Ÿงน Test 5: Clearing all site data..." ./cremote clear-all-site-data --timeout=15 if [ $? -eq 0 ]; then echo "โœ… All site data cleared successfully" else echo "โŒ Failed to clear all site data" fi # Test 6: Clear cookies only echo "" echo "๐Ÿช Test 6: Clearing cookies..." ./cremote clear-cookies --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Cookies cleared successfully" else echo "โŒ Failed to clear cookies" fi # Test 7: Clear storage only echo "" echo "๐Ÿ’พ Test 7: Clearing storage..." ./cremote clear-storage --timeout=10 if [ $? -eq 0 ]; then echo "โœ… Storage cleared successfully" else echo "โŒ Failed to clear storage" fi echo "๐ŸŽ‰ Cache and site data management tests completed!" echo "" echo "๐Ÿ“‹ Summary of new features:" echo " โ€ข disable-cache: Disables browser cache for testing" echo " โ€ข enable-cache: Re-enables browser cache" echo " โ€ข clear-cache: Clears existing cached resources" echo " โ€ข clear-all-site-data: Clears ALL site data (cookies, storage, cache, etc.)" echo " โ€ข clear-cookies: Clears cookies only" echo " โ€ข clear-storage: Clears web storage only (localStorage, sessionStorage, etc.)" echo "" echo "๐Ÿ’ก Use cases:" echo " โ€ข Testing: Ensure fresh page loads without cache" echo " โ€ข Performance: Test cold load performance" echo " โ€ข Debugging: Resolve cache-related issues" echo " โ€ข Development: See changes immediately" echo " โ€ข Authentication: Clear cookies to test login/logout flows" echo " โ€ข Privacy: Clear all site data for clean state testing" echo " โ€ข Storage: Clear web storage to test application state"