Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

docs(ui-tests): document findActionButton + test_lib helpers (#4166)

LearningCircuitd696af4185d2
diff --git a/tests/ui_tests/README.md b/tests/ui_tests/README.md
index 9ba1e89897..684914c38d 100644
--- a/tests/ui_tests/README.md
+++ b/tests/ui_tests/README.md
@@ -242,6 +242,19 @@ Failed: 0
🎉 All tests passed!
```
+## Shared helpers in `test_lib/`
+
+Common patterns live in `tests/ui_tests/test_lib/` and are re-exported from `./test_lib`. Use these rather than inlining the equivalent logic — duplicated logic is how the same bug class hides in multiple files (#4069 / #4127).
+
+- **`findActionButton(page, { selectors, keywords, click })`** — locate a button by text content with **word-boundary** matching. Defaults to `selectors='button, a.btn, .btn'` and `keywords=['create', 'new', 'add']`. Returns `{ found, text }`.
+ - Why this exists: `text.includes('new')` matches the substring "new" inside "News" (e.g. an unrelated `<a>Back to News Feed</a>` button). The helper wraps `\b(?:create|new|add)\b` so "Create Subscription" / "New Folder" / "Add Item" still match but "News Feed" doesn't.
+ - Example: `const { found } = await findActionButton(page, { click: true });`
+- **`navigateTo(page, url, options)`** — robust navigation with retries and CI-tuned timeouts.
+- **`setupTest({ authenticate: true }) / teardownTest(ctx)`** — launches a browser, optionally authenticates via `auth_helper.js` (uses the CI test user when `CI=true`, registers a fresh user otherwise), and returns a context with `page`, `browser`, and config.
+- **`TestResults(suiteName)`** — collector with `.run(group, name, fn)`, `.skip(...)`, `.print()`, `.save()` (writes JSON + JUnit XML to `test-results/`).
+
+Prefer asserting **browser-level contracts** (HTML5 `:invalid`, navigation target, computed style) over heuristic scraping for `.error` / `.invalid-feedback` classes — heuristic selectors mask regressions when app markup drifts.
+
## Adding New Page Tests
To test a new page, add an entry to the `testCases` array in `test_pages_browser.js`: