~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(ui-tests): match create/new/add buttons with word boundaries (#4069)
LearningCircuit1c33f1dc0757
diff --git a/tests/ui_tests/test_crud_operations_ci.js b/tests/ui_tests/test_crud_operations_ci.jsindex 59cff591fc..34e4215938 100644--- a/tests/ui_tests/test_crud_operations_ci.js+++ b/tests/ui_tests/test_crud_operations_ci.js@@ -7,7 +7,7 @@* Run: node test_crud_operations_ci.js*/-const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout } = require('./test_lib');+const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout, findActionButton } = require('./test_lib');// ============================================================================// Collection CRUD Tests@@ -16,22 +16,8 @@ const CollectionCrudTests = {async createCollectionFormOpens(page, baseUrl) {await navigateTo(page, `${baseUrl}/collections`);- // Find and click create button- const clicked = await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });-- if (createBtn) {- createBtn.click();- return true;- }- return false;- });-- if (!clicked) {+ const { found } = await findActionButton(page, { click: true });+ if (!found) {return { passed: null, skipped: true, message: 'No create collection button found' };}@@ -61,16 +47,7 @@ const CollectionCrudTests = {async createCollectionFormValidation(page, baseUrl) {await navigateTo(page, `${baseUrl}/collections`);- // Click create button- await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });- if (createBtn) createBtn.click();- });-+ await findActionButton(page, { click: true });await delay(500);// Try to submit empty form@@ -205,22 +182,8 @@ const SubscriptionCrudTests = {async createSubscriptionFormOpens(page, baseUrl) {await navigateTo(page, `${baseUrl}/news/subscriptions`);- // Find and click create button- const clicked = await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add') || text.includes('subscribe');- });-- if (createBtn) {- createBtn.click();- return true;- }- return false;- });-- if (!clicked) {+ const { found } = await findActionButton(page, { click: true });+ if (!found) {return { passed: null, skipped: true, message: 'No create subscription button found' };}@@ -250,16 +213,7 @@ const SubscriptionCrudTests = {async subscriptionFormValidation(page, baseUrl) {await navigateTo(page, `${baseUrl}/news/subscriptions`);- // Click create button- await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });- if (createBtn) createBtn.click();- });-+ await findActionButton(page, { click: true });await delay(500);// Try to submit empty form@@ -293,16 +247,7 @@ const SubscriptionCrudTests = {async subscriptionFrequencyOptions(page, baseUrl) {await navigateTo(page, `${baseUrl}/news/subscriptions`);- // Open create form first- await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });- if (createBtn) createBtn.click();- });-+ await findActionButton(page, { click: true });await delay(500);const result = await page.evaluate(() => {@@ -335,16 +280,7 @@ const SubscriptionCrudTests = {async subscriptionTypeOptions(page, baseUrl) {await navigateTo(page, `${baseUrl}/news/subscriptions`);- // Open create form first- await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });- if (createBtn) createBtn.click();- });-+ await findActionButton(page, { click: true });await delay(500);const result = await page.evaluate(() => {diff --git a/tests/ui_tests/test_lib/index.js b/tests/ui_tests/test_lib/index.jsindex 41ff543231..91cbd87d16 100644--- a/tests/ui_tests/test_lib/index.js+++ b/tests/ui_tests/test_lib/index.js@@ -47,6 +47,7 @@ const {clickAndWaitForNavigation,getInputValue,clearAndType,+ findActionButton,log,} = require('./test_utils');@@ -71,6 +72,7 @@ module.exports = {clickAndWaitForNavigation,getInputValue,clearAndType,+ findActionButton,// Logginglog,diff --git a/tests/ui_tests/test_lib/test_utils.js b/tests/ui_tests/test_lib/test_utils.jsindex 05963cad69..4a588f4327 100644--- a/tests/ui_tests/test_lib/test_utils.js+++ b/tests/ui_tests/test_lib/test_utils.js@@ -290,6 +290,41 @@ async function clearAndType(page, selector, text) {await page.type(selector, text);}+/**+ * Find an action button on the current page by word-boundary keyword match+ * against its text content, and optionally click it.+ *+ * Word boundaries (`\b`) keep the match from firing on substrings — e.g.+ * the default keyword `new` matches "New Folder" but NOT "Back to News+ * Feed" (where "news" merely contains "new"). The original substring+ * matcher caused #4069.+ *+ * @param {import('puppeteer').Page} page+ * @param {Object} [options]+ * @param {string} [options.selectors] CSS selector list to scan.+ * Default: `'button, a.btn, .btn'`.+ * @param {string[]} [options.keywords] Lowercase words to match (combined+ * into `\b(?:k1|k2|...)\b`). Default: `['create', 'new', 'add']`.+ * @param {boolean} [options.click] If true, click the first match.+ * @returns {Promise<{found: boolean, text?: string}>}+ */+async function findActionButton(page, options = {}) {+ const {+ selectors = 'button, a.btn, .btn',+ keywords = ['create', 'new', 'add'],+ click = false,+ } = options;++ return await page.evaluate((selectorsStr, keywordsArr, doClick) => {+ const pattern = new RegExp(`\\b(?:${keywordsArr.join('|')})\\b`);+ const buttons = Array.from(document.querySelectorAll(selectorsStr));+ const match = buttons.find(b => pattern.test((b.textContent || '').toLowerCase()));+ if (!match) return { found: false };+ if (doClick) match.click();+ return { found: true, text: match.textContent?.trim() };+ }, selectors, keywords, click);+}+// Console logging with colors (works in terminal)const log = {info: (msg) => console.log(`\x1b[36m[INFO] ${msg}\x1b[0m`),@@ -318,5 +353,6 @@ module.exports = {clickAndWaitForNavigation,getInputValue,clearAndType,+ findActionButton,log,};diff --git a/tests/ui_tests/test_library_collections_ci.js b/tests/ui_tests/test_library_collections_ci.jsindex d935bd3871..b8735591e5 100644--- a/tests/ui_tests/test_library_collections_ci.js+++ b/tests/ui_tests/test_library_collections_ci.js@@ -6,7 +6,7 @@** Run: node test_library_collections_ci.js*/-const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout } = require('./test_lib');+const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout, findActionButton } = require('./test_lib');// ============================================================================// Library Page Tests@@ -183,24 +183,12 @@ const CollectionsPageTests = {async createCollectionButton(page, baseUrl) {await navigateTo(page, `${baseUrl}/library/collections`);- const result = await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b =>- b.textContent?.toLowerCase().includes('create') ||- b.textContent?.toLowerCase().includes('new') ||- b.textContent?.toLowerCase().includes('add')- );-- return {- hasCreateButton: !!createBtn,- buttonText: createBtn?.textContent?.trim()- };- });+ const { found, text } = await findActionButton(page);return {- passed: result.hasCreateButton,- message: result.hasCreateButton- ? `Create collection button found ("${result.buttonText}")`+ passed: found,+ message: found+ ? `Create collection button found ("${text}")`: 'No create collection button found'};},diff --git a/tests/ui_tests/test_mobile_interactions_ci.js b/tests/ui_tests/test_mobile_interactions_ci.jsindex 3b3dae7958..cde920c35d 100644--- a/tests/ui_tests/test_mobile_interactions_ci.js+++ b/tests/ui_tests/test_mobile_interactions_ci.js@@ -6,7 +6,7 @@** Run: node test_mobile_interactions_ci.js*/-const { setupTest, teardownTest, TestResults, log, delay, viewports, navigateTo, withTimeout } = require('./test_lib');+const { setupTest, teardownTest, TestResults, log, delay, viewports, navigateTo, withTimeout, findActionButton } = require('./test_lib');// ============================================================================// Mobile Modal Tests@@ -17,22 +17,8 @@ const MobileModalTests = {await page.setViewport({ width: 375, height: 667, isMobile: true, hasTouch: true });await navigateTo(page, `${baseUrl}/collections`);- // Find a button that opens a modal- const result = await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const modalTrigger = buttons.find(b => {- const text = b.textContent?.toLowerCase() || '';- return text.includes('create') || text.includes('new') || text.includes('add');- });-- if (modalTrigger) {- modalTrigger.click();- return { clicked: true };- }- return { clicked: false };- });-- if (!result.clicked) {+ const { found } = await findActionButton(page, { click: true });+ if (!found) {return { passed: null, skipped: true, message: 'No modal trigger button found' };}diff --git a/tests/ui_tests/test_news_subscriptions_ci.js b/tests/ui_tests/test_news_subscriptions_ci.jsindex 922a1e4831..961b9cef65 100644--- a/tests/ui_tests/test_news_subscriptions_ci.js+++ b/tests/ui_tests/test_news_subscriptions_ci.js@@ -7,7 +7,7 @@* Run: node test_news_subscriptions_ci.js*/-const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout } = require('./test_lib');+const { setupTest, teardownTest, TestResults, log, delay, navigateTo, withTimeout, findActionButton } = require('./test_lib');// ============================================================================// News Feed Page Tests@@ -244,24 +244,12 @@ const SubscriptionsPageTests = {async createSubscriptionButton(page, baseUrl) {await navigateTo(page, `${baseUrl}/news/subscriptions`);- const result = await page.evaluate(() => {- const buttons = Array.from(document.querySelectorAll('button, a.btn, .btn'));- const createBtn = buttons.find(b =>- b.textContent?.toLowerCase().includes('create') ||- b.textContent?.toLowerCase().includes('new') ||- b.textContent?.toLowerCase().includes('add')- );-- return {- hasCreateButton: !!createBtn,- buttonText: createBtn?.textContent?.trim()- };- });+ const { found, text } = await findActionButton(page);return {- passed: result.hasCreateButton,- message: result.hasCreateButton- ? `Create subscription button found ("${result.buttonText}")`+ passed: found,+ message: found+ ? `Create subscription button found ("${text}")`: 'No create subscription button found'};},