Hello i am new on nicegui, i create a simple app where i need to upload the files and store this files on ftp server. I start to make some tests with nicegui.testing.User (i use this package because i don't need to install the selisium package) i want to know how to simulate a test of uploading files.
# simple function for handle_uplaod
# file_handler.py
def handle_file_upload(file_name : str ) :
# some logic for store the file on the ftp server
# main.py
# imports ...
ui.page("/")
def main():
ui.upload(on_upload = lambda file_name :handle_file_upload(file_name), auto_upload = True)
# tests/test_upload_file.py
ui.run() @pytest.mark.asyncio
async def test_upload_file(user: User) -> None:
"""Test step 2 page elements"""
# loading the real page
await user.open("/")
upload = user.find(ui.upload).elements.pop()
upload.handle_uploads([ui.upload.SmallFileUpload("file.psd", "application/pdf", b"Test Service Terms File Hello")])
# How to apply tests xD
asserts ...
asserts ...