test_groups.py 957 B

12345678910111213141516171819202122232425262728293031323334
  1. from nicegui import ui
  2. from .screen import Screen
  3. def test_remove_and_clear(screen: Screen):
  4. with ui.row() as row:
  5. ui.label('Label A')
  6. b = ui.label('Label B')
  7. ui.label('Label C')
  8. ui.button('Remove B', on_click=lambda: row.remove(b))
  9. ui.button('Remove 0', on_click=lambda: row.remove(0))
  10. ui.button('Clear', on_click=lambda: row.clear())
  11. screen.open('/')
  12. screen.should_contain('Label A')
  13. screen.should_contain('Label B')
  14. screen.should_contain('Label C')
  15. screen.click('Remove B')
  16. screen.should_contain('Label A')
  17. screen.should_not_contain('Label B')
  18. screen.should_contain('Label C')
  19. screen.click('Remove 0')
  20. screen.should_not_contain('Label A')
  21. screen.should_not_contain('Label B')
  22. screen.should_contain('Label C')
  23. screen.click('Clear')
  24. screen.should_not_contain('Label A')
  25. screen.should_not_contain('Label B')
  26. screen.should_not_contain('Label C')