Fix #5: center import export modals
This commit is contained in:
parent
20e7d63665
commit
40aa66d164
3 changed files with 182 additions and 7 deletions
|
|
@ -13,7 +13,7 @@ from hosts.core.import_export import (
|
|||
)
|
||||
from hosts.core.models import HostEntry, HostsFile
|
||||
from hosts.tui.app import HostsManagerApp
|
||||
from hosts.tui.import_export_modal import ExportModal, ImportModal
|
||||
from hosts.tui.import_export_modal import ExportModal, FileBrowserModal, ImportModal
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -42,6 +42,52 @@ async def test_export_shortcut_opens_a_format_chooser_and_reports_validation():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_export_modal_is_centered_in_the_terminal_viewport():
|
||||
"""The export form is centered rather than pinned to a terminal corner."""
|
||||
app = HostsManagerApp()
|
||||
app.load_hosts_file = Mock()
|
||||
|
||||
async with app.run_test(size=(120, 40)) as pilot:
|
||||
await pilot.press("ctrl+x")
|
||||
await pilot.pause()
|
||||
|
||||
container = app.screen.query_one("#format-container")
|
||||
assert container.region.x == (app.size.width - container.region.width) // 2
|
||||
|
||||
assert container.region.y == (app.size.height - container.region.height) // 2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_export_browser_lets_the_user_choose_a_destination_directory():
|
||||
"""Browse opens a centered directory tree rather than requiring a typed path."""
|
||||
app = HostsManagerApp()
|
||||
app.load_hosts_file = Mock()
|
||||
|
||||
async with app.run_test(size=(120, 40)) as pilot:
|
||||
await pilot.press("ctrl+x")
|
||||
await pilot.pause()
|
||||
await pilot.press("tab")
|
||||
await pilot.press("enter")
|
||||
await pilot.pause()
|
||||
await pilot.pause()
|
||||
|
||||
assert isinstance(app.screen, FileBrowserModal)
|
||||
assert app.screen.query_one("#file-browser-tree") is not None
|
||||
container = app.screen.query_one("#file-browser-container")
|
||||
assert container.region.x == (app.size.width - container.region.width) // 2
|
||||
|
||||
await pilot.press("tab")
|
||||
await pilot.press("tab")
|
||||
await pilot.press("enter")
|
||||
await pilot.pause()
|
||||
await pilot.pause()
|
||||
assert isinstance(app.screen, ExportModal)
|
||||
assert app.screen.query_one("#path-input", Input).value.endswith(
|
||||
"hosts-export.hosts"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_export_requires_overwrite_confirmation_before_calling_service(tmp_path):
|
||||
"""An existing output file is not replaced until the user confirms it."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue