Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for ElementFilter and User #3381

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

rodja
Copy link
Member

@rodja rodja commented Jul 22, 2024

This PR addresses the mypy warnings from the integration-test-framework branch.

@rodja rodja added the enhancement New feature or request label Jul 22, 2024
@falkoschindler falkoschindler merged commit e8afcb5 into integration-test-framework Jul 22, 2024
6 checks passed
@falkoschindler falkoschindler deleted the element-filter-typing branch July 22, 2024 09:52
rodja added a commit that referenced this pull request Aug 3, 2024
* begin implementing ui.get to query elements

* type hinting, getting all elements and __repr__

* set style, classes, props with ui.get()

* introduce .within filter

* more stable test

* element.keys(..) + ui.get(key=...)

* allow setting multiple keys for ui.get

* allow filtering ui.get(..).within(key=..)

* allow multiple keys in ui.get

* testing ui.get with TextElement

* allow filtering with `ui.get(text=...)`

* ui.get(..).exclude(type=..., key=..., text=...)

* introduce ui.get().not_within(...)

* add documentation page and use_local_scope param

* fixed default

* ui.get within elements

* Enhance test example to show how to test with routing.
Also rename pytest example to integration_tests to not have name-collisions

* first proof of concept for simulated screen

* demo async test

* fix click in simulated screen

* simulated screen can now handle async pages

* do module reloading through pytest marker

* determine whether to use simulation screen or selenium screen

* rename Screen to SeleniumScreen to better pair it with SimulatedScreen

* docstrings

* custom marker

* first concept of detecting failures on event loop

* checking exceptions in other thread

* use same event loop for tests and app which simplifies things a lot

* show content of simulated screen on failure

* simulating sio handshake to test for connection

* notes

* provide pytest plugin and ensure SimulatedScreen does not load Selenium fixtures

* remove pytest.ini

* better description for pytest marker

* ensure fixtures are run when using screen

* ensure loop is closed

* cleanup

* fixed async warning by making selenium_screen fixture non-async

* start testing the chat app example

* test typing into chat app

* fix test

* cleanup

* ignore test_ files when building link examples

* python 3.8 compatibility

* re-adding tests/conftest.py because nicegui itself does not benefit from the newly provided pytest plugin

* for testing we need to manage multiple clients in the same asyncio task

* use __init__.py and relative import to get right main module

* element tests without screen need to explicitly reset globals

* keep original stack behaviour if we do not simulate

* rename ui.get to ui.find

* rename element.tags to element.markers

* refactored ui.find into ElementFilter which serves as  foundation for new user.should_see(...)

* better naming and fixed documentation

* cleanup

* increased is-displayed delay

* do multiple checks for visibility

* adapt tests to use SeleniumScreen

* use configurable url

* allow subclasses of screen fixtures

* clear urls and reset on_air for each test

* cleanup

* registering signals does not work in pytests

* user.should_see is now async

* warn if its not a nicegui page

* print markers

* provide check if code is executed in pytest

* support storage in simulated screen

* dropped simulated screen concept to make one user visit multiple pages (for example via ui.navigate.to)

* re-add typing capabilities

* check for notifications

* fix ui.navigate.to for simulation

* renaming

* fix excluding_text test

* make conftest generally available (like the examples)

* cleanup

* fix usage of context

* support for auto-index-pages

* click checkbox toggles value in simulation

* fix "Self" import

* make fixtures available via pytest plugin

* adapted new tests to new structure

* ensure utf-8

* try latest pytest

* use newly named screen class

* update dependencies

* restore original ui.navigate.to after we exit simulated user

* fix logging and types

* fix type hint for python 3.8

* fix users fixture in combination with ui.navigate.to

* try with longer timeout

* only prepare auto index client for simulation if the user fixture is chosen

* analyze core.loop issue with failing tests

* Revert "analyze core.loop issue with failing tests"

This reverts commit 725965c.

* only assert loop is closed if it has been created
because some tests may exit without calling screen.open()

* better naming

* renaming function and files

* renaming

* cleanup

* add user.should_not_see and user.trigger methods

* add integration tests for todo list example

* icon prop is content

* fix typing

* return self

* add integration tests for authentication example
this uncovered the need to get new context in every retry to handle page changes

* allow clicking on links in user simulation

* always stop server

* add link to example

* remove accidentally commited env file

* renaming

* improve check if we are running as pytest

* add typehint

* remove obsolete try/except

* remove obsolete code (may have been here due to bad merge conflict resolving)

* cleanup

* reload run module between tests to fix it on GitHub Action

* introduction of UserFocus to trigger events

* using non-async user.focus to simplify API

* add user.focus(...).click()

* updated tests to use new user.focus for interaction

* formatting

* reset to main version

* adapted auth tests

* make Self available for lower python versions

* provide overloaded methods to simplify API

* renaming and more simplifications

* better imports

* fix import Self

* renaming

* code review

* add back requirements.txt

* code review

* rework str output shown on a failing test

* fix some typing issues

* remove obsolete test

* simplify test_multiple_pages

* update element filter tests to use User instead of Screen

* fix tests by resetting default attributes for elements

* Use ui.notification for ui.notify to simplify user simulation tests (#3369)

* use ui.notification for ui.notify to simplify user simulation tests

* code review

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* Use `Set` in user._gather_elements and improve typing (#3370)

* use set in user._gather_elements and improve typing

* code review

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* code review for Element.__str__

* simplify mark()

* Fix typing for ElementFilter and User (#3381)

* improve typing and naming

* fix typing

* reverted "kind" and type T of ElementFilter

* fix element filter type inference

* fix typing in __next__

* ignore typing where it can not be matched

* open page

* code review

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* Implement full `ui.navigate` functionality for user simulation (#3382)

* make ui.navigate an object of a replaceable class to simplify and improve user simulation

* provide ui.navigate.reload for user simulation

* code review

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* Make combining multiple content filters more robust (#3383)

* make ui.navigate an object of a replaceable class to simplify and improve user simulation

* provide ui.navigate.reload for user simulation

* make combining multiple content filters more robust

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* fix problem with `ui.navigate` on documentation page

* move element filter documentation to styling and appearance

* fix ui.open

* pylint

* try removing explicit response.encoding

* add user interaction with ui.switch, ui.editor and ui.codemirror

* Improve iteration of elements (#3385)

* make ui.navigate an object of a replaceable class to simplify and improve user simulation

* provide ui.navigate.reload for user simulation

* make combining multiple content filters more robust

* introduce element.ancestors and element.descendants

* rewrite __iter__ (tests still failing)

* fix typo

* improve filter

* fix another condition

* fix deletion of elements

* replace tee with list for efficiency

* add some more tests and fix conditions

* remove len and getitem

---------

Co-authored-by: Rodja Trappe <rodja@zauberzeug.com>

* improve type annotation

* extend docstring

* fix rule for ancestor kinds

* refactor element filter tests

* fix link to example folder

* more consistent rules

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* update filter rules and re-organize element filter tests

* add test which combines multiple "within" statements

* demonstrate validity of having multiple elements for a singe within clause

* pytest configuration & fixtures (#3411)

* remove pytest-prefix from plugin specification

* fix requirements and settings for pytests example

* rename screen and user with prefix nicegui_

* add conftest with renaming to pytests example

* add internal renaming of nicegui_screen to screen and nicegui_user to user

* remove unused pylint ignore

* fix rename in examples

* remove entry point

* remove renaming

* remove renaming in examples

* remove renaming fixtures and add example code

* double quotes

* reworked as described in docs (#3413)

* add pytest plugin loading to examples

* run the pytest examples as part of the test_startup.sh to avoid conflicts in setup

* renamed the pytest plugin from fixtures.py to plugin.py

* fix todo tests

* rename folder

---------

Co-authored-by: Rodja Trappe <rodja@zauberzeug.com>
Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* remove redundant test

* add multi-user navigation test

* Add documentation of pytest fixtures and pytest configuration (#3413)

* begin with documentation of fixtures and pytest setup

* code review

* also prepare simulation for screen fixture

* replace hacky docs.pytest and Demo.raw with generic docs.part

* better split of testing topics in the docs

* improve user docs

* add UserInteraction reference

* review

* simplify doc.part

* fix storage test

* web driver info

* review

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>

* add conftest.py for backward compatibility

* remove activate() and deactivate()

---------

Co-authored-by: Falko Schindler <falko@zauberzeug.com>
Co-authored-by: Paula Kammler <paula@zauberzeug.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants