Extend endpoint and browser tests for ESPNow and UI
Add coverage for /presets/send and updated tab/preset UI workflows in HTTP and Selenium tests.
This commit is contained in:
@@ -398,42 +398,49 @@ def test_tabs_ui(browser: BrowserTest) -> bool:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"✗ Failed to create tab via UI: {e}")
|
print(f"✗ Failed to create tab via UI: {e}")
|
||||||
|
|
||||||
# Test 4: Edit a tab via UI
|
# Test 4: Edit a tab via UI (right-click in Tabs list)
|
||||||
total += 1
|
total += 1
|
||||||
try:
|
try:
|
||||||
# Find edit button (should be in the tabs list)
|
|
||||||
# First, close and reopen modal to refresh
|
# First, close and reopen modal to refresh
|
||||||
browser.click_element(By.ID, 'tabs-close-btn')
|
browser.click_element(By.ID, 'tabs-close-btn')
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
browser.click_element(By.ID, 'tabs-btn')
|
browser.click_element(By.ID, 'tabs-btn')
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# Look for edit button - it should be in a profiles-row
|
# Right-click the row corresponding to 'Browser Test Tab'
|
||||||
edit_buttons = browser.driver.find_elements(By.XPATH, "//button[contains(text(), 'Edit')]")
|
try:
|
||||||
if edit_buttons:
|
tab_row = browser.driver.find_element(
|
||||||
# Use JavaScript click to avoid interception
|
By.XPATH,
|
||||||
browser.driver.execute_script("arguments[0].click();", edit_buttons[0])
|
"//div[@id='tabs-list-modal']//div[contains(@class,'profiles-row')][.//span[contains(text(), 'Browser Test Tab')]]"
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
tab_row = None
|
||||||
|
|
||||||
|
if tab_row:
|
||||||
|
actions = ActionChains(browser.driver)
|
||||||
|
actions.context_click(tab_row).perform()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# Check if edit modal opened
|
# Check if edit modal opened
|
||||||
edit_modal = browser.wait_for_element(By.ID, 'edit-tab-modal')
|
edit_modal = browser.wait_for_element(By.ID, 'edit-tab-modal')
|
||||||
if edit_modal:
|
if edit_modal:
|
||||||
print("✓ Edit modal opened")
|
print("✓ Edit modal opened via right-click")
|
||||||
# Fill in new name
|
# Fill in new name
|
||||||
if browser.fill_input(By.ID, 'edit-tab-name', 'Edited Browser Tab'):
|
if browser.fill_input(By.ID, 'edit-tab-name', 'Edited Browser Tab'):
|
||||||
print(" ✓ Filled new tab name")
|
print(" ✓ Filled new tab name")
|
||||||
# Submit form
|
# Submit form
|
||||||
edit_form = browser.wait_for_element(By.ID, 'edit-tab-form')
|
edit_form = browser.wait_for_element(By.ID, 'edit-tab-form')
|
||||||
if edit_form:
|
if edit_form:
|
||||||
edit_form.submit()
|
browser.driver.execute_script("arguments[0].submit();", edit_form)
|
||||||
time.sleep(1) # Wait for update
|
time.sleep(1) # Wait for update
|
||||||
print("✓ Submitted edit form")
|
print("✓ Submitted edit form")
|
||||||
passed += 1
|
passed += 1
|
||||||
else:
|
else:
|
||||||
print("✗ Edit form not found")
|
print("✗ Edit form not found")
|
||||||
else:
|
else:
|
||||||
print("✗ Edit modal didn't open")
|
print("✗ Edit modal didn't open after right-click")
|
||||||
else:
|
else:
|
||||||
print("✗ No edit buttons found (might need to create a tab first)")
|
print("✗ Could not find tab row for 'Browser Test Tab'")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"✗ Failed to edit tab via UI: {e}")
|
print(f"✗ Failed to edit tab via UI: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
|
|||||||
@@ -332,7 +332,22 @@ def test_presets(client: TestClient) -> bool:
|
|||||||
else:
|
else:
|
||||||
print(f"✗ PUT /presets/{preset_id} - Status: {response.status_code}")
|
print(f"✗ PUT /presets/{preset_id} - Status: {response.status_code}")
|
||||||
|
|
||||||
# Test 5: Delete preset
|
# Test 5: Send preset via /presets/send
|
||||||
|
total += 1
|
||||||
|
try:
|
||||||
|
send_body = {"preset_ids": [preset_id]}
|
||||||
|
response = client.post('/presets/send', json_data=send_body)
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
sent = data.get('presets_sent')
|
||||||
|
print(f"✓ POST /presets/send - Sent presets (presets_sent={sent})")
|
||||||
|
passed += 1
|
||||||
|
else:
|
||||||
|
print(f"✗ POST /presets/send - Status: {response.status_code}, Response: {response.text}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"✗ POST /presets/send - Error: {e}")
|
||||||
|
|
||||||
|
# Test 6: Delete preset
|
||||||
total += 1
|
total += 1
|
||||||
response = client.delete(f'/presets/{preset_id}')
|
response = client.delete(f'/presets/{preset_id}')
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
|
|||||||
Reference in New Issue
Block a user