1
0

test_select.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from nicegui import ui
  2. from .screen import Screen
  3. def test_select(screen: Screen):
  4. ui.select(['A', 'B', 'C'], value='A')
  5. screen.open('/')
  6. screen.should_contain('A')
  7. screen.should_not_contain('B')
  8. screen.should_not_contain('C')
  9. screen.click('A') # open the dropdown
  10. screen.click('B') # close the dropdown
  11. screen.wait(0.5)
  12. screen.should_not_contain('A')
  13. screen.should_contain('B')
  14. screen.should_not_contain('C')
  15. def test_select_with_input(screen: Screen):
  16. ui.select(['A', 'AB', 'XYZ'], with_input=True)
  17. screen.open('/')
  18. screen.find_by_tag('input').click()
  19. screen.should_contain('XYZ')
  20. screen.find_by_tag('input').send_keys('A')
  21. screen.wait(0.5)
  22. screen.should_contain('A')
  23. screen.should_contain('AB')
  24. screen.should_not_contain('XYZ')
  25. def test_replace_select(screen: Screen):
  26. with ui.row() as container:
  27. ui.select(['A'], value='A')
  28. def replace():
  29. container.clear()
  30. with container:
  31. ui.select(['B'], value='B')
  32. ui.button('Replace', on_click=replace)
  33. screen.open('/')
  34. screen.should_contain('A')
  35. screen.click('Replace')
  36. screen.should_contain('B')
  37. screen.should_not_contain('A')