تم الانتهاء من آخر دفعة تحسينات على المشروع، وتشمل:

تحويل لوحة الإدارة الداخلية من secret header إلى session auth حقيقي مع صلاحيات admin.
إضافة دعم إدارة الأدوار من داخل لوحة الإدارة نفسها، مع حماية الحسابات المعتمدة عبر INTERNAL_ADMIN_EMAILS.
تحسين بيانات المستخدم في الواجهة والباكند لتشمل role وis_allowlisted_admin.
إضافة اختبار frontend مخصص لصفحة /internal/admin بدل الاعتماد فقط على build واختبار routes.
تحسين إضافي في الأداء عبر إزالة الاعتماد على pdfjs-dist/pdf.worker في عدّ صفحات PDF واستبداله بمسار أخف باستخدام pdf-lib.
تحسين تقسيم الـ chunks في build لتقليل أثر الحزم الكبيرة وفصل أجزاء مثل network, icons, pdf-core, وeditor.
التحقق الذي تم:

نجاح build للواجهة.
نجاح اختبار صفحة الإدارة الداخلية في frontend.
نجاح اختبارات auth/admin في backend.
نجاح full backend suite مسبقًا مع EXIT:0.
ولو تريد نسخة أقصر جدًا، استخدم هذه:

آخر التحديثات:
تم تحسين نظام الإدارة الداخلية ليعتمد على صلاحيات وجلسات حقيقية بدل secret header، مع إضافة إدارة أدوار من لوحة admin نفسها، وإضافة اختبارات frontend مخصصة للوحة، وتحسين أداء الواجهة عبر إزالة pdf.worker وتحسين تقسيم الـ chunks في build. جميع الاختبارات والتحققات الأساسية المطلوبة نجح
This commit is contained in:
Your Name
2026-03-16 13:50:45 +02:00
parent b5d97324a9
commit 957d37838c
85 changed files with 9915 additions and 119 deletions

View File

@@ -0,0 +1,79 @@
"""Tests for the contact form endpoint."""
import pytest
class TestContactSubmission:
"""Tests for POST /api/contact/submit."""
def test_submit_success(self, client):
response = client.post("/api/contact/submit", json={
"name": "Test User",
"email": "test@example.com",
"category": "general",
"subject": "Test Subject",
"message": "This is a test message body.",
})
assert response.status_code == 201
data = response.get_json()
assert data["message"] == "Message sent successfully."
assert "id" in data
assert "created_at" in data
def test_submit_missing_name(self, client):
response = client.post("/api/contact/submit", json={
"email": "test@example.com",
"subject": "Test",
"message": "Body",
})
assert response.status_code == 400
assert "Name" in response.get_json()["error"]
def test_submit_invalid_email(self, client):
response = client.post("/api/contact/submit", json={
"name": "User",
"email": "not-an-email",
"subject": "Test",
"message": "Body",
})
assert response.status_code == 400
assert "email" in response.get_json()["error"].lower()
def test_submit_missing_subject(self, client):
response = client.post("/api/contact/submit", json={
"name": "User",
"email": "test@example.com",
"subject": "",
"message": "Body",
})
assert response.status_code == 400
assert "Subject" in response.get_json()["error"]
def test_submit_missing_message(self, client):
response = client.post("/api/contact/submit", json={
"name": "User",
"email": "test@example.com",
"subject": "Test",
"message": "",
})
assert response.status_code == 400
assert "Message" in response.get_json()["error"]
def test_submit_bug_category(self, client):
response = client.post("/api/contact/submit", json={
"name": "Bug Reporter",
"email": "bug@example.com",
"category": "bug",
"subject": "Found a bug",
"message": "The merge tool crashes on large files.",
})
assert response.status_code == 201
def test_submit_invalid_category_defaults_to_general(self, client):
response = client.post("/api/contact/submit", json={
"name": "User",
"email": "test@example.com",
"category": "hacking",
"subject": "Test",
"message": "Body text here.",
})
assert response.status_code == 201