test_notification.py 673 B

1234567891011121314151617181920212223
  1. from nicegui import ui
  2. from nicegui.testing import Screen
  3. def test_notification(screen: Screen):
  4. ui.button('Notify', on_click=lambda: ui.notification('Hi!'))
  5. screen.open('/')
  6. screen.click('Notify')
  7. screen.should_contain('Hi!')
  8. def test_close_button(screen: Screen):
  9. b = ui.button('Notify', on_click=lambda: ui.notification('Hi!', timeout=None, close_button=True))
  10. screen.open('/')
  11. screen.click('Notify')
  12. screen.should_contain('Hi!')
  13. assert len(b.client.layout.default_slot.children) == 2
  14. screen.click('Close')
  15. screen.wait(1.5)
  16. screen.should_not_contain('Hi!')
  17. assert len(b.client.layout.default_slot.children) == 1