deploy DOM search v8 update

This commit is contained in:
Marco0300
2026-09-06 00:46:28 +02:00
parent e92ffaa807
commit eeffaf4b6c
5 changed files with 317 additions and 28 deletions
+26
View File
@@ -268,6 +268,32 @@ class BrowserOnlyAppTests(unittest.TestCase):
self.assertEqual(server.browser_use_limits(), (22, 900))
self.assertEqual(server.website_scan_timeout_seconds(), 15)
def test_company_profile_and_promotions_feed_email_draft(self):
status, profile = self.request("POST", "/api/settings", {"company_profile": {
"name": "Marco Web Studio", "description": "A South African hosting studio.",
"services": "Domains, hosting and website rebuilds.", "packages": "Gold Plus hosting at R119/month.",
}})
self.assertEqual(status, 200)
self.assertTrue(profile["company_profile"]["configured"])
self.request("POST", "/api/settings", {"ai": {"AI_PROVIDER": "custom", "AI_BASE_URL": "https://ai.example/v1", "AI_MODEL": "test-model", "AI_API_KEY": "test-key"}})
status, promotion = self.request("POST", "/api/promotions", {"name": "Free rebuild", "description": "Free website rebuild when hosting moves to Gold Plus.", "terms": "New hosting customers only."})
self.assertEqual(status, 201)
status, listed = self.request("GET", "/api/promotions")
self.assertEqual(status, 200)
self.assertEqual(listed["items"][0]["name"], "Free rebuild")
conn = server.db()
conn.execute("INSERT INTO prospects(name,domain,category,discovered_at) VALUES(?,?,?,?)", ("Acme", "maps:acme", "plumber", server.now()))
conn.commit(); conn.close()
content = json.dumps({"subject": "A free website rebuild", "message": "Good day Acme,\n\nWe can help.", "rationale": "Uses the supplied promotion.", "recommended_offer": "Free rebuild", "unknowns": [], "evidence_used": ["prospect_record"], "follow_up": "Review before sending."})
with patch("api.server.http_json", return_value={"choices": [{"message": {"content": content}}]}) as http_json:
status, body = self.request("POST", "/api/prospects/1/message", {"offer": "Please mention our offer.", "promotion_id": promotion["id"]})
self.assertEqual(status, 200)
prompt = http_json.call_args.args[2]["messages"][1]["content"]
self.assertIn("Free website rebuild", prompt)
self.assertIn("Gold Plus hosting at R119/month", prompt)
saved = server.db().execute("SELECT ai_promotion_id FROM prospects WHERE id=1").fetchone()
self.assertEqual(saved[0], promotion["id"])
if __name__ == "__main__":
unittest.main()