test_mermaid.py 928 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from nicegui import ui
  2. from .screen import Screen
  3. def test_mermaid(screen: Screen):
  4. m = ui.mermaid('''
  5. graph TD;
  6. Node_A --> Node_B;
  7. ''')
  8. screen.open('/')
  9. assert screen.find('Node_A').get_attribute('class') == 'nodeLabel'
  10. m.set_content('''
  11. graph TD;
  12. Node_C --> Node_D;
  13. ''')
  14. assert screen.find('Node_C').get_attribute('class') == 'nodeLabel'
  15. screen.should_not_contain('Node_A')
  16. def test_mermaid_with_line_breaks(screen: Screen):
  17. ui.mermaid('''
  18. requirementDiagram
  19. requirement test_req {
  20. id: 1
  21. text: some test text
  22. risk: high
  23. verifymethod: test
  24. }
  25. ''')
  26. screen.open('/')
  27. screen.should_contain('<<Requirement>>')
  28. screen.should_contain('Id: 1')
  29. screen.should_contain('Text: some test text')
  30. screen.should_contain('Risk: High')
  31. screen.should_contain('Verification: Test')