from __future__ import annotations

import pytest
from playwright.sync_api import Page

from e2e.pages.product_solution_admin_page import ProductSolutionAdminPage


PRODUCT_NAME_KEYWORD = "自动化产品_"


@pytest.mark.e2e_standalone
def test_prodsol_flow_001_existing_product_operation_log(page: Page, settings, bug_reporter) -> None:
    admin = ProductSolutionAdminPage(page, settings.admin_url)
    admin.login(settings.admin_username, settings.admin_password)
    bug_reporter.record_if_errors(account=settings.admin_username, location="SaaS Admin 登录")

    product_code = admin.latest_product_code_by_name_keyword(PRODUCT_NAME_KEYWORD)
    admin.assert_product_create_operation_logs(product_code=product_code)
    bug_reporter.record_if_errors(
        account=settings.admin_username,
        location=f"PRODSOL-FLOW-001 既有产品操作日志校验：{product_code}",
    )
