import requests from app import create_app from app.models.user import User from app.services.jwt_service import JWTService BASE_URL = "http://localhost:3000" app = create_app() with app.app_context(): admin = User.query.filter_by(email='admin@edu-space.com').first() token = JWTService.create_access_token(admin) cookies = {'auth_token': token} session = requests.Session() session.cookies.update(cookies) routes_to_test = [ ("admin.google_sheets_import", "/admin/google_sheets_import", ["Google Sheets", "Official Schedule Board"]), ("classrooms.add_classroom", "/classrooms/add_classroom", ["Add Classroom", "Classroom Information"]), ("admin.occupancy_metrics", "/admin/occupancy_metrics", ["Ocupación", "Métricas"]), ("buildings.list_buildings", "/buildings/list_buildings", ["Edificios", "Edificio Central"]), ("schedule.add_reservation", "/schedule/add_reservation", ["New Reservation", "Detalles de la Reserva"]) ] all_passed = True print("\n========================================================") print("Testing coupling of 5 newly added BFF functionalities:") print("========================================================") for name, path, expected_texts in routes_to_test: r = session.get(f"{BASE_URL}{path}", allow_redirects=True) is_200 = r.status_code == 200 texts_found = [t for t in expected_texts if t.lower() in r.text.lower()] all_texts_ok = len(texts_found) == len(expected_texts) has_fallback = "En Construcción" in r.text status = "PASSED" if is_200 and all_texts_ok and not has_fallback else "FAILED" print(f"[{status}] {name} ({path}) -> Status: {r.status_code}, Texts match: {texts_found}/{expected_texts}, Has Fallback: {has_fallback}") if status == "FAILED": all_passed = False print(f"Response snippet:\n{r.text[:500]}\n---") print("========================================================") if all_passed: print("SUCCESS: ALL 5 FUNCTIONALITIES ARE COUPLED TO THE NODE.JS BFF!") else: print("FAILURE: SOME FUNCTIONALITIES FAILED!") print("========================================================\n")