refactor(tests): restructure into layered POM architecture with Allure reporting
- Split framework into core/ (config, logger, db, driver factories, screenshot, allure integration) and pages/ (PO layer: base/admin/driver); flatten test files per platform (web/admin, app/driver_android, cross_end) - Slim root conftest.py 656 -> ~100 lines: drop inline CN HTML report, add Allure severity mapping (p0/p1/p2 -> blocker/normal/minor) and environment.properties; support both tests.*-prefixed and bare imports - Preserve TC-D2S-001/002 cross-end E2E cases with business logic unchanged, add allure epic/feature/story/step annotations - Deduplicate: single makereport hook, shared failure-screenshot helpers, single SCREENSHOTS_DIR constant; deterministic auth-state role loading - Move DB credentials from db_helper.py into test_config.yaml (database section) - Move pytest.ini to repo root; switch reporting to allure-pytest (drop pytest-html/junitxml); update requirements.txt accordingly - Delete deprecated scaffolding: test_freight_full_flow + 6 stale page objects, iOS/shipper empty shells, dead utils - Fix flaky vxe-table action-row wait: wait for a visible td instead of hidden placeholder rows (fixed shipper-payment timeouts) - Verified end-to-end against live env: both E2E cases pass (2 passed 3m12s); run artifacts (logs/screenshots/allure) included per repo convention
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
"""管理端登录测试用例。
|
||||
|
||||
标记:
|
||||
pytest -m admin # 仅管理端用例
|
||||
pytest -m p0 # P0 冒烟
|
||||
pytest -m smoke # 冒烟
|
||||
"""
|
||||
|
||||
import allure
|
||||
import pytest
|
||||
from playwright.sync_api import Page
|
||||
|
||||
pytestmark = [pytest.mark.admin]
|
||||
|
||||
|
||||
@allure.epic("运八网络货运平台")
|
||||
@allure.feature("管理端")
|
||||
class TestAdminSmoke:
|
||||
"""管理端冒烟 — 验证预登录态。"""
|
||||
|
||||
@allure.story("预登录态访问")
|
||||
@allure.title("验证预登录态可直接访问管理后台")
|
||||
@pytest.mark.p0
|
||||
@pytest.mark.smoke
|
||||
def test_admin_access_with_saved_auth(self, page: Page, admin_config, ensure_login):
|
||||
"""验证预登录态可直接访问管理后台。"""
|
||||
ensure_login("super_admin")
|
||||
page.goto(admin_config["base_url"])
|
||||
page.wait_for_timeout(2000)
|
||||
assert "#/login" not in page.url and "/login" not in page.url, (
|
||||
"预登录态失效!请运行: python tests/web/admin/save_auth.py"
|
||||
)
|
||||
|
||||
@allure.story("预登录态访问")
|
||||
@allure.title("验证车队长预登录态有效")
|
||||
@pytest.mark.p0
|
||||
@pytest.mark.smoke
|
||||
def test_team_leader_access(self, page: Page, admin_config, ensure_login):
|
||||
"""验证车队长预登录态有效。"""
|
||||
ensure_login("team_leader")
|
||||
page.goto(admin_config["base_url"])
|
||||
page.wait_for_timeout(2000)
|
||||
assert "#/login" not in page.url and "/login" not in page.url
|
||||
|
||||
@allure.story("预登录态访问")
|
||||
@allure.title("验证首页可正常加载")
|
||||
@pytest.mark.p0
|
||||
@pytest.mark.smoke
|
||||
def test_dashboard_loads(self, page: Page, admin_config, ensure_login):
|
||||
"""验证首页可正常加载。"""
|
||||
ensure_login("super_admin")
|
||||
page.goto(admin_config["base_url"])
|
||||
assert page.title(), "首页应显示页面标题"
|
||||
|
||||
|
||||
@allure.epic("运八网络货运平台")
|
||||
@allure.feature("管理端")
|
||||
class TestLoginPage:
|
||||
"""登录页交互验证。"""
|
||||
|
||||
@allure.story("登录页")
|
||||
@allure.title("验证登录页可正常访问")
|
||||
@pytest.mark.p1
|
||||
def test_login_page_accessible(self, page: Page, admin_config):
|
||||
"""验证登录页可正常访问。"""
|
||||
page.goto(f"{admin_config['base_url']}/#/login")
|
||||
assert page.get_by_placeholder("请输入用户名").is_visible()
|
||||
|
||||
@allure.story("登录页")
|
||||
@allure.title("验证登录页元素完整")
|
||||
@pytest.mark.p1
|
||||
def test_login_page_elements(self, page: Page, admin_config):
|
||||
"""验证登录页元素完整。"""
|
||||
page.goto(f"{admin_config['base_url']}/#/login")
|
||||
assert page.get_by_placeholder("请输入用户名").is_visible()
|
||||
assert page.get_by_placeholder("请输入密码").is_visible()
|
||||
assert page.get_by_role("button", name="登录").is_visible()
|
||||
|
||||
@allure.story("登录页")
|
||||
@allure.title("验证已登录用户访问登录页被重定向")
|
||||
@pytest.mark.p1
|
||||
def test_session_redirect(self, page: Page, admin_config, ensure_login):
|
||||
"""验证已登录用户访问登录页被重定向。"""
|
||||
ensure_login("super_admin")
|
||||
page.goto(admin_config["base_url"])
|
||||
page.wait_for_timeout(2000)
|
||||
assert "#/login" not in page.url
|
||||
|
||||
page.goto(f"{admin_config['base_url']}/#/login")
|
||||
page.wait_for_timeout(2000)
|
||||
assert "#/login" not in page.url and "/login" not in page.url
|
||||
Reference in New Issue
Block a user