88 lines
3.2 KiB
Python
88 lines
3.2 KiB
Python
"""
|
|
V1.1 首页 E2E 测试骨架
|
|
测试项目: 善缘丹阳 V1.1 首页结构 + Banner + 8核心入口
|
|
"""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.e2e
|
|
class TestHomeV11:
|
|
"""V1.1 首页 E2E 测试"""
|
|
|
|
def test_home_api_returns_user_state(self, api_client, authenticated_user):
|
|
"""GET /api/v1/home 返回 userState"""
|
|
resp = api_client.get("/api/v1/home")
|
|
assert resp.status_code == 200
|
|
data = resp.json()
|
|
assert "userState" in data
|
|
|
|
def test_home_banners_filtered_by_time(self, api_client, banner_factory):
|
|
"""Banner按时间过滤:未开始和已过期的Banner不显示"""
|
|
# TODO: P07 实现后完善
|
|
pass
|
|
|
|
def test_home_banners_filtered_by_audience(self, api_client, banner_factory, user_factory):
|
|
"""Banner按用户状态过滤:audience_scope不匹配时不显示"""
|
|
# TODO: P07 实现后完善
|
|
pass
|
|
|
|
def test_home_quick_entries_fixed_order(self, api_client):
|
|
"""首页8核心入口顺序固定"""
|
|
# TODO: P07 实现后完善
|
|
pass
|
|
|
|
def test_unverified_user_no_recommendations(self, api_client, unverified_user):
|
|
"""未审核用户不返回真实推荐"""
|
|
resp = api_client.get("/api/v1/home")
|
|
data = resp.json()
|
|
assert data.get("recommendations") == [] or data.get("recommendations") is None
|
|
|
|
def test_paused_user_no_new_recommendations(self, api_client, paused_user):
|
|
"""Paused状态用户不返回新推荐"""
|
|
resp = api_client.get("/api/v1/home")
|
|
data = resp.json()
|
|
# Paused用户应有推荐区降级提示,而非空列表
|
|
assert "recommendations" in data or "userState" in data
|
|
|
|
def test_successful_user_no_match_recommendations(self, api_client, successful_user):
|
|
"""Successful用户不返回找对象推荐"""
|
|
resp = api_client.get("/api/v1/home")
|
|
data = resp.json()
|
|
# Successful用户首页应转为公益服务推荐
|
|
pass
|
|
|
|
def test_service_location_shown_when_available(self, api_client, service_location_factory):
|
|
"""服务站可展示"""
|
|
# TODO: P19 实现后完善
|
|
pass
|
|
|
|
def test_banner_cannot_link_external_url(self, admin_client):
|
|
"""Banner不能创建外部URL跳转"""
|
|
# TODO: P19 实现后完善
|
|
pass
|
|
|
|
|
|
@pytest.mark.e2e
|
|
class TestCapabilityService:
|
|
"""CapabilityService 能力判断测试"""
|
|
|
|
def test_can_receive_recommendations(self, api_client, searching_user):
|
|
"""Searching用户canReceiveRecommendations=true"""
|
|
resp = api_client.get("/api/v1/home")
|
|
data = resp.json()
|
|
caps = data.get("capabilities", {})
|
|
assert caps.get("canReceiveRecommendations") is True
|
|
|
|
def test_paused_user_cannot_receive_recommendations(self, api_client, paused_user):
|
|
"""Paused用户canReceiveRecommendations=false"""
|
|
resp = api_client.get("/api/v1/home")
|
|
data = resp.json()
|
|
caps = data.get("capabilities", {})
|
|
assert caps.get("canReceiveRecommendations") is False
|
|
|
|
def test_counseling_enabled_capability(self, api_client, verified_user):
|
|
"""counselingEnabled flag控制canApplyCounseling"""
|
|
# TODO: P22 实现后完善
|
|
pass
|