Skip to content

Commit

Permalink
Allow testing for validation texts (#3765)
Browse files Browse the repository at this point in the history
allow testing for validation texts
  • Loading branch information
rodja committed Sep 24, 2024
1 parent f58c518 commit 2c67684
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions nicegui/element_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def __iter__(self) -> Iterator[T]:
element.props.get('icon'),
element.props.get('placeholder'),
element.props.get('value'),
element.props.get('error-message'),
element.text if isinstance(element, TextElement) else None,
element.content if isinstance(element, ContentElement) else None,
element.source if isinstance(element, SourceElement) else None,
Expand Down
9 changes: 9 additions & 0 deletions tests/test_user_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,12 @@ def page():
assert len(user.download.http_responses) == 1
assert response.status_code == 200
assert response.text == 'Hello'


async def test_validation(user: User) -> None:
ui.input('Number', validation={'Not a number': lambda value: value.isnumeric()})

await user.open('/')
await user.should_not_see('Not a number')
user.find(ui.input).type('some invalid entry')
await user.should_see('Not a number')

0 comments on commit 2c67684

Please sign in to comment.