Skip to content

Commit a63e953

Browse files
committed
test(web): fix 6 settings-panel e2e strict-locator failures (Issue #2)
The panel works live; the tests' locators were wrong. Each provider row renders ALL THREE auth-kind control divs (api_key / bedrock_bearer / local_keyless), x-show-hidden but present in the DOM, and every row has its own .key-ok / .key-error status spans. So: - unscoped input[type=password] / "Test & save" matched a visible control AND a hidden one -> strict-mode violation; - page.wait_for_selector(".provider-row .key-ok") matched all 3 rows and waited on the first (openai's), which never becomes visible -> timeout. Fix (selectors only, panel untouched, per handoff): - scope inputs/buttons with :visible; - assert "no VISIBLE password input" for Ollama (hidden ones legitimately exist); - wait on the acted-on row's own .key-ok/.key-error via row.locator(...).wait_for. All 8 settings-panel e2e tests pass (was 6 failed / 2 passed).
1 parent 00045b1 commit a63e953

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

packages/studyloop/tests/test_web_settings_panel_e2e.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,31 @@ def test_api_key_row_shows_password_input(self, page: Page) -> None:
180180
_goto_settings(page)
181181
_wait_rows(page)
182182
row = _row(page, "OpenAI")
183-
assert row.locator("input[type='password']").is_visible()
184-
assert row.locator("button:has-text('Test & save')").is_visible()
183+
# Every provider row renders all three auth-kind control divs (x-show
184+
# hides the inactive ones but they stay in the DOM), so an unscoped
185+
# input[type=password] matches the api_key AND the hidden bedrock_bearer
186+
# input. Scope to the visible control to avoid the strict-mode collision.
187+
assert row.locator("input[type='password']:visible").is_visible()
188+
assert row.locator("button:visible:has-text('Test & save')").is_visible()
185189

186190
def test_bedrock_row_shows_bearer_input_and_hint(self, page: Page) -> None:
187191
_route_providers(page)
188192
_goto_settings(page)
189193
_wait_rows(page)
190194
row = _row(page, "AWS Bedrock")
191-
assert row.locator("input[type='password']").is_visible()
195+
assert row.locator("input[type='password']:visible").is_visible()
192196
assert "AWS_BEARER_TOKEN_BEDROCK" in row.inner_text()
193197

194198
def test_ollama_row_shows_url_input_not_password(self, page: Page) -> None:
195199
_route_providers(page)
196200
_goto_settings(page)
197201
_wait_rows(page)
198202
row = _row(page, "Ollama (local)")
199-
assert row.locator("input[type='text']").is_visible()
200-
assert row.locator("input[type='password']").count() == 0
201-
assert row.locator("button:has-text('Test connection')").is_visible()
203+
assert row.locator("input[type='text']:visible").is_visible()
204+
# Hidden api_key/bedrock password inputs still exist in the DOM (x-show);
205+
# assert no VISIBLE password input rather than none in the DOM.
206+
assert row.locator("input[type='password']:visible").count() == 0
207+
assert row.locator("button:visible:has-text('Test connection')").is_visible()
202208

203209

204210
class TestSaveKeyFlow:
@@ -216,11 +222,11 @@ def handle_post(route):
216222
_goto_settings(page)
217223
_wait_rows(page)
218224
row = _row(page, "OpenAI")
219-
row.locator("input[type='password']").fill("sk-test-123")
220-
row.locator("button:has-text('Test & save')").click()
221-
page.wait_for_function(
222-
"() => !!document.querySelector('.provider-row .key-ok')", timeout=3000
223-
)
225+
row.locator("input[type='password']:visible").fill("sk-test-123")
226+
row.locator("button:visible:has-text('Test & save')").click()
227+
# Wait for THIS row's success marker to become visible (every row has a
228+
# .key-ok element; only the acted-on row's is shown via x-show).
229+
row.locator(".key-ok").wait_for(state="visible", timeout=3000)
224230
assert posted["body"] == {"provider": "openai", "key": "sk-test-123"}
225231

226232

@@ -238,8 +244,8 @@ def test_ollama_test_success_shows_ok(self, page: Page) -> None:
238244
_goto_settings(page)
239245
_wait_rows(page)
240246
row = _row(page, "Ollama (local)")
241-
row.locator("button:has-text('Test connection')").click()
242-
page.wait_for_selector(".provider-row .key-ok", state="visible", timeout=3000)
247+
row.locator("button:visible:has-text('Test connection')").click()
248+
row.locator(".key-ok").wait_for(state="visible", timeout=5000)
243249
assert "3 cards" in row.inner_text()
244250

245251
def test_ollama_test_failure_shows_error(self, page: Page) -> None:
@@ -255,6 +261,6 @@ def test_ollama_test_failure_shows_error(self, page: Page) -> None:
255261
_goto_settings(page)
256262
_wait_rows(page)
257263
row = _row(page, "Ollama (local)")
258-
row.locator("button:has-text('Test connection')").click()
259-
page.wait_for_selector(".provider-row .key-error", state="visible", timeout=3000)
264+
row.locator("button:visible:has-text('Test connection')").click()
265+
row.locator(".key-error").wait_for(state="visible", timeout=5000)
260266
assert "unreachable" in row.inner_text()

0 commit comments

Comments
 (0)