Browse Source

provide integration test for #98

Rodja Trappe 2 years ago
parent
commit
3854793d1f
2 changed files with 16 additions and 2 deletions
  1. 4 2
      tests/screen.py
  2. 12 0
      tests/test_element.py

+ 4 - 2
tests/screen.py

@@ -113,12 +113,14 @@ class Screen():
     @staticmethod
     def simplify_input_tags(soup: BeautifulSoup) -> None:
         for element in soup.find_all(class_="q-field"):
-            print(element.prettify())
+            # print(element.prettify())
             new = soup.new_tag('simple_input')
             name = element.find(class_='q-field__label').text
             placeholder = element.find(class_='q-field__native').get('placeholder')
+            messages = element.find(class_='q-field__messages')
             value = element.find(class_='q-field__native').get('value')
-            new.string = (f'{name}: ' if name else '') + (value or placeholder or '')
+            new.string = (f'{name}: ' if name else '') + (value or placeholder or '') + \
+                f' \u002A{messages.text}' if messages else ''
             new['class'] = element['class']
             element.replace_with(new)
 

+ 12 - 0
tests/test_element.py

@@ -1,4 +1,5 @@
 
+import pytest
 from nicegui import ui
 from selenium.webdriver.common.action_chains import ActionChains
 from selenium.webdriver.common.by import By
@@ -27,6 +28,17 @@ def test_joystick(screen: Screen):
     assert screen.selenium.find_element(By.XPATH, '//div[@data-nicegui="joystick"]')
 
 
+@pytest.mark.skip(reason='not jet fixed; see https://github.com/zauberzeug/nicegui/issues/98')
+def test_input_with_multi_word_error_message(screen: Screen):
+    input = ui.input(label='some input')
+    ui.button('set error', on_click=lambda: input.props('error-message="Some multi word error message" error=error'))
+
+    screen.open('/')
+    screen.should_not_contain('Some multi word error message')
+    screen.click('set error')
+    screen.should_contain('Some multi word error message')
+
+
 def test_classes(screen: Screen):
     label = ui.label('Some label')