Skip to content

Commit

Permalink
naming update, req update, tab test
Browse files Browse the repository at this point in the history
  • Loading branch information
hausman-gdit committed Feb 5, 2024
1 parent 2c65035 commit 72e1b93
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bmds_server/desktop/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,20 @@ class ConfigTab(Static):
"""Configuration Tab"""

# Content Switch
@on(Button.Pressed, "#dir-container,#fn-container")
@on(Button.Pressed, "#btn-dir-container,#btn-fn-container")
def btn_container_switch(self, event: Button.Pressed) -> None:
self.query_one(ContentSwitcher).current = event.button.id
self.query_one(DirectoryContainer).reload()

def compose(self) -> ComposeResult:
with Horizontal(classes="config-tab"):
with Vertical(classes="config-btns"):
yield Button("Change Directory / Project", id="dir-container", classes="btn-auto")
yield Button("Create New Project", id="fn-container", classes="btn-auto")
yield Button(
"Change Directory / Project",
id="btn-dir-container",
classes="btn-auto",
)
yield Button("Create New Project", id="btn-fn-container", classes="btn-auto")
yield Rule(orientation="vertical")

with ContentSwitcher(initial="dir-container"):
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ redis==5.0.1
# desktop
textual==0.45.1
whitenoise==6.6.0
pytest-asyncio==0.23.4
36 changes: 36 additions & 0 deletions tests/desktop/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from textual.widgets import Tabs

from bmds_server.desktop.cli import BmdsDesktop

Expand All @@ -13,3 +14,38 @@ async def test_keys():
await pilot.press("s")
btn_start = app.query_one("#runner-button")
assert btn_start.label.__str__() == "Stop BMDS Desktop"


@pytest.mark.asyncio
async def test_tab_navigation_keyboard():
"""Keyboard Navigation"""
app = BmdsDesktop()

async with app.run_test() as pilot:
tabs = pilot.app.query_one(Tabs)
# That there are 3 tabs
assert tabs.tab_count == 3
# That when open app, a tab is active, and is "app" tab
assert tabs.active_tab is not None
assert tabs.active_tab.id == "app"
assert tabs.active == tabs.active_tab.id
# set focus to window
await pilot.press("tab")
# Check app tab content
btn_start = app.query_one("#runner-button")
assert btn_start.label.__str__() == "Start BMDS Desktop"
# Go to Logging tab
await pilot.press("right") # press right arrow key
assert tabs.active_tab is not None
assert tabs.active_tab.id == "tab-2"
assert tabs.active == tabs.active_tab.id
# Go to Config Tab
await pilot.press("right") # press right arrow key
assert tabs.active_tab is not None
assert tabs.active_tab.id == "config"
assert tabs.active == tabs.active_tab.id
# check Config tab buttons
btn_fn = app.query_one("#btn-fn-container")
assert btn_fn.label.__str__() == "Create New Project"
btn_dir = app.query_one("#btn-dir-container")
assert btn_dir.label.__str__() == "Change Directory / Project"

0 comments on commit 72e1b93

Please sign in to comment.