Repository: streamlit/streamlit
File: e2e_playwright/st_chat_input_test.py (Python)

Code before:
    # shown over the uploaded file tooltip hover target:
    reset_hovering(app)
    expect_help_tooltip(app, uploaded_files, "File must be 1.0MB or smaller.")


def test_single_file_upload_button_tooltip(app: Page):
    """Test that the single file upload button tooltip renders correctly."""
    app.set_viewport_size({"width": 750, "height": 2000})

    chat_input_upload_button = get_element_by_key(app, "chat_input_4").get_by_test_id(
        "stChatInputFileUploadButton"
    )
    expect(chat_input_upload_button).to_be_visible()
    chat_input_upload_button.scroll_into_view_if_needed()

    expect_help_tooltip(app, chat_input_upload_button, "Upload or drag and drop a file")
    # Hover on the tooltip hover target


def test_multi_file_upload_button_tooltip(app: Page):
    """Test that the multi file upload button tooltip renders correctly."""
    app.set_viewport_size({"width": 750, "height": 2000})

    chat_input_upload_button = get_element_by_key(app, "chat_input_5").get_by_test_id(
        "stChatInputFileUploadButton"
    )
    expect(chat_input_upload_button).to_be_visible()
    chat_input_upload_button.scroll_into_view_if_needed()

    expect_help_tooltip(app, chat_input_upload_button, "Upload or drag and drop files")


def test_directory_upload_button_tooltip(app: Page):
    """Test that the directory upload button tooltip renders correctly."""
    app.set_viewport_size({"width": 750, "height": 2000})

    chat_input_upload_button = get_element_by_key(app, "chat_input_9").get_by_test_id(
        "stChatInputFileUploadButton"
    )
    expect(chat_input_upload_button).to_be_visible()
    chat_input_upload_button.scroll_into_view_if_needed()

    expect_help_tooltip(
        app, chat_input_upload_button, "Upload or drag and drop a directory"
    )


def test_directory_upload_disabled_state(app: Page):
    """Test that disabled directory upload input cannot be interacted with."""
    disabled_chat_input = get_element_by_key(app, "chat_input_10")
    disabled_upload_button = disabled_chat_input.get_by_test_id(

Review comment (suggestion):
This line still seems to be slightly flaky in webkit (but 3 in 50 might be somewhat ok). Based on the error it seems like either the tooltip already shows before hovering or it doesn't disappear after triggering the `reset_hovering` in `expect_help_tooltip`. Maybe its fine to just verify this via (instead of using `expect_help_tooltip` here): 

```
hover_target.hover()
tooltip_content =  app.get_by_test_id("stTooltipContent")
expect(tooltip_content).to_be_visible()
expect(tooltip_content).to_have_text("File must be 1.0MB or smaller.")
```

Code after:
    expect(chat_input).to_be_visible()
    file_upload_helper(app, chat_input, [file1])

    uploaded_files = chat_input.get_by_test_id("stChatUploadedFiles").first
    expect(uploaded_files).to_be_visible()

    # Verify the file appears in the uploaded files list
    expect(uploaded_files.get_by_text(file_name1)).to_be_visible()

    uploaded_file = uploaded_files.get_by_test_id("stChatInputFile").first
    expect(uploaded_file).to_be_visible()

    uploaded_files.scroll_into_view_if_needed()

    # Reset hovering to not cause issues with the upload tooltip being
    # shown over the uploaded file tooltip hover target:
    reset_hovering(app)

    # Ensure the upload button tooltip has disappeared before checking the error tooltip
    expect(app.get_by_text("Upload or drag and drop a file")).not_to_be_attached()

    # Ensure the tooltip hover target is in viewport before hovering (WebKit requirement)
    hover_target = uploaded_files.get_by_test_id("stTooltipHoverTarget")
    hover_target.scroll_into_view_if_needed()

    expect_help_tooltip(app, uploaded_files, "File must be 1.0MB or smaller.")


def test_single_file_upload_button_tooltip(app: Page):
    """Test that the single file upload button tooltip renders correctly."""
    app.set_viewport_size({"width": 750, "height": 2000})

    chat_input_upload_button = get_element_by_key(app, "chat_input_4").get_by_test_id(
        "stChatInputFileUploadButton"
    )
    expect(chat_input_upload_button).to_be_visible()
    chat_input_upload_button.scroll_into_view_if_needed()

    expect_help_tooltip(app, chat_input_upload_button, "Upload or drag and drop a file")
    # Hover on the tooltip hover target


def test_multi_file_upload_button_tooltip(app: Page):
    """Test that the multi file upload button tooltip renders correctly."""
    app.set_viewport_size({"width": 750, "height": 2000})

    chat_input_upload_button = get_element_by_key(app, "chat_input_5").get_by_test_id(
        "stChatInputFileUploadButton"
    )
    expect(chat_input_upload_button).to_be_visible()
    chat_input_upload_button.scroll_into_view_if_needed()