"""Integration tests for the complete workflow."""
import tempfile
from pathlib import Path
import pytest
@pytest.mark.asyncio
async def test_edit_file_workflow():
"""Test the complete edit file workflow using `request_change`."""
from domin8.tools.request_change import handle_request_change
diff = (
"--- a/README.md\n"
"+++ b/README.md\n"
"@@ -1 +1 @@\n"
"-Old line\n"
"+New line\n"
)
arguments = {
"summary": (
"This change updates the README because it contained outdated examples, lacked information about setup and usage, "
"and did not document known platform-specific gotchas. It is necessary because several new contributors reported confusion, "
"CI flakiness due to unclear instructions, and repeated questions in the issue tracker - this will reduce onboarding friction and improve clarity."
),
"short_summary": "Update README with clearer examples and instructions",
"explainability": {"bullets": [
"Existing README examples were outdated and caused confusion for new contributors when following quickstart steps.",
"This update clarifies setup steps and provides reproducible examples for common workflows to mitigate CI flakiness.",
"Improves onboarding and reduces support overhead reported in issues and PR comments over the last month."
]},
"diff": diff,
"actor_id": "test-agent"
}
result = await handle_request_change(arguments)
assert "✅" in result
assert "PENDING" in result
@pytest.mark.asyncio
async def test_create_file_workflow():
"""Test the complete create file workflow using `request_change`."""
from domin8.tools.request_change import handle_request_change
diff = (
"--- /dev/null\n"
"+++ b/new_file.py\n"
"@@ -0,0 +1,3 @@\n"
"+# New Python file\n"
"+def hello():\n"
"+ print('Hello')\n"
)
arguments = {
"summary": (
"Create a new utility module because we need to encapsulate shared helper functions and remove duplication across several "
"components. This promotes reuse, enables more focused unit tests, and reduces maintenance cost. It also prepares the codebase "
"for future refactors by centralizing common behavior behind a stable API."
),
"short_summary": "Create utility module for shared helpers",
"explainability": {"bullets": [
"This new module centralizes helper functions that were duplicated across the codebase, reducing duplication and bugs.",
"It enables more focused unit tests and simplifies test maintenance for the related components.",
"Promotes code reuse and makes future refactors safer by providing a stable internal API for common behavior."
]},
"diff": diff,
"actor_id": "test-agent"
}
result = await handle_request_change(arguments)
assert "✅" in result
assert "PENDING" in result
@pytest.mark.asyncio
async def test_delete_file_workflow():
"""Test the complete delete file workflow using `request_change`."""
from domin8.tools.request_change import handle_request_change
diff = (
"diff --git a/README.md b/README.md\n"
"--- a/README.md\n"
"+++ /dev/null\n"
"@@ -1 +0,0 @@\n"
"-Some line to remove\n"
)
arguments = {
"summary": (
"Delete an obsolete file because its functionality was migrated to a better-maintained module, it is no longer "
"referenced by any tests or runtime code, and keeping it only increases maintenance overhead. Removing it reduces "
"confusion for maintainers, prevents accidental usage, and simplifies future refactors by eliminating dead code."
),
"short_summary": "Remove obsolete file",
"explainability": {"bullets": [
"The file is no longer referenced by any tests or runtime code and causes confusion for maintainers.",
"Functionality has been migrated to a central module with improved tests and clearer responsibilities.",
"Removing it reduces maintenance burden and avoids accidental use."
]},
"diff": diff,
"actor_id": "test-agent"
}
result = await handle_request_change(arguments)
assert "✅" in result
assert "PENDING" in result