' in content or \
'
0:
click_handler = html[click_handler_start:click_handler_start + 500]
assert 'icon-picker-dropdown' in click_handler, "Should reference icon-picker-dropdown"
assert 'contains' in click_handler, "Should check if click is inside dropdown"
assert 'closeIconPicker()' in click_handler, "Should close if clicked outside"
print("✓ Test 158 passed: Click outside closes dropdown")
def test_icon_picker_updates_trigger_display():
"""Test 159: Selected icon updates trigger button display"""
habits_path = Path(__file__).parent.parent / 'habits.html'
html = habits_path.read_text()
# Check that selectIcon updates the trigger display
select_icon_section = html[html.find('function selectIcon('):html.find('function selectIcon(') + 1500]
assert 'selectedIconDisplay' in select_icon_section, "Should update selectedIconDisplay element"
assert 'setAttribute' in select_icon_section, "Should set icon attribute"
assert 'data-lucide' in select_icon_section, "Should update data-lucide attribute"
assert 'lucide.createIcons()' in select_icon_section, "Should refresh Lucide icons"
print("✓ Test 159 passed: Trigger display updates on selection")
def test_icon_picker_css_dropdown_styles():
"""Test 160: CSS includes dropdown-specific styles"""
habits_path = Path(__file__).parent.parent / 'habits.html'
html = habits_path.read_text()
# Check for dropdown-specific CSS
assert '.icon-picker-dropdown' in html, "Should have dropdown container styles"
assert '.icon-picker-trigger' in html, "Should have trigger button styles"
assert '.icon-picker-content' in html, "Should have content container styles"
assert 'position: absolute' in html, "Content should be absolutely positioned"
assert 'z-index: 100' in html, "Content should have high z-index"
# Check for hover states
assert '.icon-picker-trigger:hover' in html, "Should have trigger hover state"
print("✓ Test 160 passed: Dropdown CSS styles present")
def test_icon_picker_chevron_rotation():
"""Test 161: Chevron rotates when dropdown opens"""
habits_path = Path(__file__).parent.parent / 'habits.html'
html = habits_path.read_text()
# Check for chevron rotation in CSS
assert 'trigger-chevron' in html, "Chevron should have trigger-chevron class"
assert 'transform: rotate(180deg)' in html, "Chevron should rotate 180deg when open"
assert '.open .trigger-chevron' in html or '.icon-picker-trigger.open .trigger-chevron' in html, "Should rotate when trigger has open class"
# Check that open class is toggled
assert "classList.add('open')" in html, "Should add open class"
assert "classList.remove('open')" in html, "Should remove open class"
print("✓ Test 161 passed: Chevron rotation logic")
def test_icon_picker_search_autofocus():
"""Test 162: Search input gets focus when dropdown opens"""
habits_path = Path(__file__).parent.parent / 'habits.html'
html = habits_path.read_text()
# Check that openIconPicker focuses the search input
open_icon_picker = html[html.find('function openIconPicker()'):html.find('function openIconPicker()') + 800]
assert 'focus()' in open_icon_picker, "Should focus search input when opening"
assert 'setTimeout' in open_icon_picker, "Should use setTimeout for focus after animation"
print("✓ Test 162 passed: Search input autofocus")
def test_typecheck_us006():
"""Test 163: Typecheck passes"""
result = subprocess.run(
['python3', '-m', 'py_compile', 'dashboard/api.py', 'dashboard/habits_helpers.py'],
cwd='/home/moltbot/clawd',
capture_output=True,
text=True
)
assert result.returncode == 0, f"Typecheck failed: {result.stderr}"
print("✓ Test 163 passed: Typecheck successful")