#!/run/current-system/sw/bin/bash # Test script for Nixtaml single-page website # Checks file references and basic HTML structure echo "=== Nixtaml Website Integration Test ===" # Base directory BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" INDEX_FILE="$BASE_DIR/index.html" # Check if index.html exists if [ ! -f "$INDEX_FILE" ]; then echo "ERROR: index.html not found at $INDEX_FILE" exit 1 fi echo "Checking file references in index.html..." # Extract src attributes from script tags SCRIPT_FILES=$(grep -oP 'src="\K[^"]+' "$INDEX_FILE") # Extract href from link tags, excluding anchors LINK_FILES=$(grep -oP 'href="\K[^"#][^"]*' "$INDEX_FILE") # Combine and deduplicate ALL_FILES=$(echo -e "$SCRIPT_FILES\n$LINK_FILES" | sort | uniq) MISSING_FILES=() for file in $ALL_FILES; do # Skip external URLs (starting with http) if [[ $file == http* ]]; then continue fi # Check if file exists relative to BASE_DIR if [ ! -f "$BASE_DIR/$file" ]; then MISSING_FILES+=("$file") fi done # Report missing files if [ ${#MISSING_FILES[@]} -gt 0 ]; then echo "ERROR: Missing referenced files:" for file in "${MISSING_FILES[@]}"; do echo " - $file" done else echo "✓ All referenced files exist" fi # Basic HTML structure validation echo "Validating basic HTML structure..." # Check for required elements if ! grep -q "" "$INDEX_FILE"; then echo "WARNING: Missing DOCTYPE declaration" fi if ! grep -q " tag" fi if ! grep -q "" "$INDEX_FILE"; then echo "ERROR: Missing closing tag" fi if ! grep -q "" "$INDEX_FILE"; then echo "ERROR: Missing tag" fi if ! grep -q "" "$INDEX_FILE"; then echo "ERROR: Missing tag" fi # Check for balanced tags (basic check) OPEN_TAGS=$(grep -o '<[^/][^>]*>' "$INDEX_FILE" | wc -l) CLOSE_TAGS=$(grep -o ']*>' "$INDEX_FILE" | wc -l) if [ "$OPEN_TAGS" -ne "$CLOSE_TAGS" ]; then echo "WARNING: Potential unbalanced tags (open: $OPEN_TAGS, close: $CLOSE_TAGS)" else echo "✓ Basic tag balance looks good" fi # Check for required sections REQUIRED_SECTIONS=("home" "install" "cookbook" "docs" "community") for section in "${REQUIRED_SECTIONS[@]}"; do if ! grep -q "id=\"$section\"" "$INDEX_FILE"; then echo "ERROR: Missing section with id=\"$section\"" fi done echo "✓ Section IDs present" # Check for WebGL canvas insertion point if ! grep -q "webgl-bg.js" "$INDEX_FILE"; then echo "WARNING: webgl-bg.js not referenced - WebGL background may not load" fi if ! grep -q "parallax.js" "$INDEX_FILE"; then echo "WARNING: parallax.js not referenced - Parallax effects may not work" fi echo "=== Test Complete ===" if [ ${#MISSING_FILES[@]} -gt 0 ]; then echo "FAIL: Issues found" exit 1 else echo "PASS: All checks passed" fi