Files
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

114 lines
3.7 KiB
Python

# -*- coding: utf-8 -*-
"""
QwenPaw Tools page object.
Wraps all interactions on the tool management page and exposes business-level
methods.
"""
from __future__ import annotations
import logging
from typing import Optional, List
from playwright.sync_api import Page, Locator, expect, TimeoutError
from pages.base_page import BasePage
from config.settings import config
logger = logging.getLogger(__name__)
class ToolsPage(BasePage):
"""
Tools page object.
Wraps all user interactions on the tool management page:
- Open the tools page
- Get the list of tool cards
- Get tool names
- Toggle the tool switch
- Check whether a tool is enabled
"""
PAGE_TITLE = "QwenPaw Console"
PAGE_URL = f"{config.base_url}/tools"
# ========== Selector definitions ==========
# Page load indicator
TOOL_PAGE_CONTAINER = "div[class*=toolsPage]"
PAGE_LOAD_INDICATOR = TOOL_PAGE_CONTAINER
# Tool card selectors
TOOL_CARD = ".qwenpaw-card"
SWITCH = ".qwenpaw-switch"
BREADCRUMB = 'span[class*="breadcrumbCurrent"]'
# ========== Navigation ==========
def open(self) -> "ToolsPage":
"""Open the Tools page."""
logger.info("Opening Tools page")
self.goto()
self.wait_for_page_loaded()
return self
def wait_for_page_loaded(self, timeout: Optional[int] = None) -> "ToolsPage":
"""Wait for the page to finish loading."""
timeout = timeout or self.timeout
expect(self.page.locator(self.PAGE_LOAD_INDICATOR).first).to_be_visible(timeout=timeout)
return self
# ========== Tool list operations ==========
def get_tool_cards(self) -> List[Locator]:
"""Return all tool cards."""
cards = self.page.locator(self.TOOL_CARD).all()
logger.info(f"Found {len(cards)} tool cards")
return cards
def get_tool_name(self, card: Locator) -> str:
"""Return the tool name."""
# Try to get the tool name from the card title
title_element = card.locator('.ant-card-meta-title, .qwenpaw-card-meta-title, h3, h4, [class*="title"]').first
if title_element.count() > 0:
return title_element.inner_text()
# Fall back to the card text content if no title is found
return card.inner_text().strip()[:50]
def toggle_tool(self, card: Locator) -> "ToolsPage":
"""Toggle the tool switch."""
switch = card.locator(self.SWITCH).first
if switch.count() > 0:
switch.click()
logger.info("Toggled tool switch")
return self
def is_tool_enabled(self, card: Locator) -> bool:
"""Return whether the tool is enabled."""
switch = card.locator(self.SWITCH).first
if switch.count() > 0:
return switch.evaluate(
"el => el.classList.contains('qwenpaw-switch-checked') || "
"el.classList.contains('ant-switch-checked') || "
"el.getAttribute('aria-checked') === 'true'"
)
return False
# ========== Assertion methods ==========
def assert_tool_count(self, expected_count: int, timeout: Optional[int] = None) -> "ToolsPage":
"""Assert the tool card count."""
expect(self.page.locator(self.TOOL_CARD)).to_have_count(
expected_count, timeout=timeout or self.timeout
)
return self
def assert_tool_exists(self, tool_name: str, timeout: Optional[int] = None) -> "ToolsPage":
"""Assert the tool exists."""
tool_card = self.page.locator(self.TOOL_CARD).filter(
has_text=tool_name
).first
expect(tool_card).to_be_visible(timeout=timeout or self.timeout)
return self