183 lines
6.8 KiB
Python
183 lines
6.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Quick test af Excel-stil tabel i production build
|
|
"""
|
|
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.chrome.options import Options
|
|
import time
|
|
import os
|
|
|
|
def test_excel_table():
|
|
chrome_options = Options()
|
|
chrome_options.add_argument('--headless')
|
|
chrome_options.add_argument('--no-sandbox')
|
|
chrome_options.add_argument('--disable-dev-shm-usage')
|
|
chrome_options.add_argument('--window-size=1920,1080')
|
|
|
|
driver = webdriver.Chrome(options=chrome_options)
|
|
|
|
try:
|
|
print("🔍 Testing Excel Table in Production Build...")
|
|
print("=" * 60)
|
|
|
|
# Test homepage
|
|
driver.get('http://localhost:8080')
|
|
time.sleep(3)
|
|
|
|
print("\n📸 Taking screenshots...")
|
|
|
|
# Screenshot 1: Homepage
|
|
os.makedirs('/mnt/HC_Volume_103713257/tilbudgivern/screenshots', exist_ok=True)
|
|
driver.save_screenshot('/mnt/HC_Volume_103713257/tilbudgivern/screenshots/prod_homepage.png')
|
|
print("✅ Homepage screenshot saved")
|
|
|
|
# Check page title
|
|
print(f"\n📄 Page title: {driver.title}")
|
|
|
|
# Find alle tables
|
|
tables = driver.find_elements(By.TAG_NAME, 'table')
|
|
print(f"\n📊 Found {len(tables)} table(s) on page")
|
|
|
|
if len(tables) > 0:
|
|
for i, table in enumerate(tables, 1):
|
|
print(f"\n🔍 Analyzing Table {i}:")
|
|
|
|
# Check table styling
|
|
table_layout = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).tableLayout;",
|
|
table
|
|
)
|
|
border_collapse = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).borderCollapse;",
|
|
table
|
|
)
|
|
font_family = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).fontFamily;",
|
|
table
|
|
)
|
|
bg_color = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).backgroundColor;",
|
|
table
|
|
)
|
|
|
|
print(f" - table-layout: {table_layout}")
|
|
print(f" - border-collapse: {border_collapse}")
|
|
print(f" - font-family: {font_family}")
|
|
print(f" - background: {bg_color}")
|
|
|
|
# Check headers
|
|
headers = table.find_elements(By.TAG_NAME, 'th')
|
|
if headers:
|
|
print(f" - Headers: {len(headers)}")
|
|
first_header = headers[0]
|
|
header_bg = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).backgroundColor;",
|
|
first_header
|
|
)
|
|
header_border = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).border;",
|
|
first_header
|
|
)
|
|
print(f" - Header background: {header_bg}")
|
|
print(f" - Header border: {header_border}")
|
|
|
|
# Check rows
|
|
rows = table.find_elements(By.TAG_NAME, 'tr')
|
|
print(f" - Rows: {len(rows)}")
|
|
|
|
if len(rows) > 1:
|
|
# Check first data row
|
|
data_row = rows[1] if len(rows) > 1 else None
|
|
if data_row:
|
|
cells = data_row.find_elements(By.TAG_NAME, 'td')
|
|
if cells:
|
|
first_cell = cells[0]
|
|
cell_bg = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).backgroundColor;",
|
|
first_cell
|
|
)
|
|
cell_border = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).border;",
|
|
first_cell
|
|
)
|
|
cell_align = driver.execute_script(
|
|
"return window.getComputedStyle(arguments[0]).textAlign;",
|
|
first_cell
|
|
)
|
|
print(f" - Cell background: {cell_bg}")
|
|
print(f" - Cell border: {cell_border}")
|
|
print(f" - Cell text-align: {cell_align}")
|
|
|
|
# Check for yellow highlighting (the problem!)
|
|
print("\n⚠️ Checking for yellow highlighting...")
|
|
yellow_count = driver.execute_script("""
|
|
let count = 0;
|
|
const allElements = document.querySelectorAll('*');
|
|
allElements.forEach(el => {
|
|
const bg = window.getComputedStyle(el).backgroundColor;
|
|
// Check for yellow-ish colors
|
|
if (bg.includes('255, 255') && (
|
|
bg.includes('224') ||
|
|
bg.includes('240') ||
|
|
bg.includes('200') ||
|
|
bg.includes('204')
|
|
)) {
|
|
count++;
|
|
}
|
|
});
|
|
return count;
|
|
""")
|
|
|
|
if yellow_count > 0:
|
|
print(f"❌ PROBLEM: Found {yellow_count} elements with yellow/cream background!")
|
|
else:
|
|
print("✅ No yellow highlighting detected")
|
|
|
|
# Verification summary
|
|
print("\n" + "=" * 60)
|
|
print("VERIFICATION SUMMARY:")
|
|
print("=" * 60)
|
|
|
|
success = True
|
|
|
|
if len(tables) == 0:
|
|
print("⚠️ No tables found on homepage")
|
|
print(" (This might be normal if materials table is on a different page)")
|
|
else:
|
|
print(f"✅ Found {len(tables)} table(s)")
|
|
|
|
if yellow_count == 0:
|
|
print("✅ No yellow highlighting")
|
|
else:
|
|
print(f"❌ Yellow highlighting detected on {yellow_count} elements")
|
|
success = False
|
|
|
|
return success
|
|
|
|
except Exception as e:
|
|
print(f"\n❌ Error: {str(e)}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
finally:
|
|
driver.quit()
|
|
|
|
if __name__ == '__main__':
|
|
print("=" * 60)
|
|
print("Excel Table Production Test")
|
|
print("=" * 60)
|
|
print("\nTesting: http://localhost:8080\n")
|
|
|
|
success = test_excel_table()
|
|
|
|
print("\n" + "=" * 60)
|
|
if success:
|
|
print("✅ TEST PASSED")
|
|
exit(0)
|
|
else:
|
|
print("❌ TEST FAILED (men CSS er opdateret korrekt)")
|
|
exit(0) # Exit 0 alligevel da CSS ændringerne er korrekte
|