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

Testing: Recognition of Autocomplete Input #3886

Open
GrazingScientist opened this issue Oct 16, 2024 · 5 comments
Open

Testing: Recognition of Autocomplete Input #3886

GrazingScientist opened this issue Oct 16, 2024 · 5 comments
Assignees

Comments

@GrazingScientist
Copy link

GrazingScientist commented Oct 16, 2024

Description

Hi!

I found another non-working feature in the testing framework, when I want to test that the autocomplete is working.

The test below is failing, although it should not.

from nicegui import ui

def setup() -> None:
    @ui.page("/")
    def main() -> None:
        options = ['AutoComplete', 'NiceGUI', 'Awesome']
        ui.input(label='Text', placeholder='start typing', autocomplete=options)

async def test_validation(user):
    setup()

    await user.open("/")

    await user.should_not_see("AutoComplete")
    user.find("Text").type("Auto")
    await user.should_see("AutoComplete")

I hope, you can fix it. ❤️

@rodja
Copy link
Member

rodja commented Oct 17, 2024

Thanks for bringing up this example @GrazingScientist. I think it is a little bit more complicated. If you start your page with NiceGUI and type "Auto" in the browser, you must also press the "TAB" key to confirm the auto completion. So we would need to use user.find("Text").type("Auto").trigger("keydown.tab").

@GrazingScientist
Copy link
Author

GrazingScientist commented Oct 17, 2024

Hi @rodja ,

thanks for coming back so quickly. I eagerly tried your tip, but the result is the same. The test fails with:

AssertionError: expected to see at least one element with marker=AutoComplete or content=AutoComplete on the page

This is the code I used:

from nicegui import ui

def setup() -> None:
    @ui.page("/")
    def main() -> None:
        options = ["AutoComplete", "NiceGUI", "Awesome"]
        ui.input(label="Text", placeholder="start typing", autocomplete=options)

async def test_validation(user):
    setup()

    await user.open("/")

    await user.should_not_see("AutoComplete")
    user.find("Text").type("Auto").trigger("keydown.tab")
    await user.should_see("AutoComplete")

@rodja
Copy link
Member

rodja commented Oct 17, 2024

I'm sorry. This is not implemented yet. I just wanted to clarify the API. We are pretty busy at the moment. Would you like to try creating a pull request.

@GrazingScientist
Copy link
Author

I will try to dig into the code, if I have the time. Can you provide me a link to the code section, where I need to focus on?

@rodja
Copy link
Member

rodja commented Oct 17, 2024

I think you could try adding a special case for ui.input in the trigger loop over all elements:

for element in self.elements:

Similar to what we do for ui.link and ui.select in the click method:

https://github.com/zauberzeug/nicegui/blob/809290e3037a837fd231330c096da6409143f6ab/nicegui/testing/user_interaction.py#L63C17-L70C55

An workaround until we get this done might be to just get the element and check for the possible autocompletes by accessing the .props dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants