68 lines
2.5 KiB
Python
68 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Authenticated smoke: agencia + simulate."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
ROOT = Path("/Users/4ventures/4ventures-client-portal")
|
|
APP = "https://app.4ventures.es"
|
|
CREDS = ROOT / ".ops" / "marketing-credentials.txt"
|
|
SHOT = ROOT / "scripts/dokploy-shots"
|
|
|
|
|
|
def main() -> int:
|
|
email, password = "marketing@4ventures.es", ""
|
|
for line in CREDS.read_text().splitlines():
|
|
if line.startswith("email="):
|
|
email = line.split("=", 1)[1].strip()
|
|
if line.startswith("password="):
|
|
password = line.split("=", 1)[1].strip()
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
page = browser.new_page(viewport={"width": 1400, "height": 1100})
|
|
page.goto(f"{APP}/login", wait_until="networkidle", timeout=90000)
|
|
page.locator('input[type="email"], input[name="email"]').first.fill(email)
|
|
page.locator('input[type="password"]').first.fill(password)
|
|
page.locator('button[type="submit"]').first.click()
|
|
page.wait_for_timeout(3500)
|
|
|
|
page.goto(f"{APP}/dashboard/agencia", wait_until="networkidle", timeout=60000)
|
|
page.wait_for_timeout(1500)
|
|
SHOT.mkdir(parents=True, exist_ok=True)
|
|
page.screenshot(path=str(SHOT / "smoke_agencia.png"), full_page=True)
|
|
body = page.inner_text("body")
|
|
missing_key = "Falta SUPABASE_SERVICE_ROLE_KEY" in body
|
|
print("agencia_missing_service_key", missing_key, flush=True)
|
|
print("agencia_snip", " | ".join([ln.strip() for ln in body.splitlines() if ln.strip()][10:22]), flush=True)
|
|
|
|
sim = page.evaluate(
|
|
"""async () => {
|
|
const r = await fetch('/api/simulate', {
|
|
method: 'POST',
|
|
headers: {'content-type':'application/json'},
|
|
body: JSON.stringify({ amount: 1000, channel: 'meta' })
|
|
});
|
|
const text = await r.text();
|
|
let json=null; try { json=JSON.parse(text); } catch {}
|
|
return { status: r.status, text: text.slice(0,250), json };
|
|
}"""
|
|
)
|
|
print("simulate", json.dumps(sim, ensure_ascii=False)[:400], flush=True)
|
|
browser.close()
|
|
|
|
if missing_key:
|
|
print("FAIL_AGENCIA", flush=True)
|
|
return 2
|
|
print("SUCCESS", flush=True)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|