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
113 lines
3.4 KiB
Python
113 lines
3.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Tests for the one-shot channel display migration."""
|
|
|
|
import json
|
|
from threading import Lock
|
|
|
|
from qwenpaw.config.config import (
|
|
AgentProfileConfig,
|
|
AgentProfileRef,
|
|
AgentsConfig,
|
|
Config,
|
|
load_agent_config,
|
|
migrate_channel_display_fields,
|
|
)
|
|
from qwenpaw.config import utils as config_utils
|
|
from qwenpaw.config.utils import _load_and_validate_config
|
|
|
|
|
|
def test_migrate_legacy_hidden_tool_messages():
|
|
channels = {
|
|
"slack": {
|
|
"filter_tool_messages": True,
|
|
"filter_thinking": True,
|
|
},
|
|
}
|
|
|
|
assert migrate_channel_display_fields(channels)
|
|
assert channels["slack"] == {
|
|
"show_tool_calls": False,
|
|
"show_tool_results": False,
|
|
"show_thinking": False,
|
|
}
|
|
|
|
|
|
def test_migrate_preserves_explicit_new_fields():
|
|
channels = {
|
|
"slack": {
|
|
"filter_tool_messages": False,
|
|
"show_tool_calls": False,
|
|
"tool_call_max_length": 0,
|
|
},
|
|
}
|
|
|
|
assert migrate_channel_display_fields(channels)
|
|
assert channels["slack"]["show_tool_calls"] is False
|
|
assert channels["slack"]["show_tool_results"] is True
|
|
assert channels["slack"]["tool_call_max_length"] == 0
|
|
|
|
|
|
def test_no_legacy_fields_is_not_migrated():
|
|
"""Channels without legacy fields must not be rewritten/backfilled."""
|
|
channels = {
|
|
"slack": {"enabled": True, "bot_prefix": ""},
|
|
"qq": {"show_tool_calls": False},
|
|
}
|
|
|
|
assert migrate_channel_display_fields(channels) is False
|
|
assert channels["slack"] == {"enabled": True, "bot_prefix": ""}
|
|
assert channels["qq"] == {"show_tool_calls": False}
|
|
|
|
|
|
def test_root_config_migration_persists(tmp_path):
|
|
config_path = tmp_path / "config.json"
|
|
raw = {
|
|
"channels": {
|
|
"slack": {"filter_tool_messages": True},
|
|
},
|
|
}
|
|
config_path.write_text(json.dumps(raw), encoding="utf-8")
|
|
|
|
config = _load_and_validate_config(config_path, raw)
|
|
persisted = json.loads(config_path.read_text(encoding="utf-8"))
|
|
|
|
assert config.channels.slack.show_tool_calls is False
|
|
assert "filter_tool_messages" not in persisted["channels"]["slack"]
|
|
assert persisted["channels"]["slack"]["show_tool_calls"] is False
|
|
|
|
|
|
def test_loaded_agent_config_migration_persists(
|
|
tmp_path,
|
|
monkeypatch,
|
|
):
|
|
workspace_dir = tmp_path / "workspaces" / "agent"
|
|
workspace_dir.mkdir(parents=True)
|
|
agent_config_path = workspace_dir / "agent.json"
|
|
raw = AgentProfileConfig(id="agent", name="Agent").model_dump(
|
|
exclude_none=True,
|
|
)
|
|
raw["channels"] = {"slack": {"filter_tool_messages": True}}
|
|
agent_config_path.write_text(json.dumps(raw), encoding="utf-8")
|
|
|
|
root_config = Config(
|
|
agents=AgentsConfig(
|
|
active_agent="agent",
|
|
profiles={
|
|
"agent": AgentProfileRef(
|
|
id="agent",
|
|
workspace_dir=str(workspace_dir),
|
|
),
|
|
},
|
|
),
|
|
)
|
|
monkeypatch.setattr(config_utils, "load_config", lambda: root_config)
|
|
monkeypatch.setattr(config_utils, "_agent_config_cache", {})
|
|
monkeypatch.setattr(config_utils, "_agent_config_lock", Lock())
|
|
|
|
config = load_agent_config("agent")
|
|
persisted = json.loads(agent_config_path.read_text(encoding="utf-8"))
|
|
|
|
assert config.channels.slack.show_tool_calls is False
|
|
assert "filter_tool_messages" not in persisted["channels"]["slack"]
|
|
assert persisted["channels"]["slack"]["show_tool_calls"] is False
|