test: fix external editor test to use real temp file that exists

This commit is contained in:
2026-05-07 21:21:05 -04:00
parent 6a615a2d20
commit a6c569fb69
3 changed files with 37 additions and 33 deletions
+3 -7
View File
@@ -115,12 +115,8 @@
"hash": "9b034a4193a0d9031521d4c761b458170ef8feecba3220918543d4b768199ae2", "hash": "9b034a4193a0d9031521d4c761b458170ef8feecba3220918543d4b768199ae2",
"summary": "This module manages the state and callbacks for a patch approval modal. It handles requesting patch approval, storing pending patch details, and triggering actions upon patch application or rejection.\n\n* **State Management:** Tracks whether a modal is shown and holds details of a pending patch.\n* **Callback Handling:** Allows setting and invoking callbacks for patch application and rejection.\n* **Singleton Pattern:** Provides a global, single instance of the `PatchModalManager`.\n\n**Outline:**\n**Python** \u2014 73 lines\nimports: dataclasses, time, typing\nclass PendingPatch\nclass PatchModalManager: __init__, request_patch_approval, get_pending_patch, is_modal_shown, set_apply_callback, set_reject_callback, apply_patch, reject_patch, close_modal, reset\nfunctions: get_patch_modal_manager, reset_patch_modal_manager" "summary": "This module manages the state and callbacks for a patch approval modal. It handles requesting patch approval, storing pending patch details, and triggering actions upon patch application or rejection.\n\n* **State Management:** Tracks whether a modal is shown and holds details of a pending patch.\n* **Callback Handling:** Allows setting and invoking callbacks for patch application and rejection.\n* **Singleton Pattern:** Provides a global, single instance of the `PatchModalManager`.\n\n**Outline:**\n**Python** \u2014 73 lines\nimports: dataclasses, time, typing\nclass PendingPatch\nclass PatchModalManager: __init__, request_patch_approval, get_pending_patch, is_modal_shown, set_apply_callback, set_reject_callback, apply_patch, reject_patch, close_modal, reset\nfunctions: get_patch_modal_manager, reset_patch_modal_manager"
}, },
"C:\\Users\\Ed\\AppData\\Local\\Temp\\pytest-of-Ed\\pytest-864\\test_auto_aggregate_skip0\\file1.txt": { "C:\\projects\\manual_slop\\tests\\test_external_editor_gui.py": {
"hash": "d0b425e00e15a0d36b9b361f02bab63563aed6cb4665083905386c55d5b679fa", "hash": "a0aca43b13763c7ba0490a140ddef2c5d1e899839f593cb99e33461501e5d618",
"summary": "This document contains a single line of text, \"content1\". Its purpose and key takeaways are limited to this singular piece of content.\n\n**Outline:**\n**TXT** \u2014 1 lines\npreview:\n```\ncontent1\n```" "summary": "This file contains integration tests for the external editor functionality of the GUI. It verifies that the GUI correctly launches external editors like VS Code with appropriate arguments and handles user interactions related to the external editor feature.\n\n* **External Editor Launch Verification:** Tests ensure that configured external editors (specifically VS Code) are launched with the correct command-line arguments for diff views.\n* **Configuration Loading:** Tests validate that the GUI correctly reads and applies external editor configurations from `config.toml`.\n* **GUI Interaction Testing:** Simulates user interactions like clicking buttons within the patch modal to trigger external editor actions.\n* **Command Format Validation:** Independently verifies the format of commands generated for launching external editors.\n\n**Outline:**\n**Python** \u2014 418 lines\nimports: os, pathlib, pytest, src, subprocess, sys, tempfile, time, tomli_w, tomllib\nfunctions: get_vscode_processes, vscode_external_editor_config, setup_external_editor_in_workspace, test_vscode_launches_with_diff_view, test_verify_command_format, get_vscode_processes, test_external_editor_config, test_patch_modal_shows_with_configured_editor, test_button_click_is_received, test_verify_vscode_command_format"
},
"C:\\Users\\Ed\\AppData\\Local\\Temp\\pytest-of-Ed\\pytest-864\\test_force_full0\\other.txt": {
"hash": "04d61c0832f9cbc2a210334352425d2519890a0a5945da96ccc5bd9ff101c4d3",
"summary": "This document is a simple text file containing ten lines of content, with the first eight lines previewed. Its purpose appears to be for basic data storage or as a placeholder.\n\n**Outline:**\n**TXT** \u2014 10 lines\npreview:\n```\nline1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\n```"
} }
} }
+23 -23
View File
@@ -75,7 +75,7 @@ DockId=0xAFC85805,2
[Window][Theme] [Window][Theme]
Pos=0,28 Pos=0,28
Size=469,1172 Size=1010,1172
Collapsed=0 Collapsed=0
DockId=0x00000005,3 DockId=0x00000005,3
@@ -85,7 +85,7 @@ Size=900,700
Collapsed=0 Collapsed=0
[Window][Diagnostics] [Window][Diagnostics]
Pos=1945,734 Pos=739,582
Size=1211,713 Size=1211,713
Collapsed=0 Collapsed=0
@@ -102,26 +102,26 @@ Collapsed=0
DockId=0x0000000D,0 DockId=0x0000000D,0
[Window][Discussion Hub] [Window][Discussion Hub]
Pos=471,28 Pos=1012,28
Size=1209,1172 Size=668,1172
Collapsed=0 Collapsed=0
DockId=0x00000006,0 DockId=0x00000006,0
[Window][Operations Hub] [Window][Operations Hub]
Pos=0,28 Pos=0,28
Size=469,1172 Size=1010,1172
Collapsed=0 Collapsed=0
DockId=0x00000005,2 DockId=0x00000005,2
[Window][Files & Media] [Window][Files & Media]
Pos=471,28 Pos=1012,28
Size=1209,1172 Size=668,1172
Collapsed=0 Collapsed=0
DockId=0x00000006,1 DockId=0x00000006,1
[Window][AI Settings] [Window][AI Settings]
Pos=0,28 Pos=0,28
Size=469,1172 Size=1010,1172
Collapsed=0 Collapsed=0
DockId=0x00000005,0 DockId=0x00000005,0
@@ -131,14 +131,14 @@ Size=416,325
Collapsed=0 Collapsed=0
[Window][MMA Dashboard] [Window][MMA Dashboard]
Pos=471,28 Pos=1012,28
Size=1209,1172 Size=668,1172
Collapsed=0 Collapsed=0
DockId=0x00000006,2 DockId=0x00000006,2
[Window][Log Management] [Window][Log Management]
Pos=471,28 Pos=1012,28
Size=1209,1172 Size=668,1172
Collapsed=0 Collapsed=0
DockId=0x00000006,3 DockId=0x00000006,3
@@ -407,7 +407,7 @@ DockId=0x00000006,1
[Window][Project Settings] [Window][Project Settings]
Pos=0,28 Pos=0,28
Size=469,1172 Size=1010,1172
Collapsed=0 Collapsed=0
DockId=0x00000005,1 DockId=0x00000005,1
@@ -516,9 +516,9 @@ Column 1 Width=100
Column 2 Weight=1.0000 Column 2 Weight=1.0000
[Table][0xA02D8C87,3] [Table][0xA02D8C87,3]
RefScale=16 RefScale=20
Column 0 Width=179 Column 0 Width=223
Column 1 Width=120 Column 1 Width=150
Column 2 Weight=1.0000 Column 2 Weight=1.0000
[Table][0xD0277E63,2] [Table][0xD0277E63,2]
@@ -547,15 +547,15 @@ Column 0 Width=187
Column 1 Weight=1.0000 Column 1 Weight=1.0000
[Table][0x1DA1F4A6,2] [Table][0x1DA1F4A6,2]
RefScale=16 RefScale=20
Column 0 Weight=1.0000 Column 0 Weight=1.0000
Column 1 Width=120 Column 1 Width=150
[Table][0x5B562C13,3] [Table][0x5B562C13,3]
RefScale=16 RefScale=20
Column 0 Weight=1.0000 Column 0 Weight=1.0000
Column 1 Width=80 Column 1 Width=100
Column 2 Width=150 Column 2 Width=187
[Docking][Data] [Docking][Data]
DockNode ID=0x00000008 Pos=3125,170 Size=593,1157 Split=Y DockNode ID=0x00000008 Pos=3125,170 Size=593,1157 Split=Y
@@ -565,8 +565,8 @@ DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=0,28 Size=1680,1172 Split=
DockNode ID=0x00000003 Parent=0xAFC85805 SizeRef=2175,1183 Split=X DockNode ID=0x00000003 Parent=0xAFC85805 SizeRef=2175,1183 Split=X
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2 DockNode ID=0x0000000B Parent=0x00000003 SizeRef=404,1186 Split=X Selected=0xF4139CA2
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=1512,858 Split=X Selected=0x8CA2375C DockNode ID=0x00000007 Parent=0x0000000B SizeRef=1512,858 Split=X Selected=0x8CA2375C
DockNode ID=0x00000005 Parent=0x00000007 SizeRef=840,1681 CentralNode=1 Selected=0x418C7449 DockNode ID=0x00000005 Parent=0x00000007 SizeRef=1010,1681 CentralNode=1 Selected=0x418C7449
DockNode ID=0x00000006 Parent=0x00000007 SizeRef=1209,1681 Selected=0x2C0206CE DockNode ID=0x00000006 Parent=0x00000007 SizeRef=668,1681 Selected=0x2C0206CE
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=1777,858 Selected=0x418C7449 DockNode ID=0x0000000E Parent=0x0000000B SizeRef=1777,858 Selected=0x418C7449
DockNode ID=0x0000000D Parent=0x00000003 SizeRef=435,1186 Selected=0x363E93D6 DockNode ID=0x0000000D Parent=0x00000003 SizeRef=435,1186 Selected=0x363E93D6
DockNode ID=0x00000004 Parent=0xAFC85805 SizeRef=1162,1183 Split=X Selected=0x3AEC3498 DockNode ID=0x00000004 Parent=0xAFC85805 SizeRef=1162,1183 Split=X Selected=0x3AEC3498
+11 -3
View File
@@ -61,8 +61,14 @@ def test_vscode_launches_with_diff_view(live_gui):
print(f"\n=== VSCODE LAUNCH TEST ===") print(f"\n=== VSCODE LAUNCH TEST ===")
print(f"VSCode before:\n{before if before.strip() else 'not running'}") print(f"VSCode before:\n{before if before.strip() else 'not running'}")
sample_patch = """--- a/test.py with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False, encoding='utf-8') as f:
+++ b/test.py f.write('HELLO_WORLD = "original"\n')
f.write('def main():\n')
f.write(' pass\n')
test_file = f.name
sample_patch = f"""--- a/{Path(test_file).name}
+++ b/{Path(test_file).name}
@@ -1,2 +1,3 @@ @@ -1,2 +1,3 @@
HELLO_WORLD = "original" HELLO_WORLD = "original"
-HELLO_WORLD = "modified" -HELLO_WORLD = "modified"
@@ -73,7 +79,7 @@ def test_vscode_launches_with_diff_view(live_gui):
client.push_event("show_patch_modal", { client.push_event("show_patch_modal", {
"patch_text": sample_patch, "patch_text": sample_patch,
"file_paths": ["test.py"] "file_paths": [test_file]
}) })
time.sleep(2) time.sleep(2)
@@ -99,6 +105,8 @@ def test_vscode_launches_with_diff_view(live_gui):
client.push_event("hide_patch_modal", {}) client.push_event("hide_patch_modal", {})
time.sleep(1) time.sleep(1)
os.unlink(test_file)
@pytest.mark.integration @pytest.mark.integration
@pytest.mark.timeout(30) @pytest.mark.timeout(30)