Skip to content

Comments

add test for chat settings#2669

Merged
hayescode merged 2 commits intoChainlit:mainfrom
codomposer:feat/test_chat_settings
Nov 20, 2025
Merged

add test for chat settings#2669
hayescode merged 2 commits intoChainlit:mainfrom
codomposer:feat/test_chat_settings

Conversation

@codomposer
Copy link
Contributor

@codomposer codomposer commented Nov 20, 2025

Add Comprehensive Test Suite for ChatSettings

Overview

Adds comprehensive test coverage for the ChatSettings class, ensuring proper initialization, settings collection, and emission functionality for chat configuration UI.

Changes

New Test File

  • tests/test_chat_settings.py - 16 tests covering ChatSettings functionality

Updated Test Fixture

  • tests/conftest.py - Added emit and set_chat_settings mocks to emitter

Test Coverage

Core Functionality (11 tests)

  • ChatSettings initialization with widgets and tabs
  • Settings collection from flat widget lists
  • Settings collection from nested tab structures
  • send() method with emitter integration
  • Support for all InputWidget types
  • None initial values handling

Edge Cases (5 tests)

  • Empty tabs
  • Duplicate widget IDs (last value wins)
  • Return value validation
  • Serialization of inputs in send()
  • Complex tab structures

Key Features Tested

Settings Collection

# Flat widgets
settings = ChatSettings(inputs=[
    Switch(id="enable", label="Enable", initial=True),
    Slider(id="temp", label="Temperature", initial=0.7)
])
result = settings.settings()  # {"enable": True, "temp": 0.7}

Tab Support

# Nested tabs
tab1 = Tab(id="tab1", label="General", inputs=[...])
tab2 = Tab(id="tab2", label="Advanced", inputs=[...])
settings = ChatSettings(inputs=[tab1, tab2])
# Collects all inputs from all tabs

Send Method

# Emits settings to UI and returns values
result = await settings.send()
# Calls: emitter.set_chat_settings() and emitter.emit("chat_settings", ...)

Test Statistics

  • Total Tests: 16
  • Test Classes: 2
  • Coverage: Initialization, settings collection, emission, tabs, edge cases

Contribution by Gittensor, learn more at https://gittensor.io/

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. dev-tooling Relating to developer/contributor toolings. labels Nov 20, 2025
@hayescode hayescode enabled auto-merge November 20, 2025 02:23
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@hayescode hayescode added this pull request to the merge queue Nov 20, 2025
Merged via the queue into Chainlit:main with commit e92ee2f Nov 20, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-tooling Relating to developer/contributor toolings. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants