depressingly obscure fix for the done buttong on the identity page never being selectable

but hey, at least i have a nice test!
This commit is contained in:
Michael Hudson-Doyle 2017-12-07 16:27:02 +13:00
parent d1d65288e9
commit c04927eca6
2 changed files with 16 additions and 1 deletions

View File

@ -210,7 +210,7 @@ class IdentityView(BaseView):
('pack', Text("")),
button_pile([self.form.done_btn]),
('pack', Text("")),
])),
], focus_item=1)),
])
super().__init__(body)

View File

@ -18,6 +18,9 @@ class IdentityViewTests(unittest.TestCase):
controller.signal = mock.create_autospec(spec=Signal)
return IdentityView(model, controller, {})
def enter_valid_data(self, view):
view.form.realname.value = view.form.hostname.value = view.form.username.value = view.form.password.value = view.form.confirm_password.value = 'w'
def test_done_initially_disabled(self):
view = self.make_view()
self.assertFalse(view.form.done_btn.enabled)
@ -30,3 +33,15 @@ class IdentityViewTests(unittest.TestCase):
return
else:
self.fail("Realname widget not focus")
def test_can_tab_to_done_when_valid(self):
view = self.make_view()
self.enter_valid_data(view)
self.assertTrue(view.form.done_btn.enabled)
for i in range(10):
helpers.keypress(view, 'tab', size=(80, 24))
focus_path = helpers.get_focus_path(view)
for w in reversed(focus_path):
if w is view.form.done_btn:
return
self.fail("could not tab to done button")