7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
127 lines
4.2 KiB
JavaScript
127 lines
4.2 KiB
JavaScript
/**
|
|
* Test research with specific search engine (searxng)
|
|
*/
|
|
|
|
const puppeteer = require('puppeteer');
|
|
const AuthHelper = require('./auth_helper');
|
|
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
|
|
|
|
const BASE_URL = 'http://127.0.0.1:5000';
|
|
const RESEARCH_QUESTION = 'What is the capital of France?';
|
|
|
|
async function testResearchWithSearxng() {
|
|
console.log('🔬 Testing Research with Searxng\n');
|
|
|
|
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
|
|
|
|
const page = await browser.newPage();
|
|
const authHelper = new AuthHelper(page, BASE_URL);
|
|
|
|
// Log console messages
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error' || msg.type() === 'warning') {
|
|
console.log(`📝 [${msg.type().toUpperCase()}] ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
// Log requests
|
|
page.on('request', request => {
|
|
if (request.url().includes('/api/start_research')) {
|
|
console.log(`→ REQUEST: ${request.method()} ${request.url()}`);
|
|
console.log(` Body: ${request.postData()}`);
|
|
}
|
|
});
|
|
|
|
page.on('response', response => {
|
|
if (response.url().includes('/api/start_research')) {
|
|
console.log(`← RESPONSE: ${response.status()} ${response.url()}`);
|
|
}
|
|
});
|
|
|
|
try {
|
|
// Login
|
|
console.log('🔐 Logging in...');
|
|
await authHelper.ensureAuthenticated();
|
|
console.log('✅ Logged in\n');
|
|
|
|
// Navigate to home
|
|
await page.goto(BASE_URL, { waitUntil: 'domcontentloaded' });
|
|
|
|
// Fill form
|
|
console.log('📝 Filling research form...');
|
|
await page.type('#query', RESEARCH_QUESTION);
|
|
|
|
// Wait for models to load
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
|
|
// Select searxng as search engine
|
|
console.log('🔍 Selecting searxng search engine...');
|
|
|
|
// Try to find and select searxng
|
|
const searchEngineSet = await page.evaluate(() => {
|
|
const select = document.querySelector('#search_engine');
|
|
if (select) {
|
|
// Try regular select
|
|
for (const option of select.options) {
|
|
if (option.value === 'searxng' || option.text.toLowerCase().includes('searxng')) {
|
|
select.value = option.value;
|
|
select.dispatchEvent(new Event('change'));
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Try custom dropdown
|
|
const hiddenInput = document.querySelector('#search_engine_hidden');
|
|
if (hiddenInput) {
|
|
hiddenInput.value = 'searxng';
|
|
hiddenInput.dispatchEvent(new Event('change'));
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
if (!searchEngineSet) {
|
|
console.log('⚠️ Could not set search engine to searxng');
|
|
} else {
|
|
console.log('✅ Search engine set to searxng');
|
|
}
|
|
|
|
// Submit research
|
|
console.log('\n📤 Submitting research...');
|
|
await Promise.all([
|
|
page.waitForResponse(response =>
|
|
response.url().includes('/api/start_research'),
|
|
{ timeout: 10000 }
|
|
),
|
|
page.click('#submit-research')
|
|
]);
|
|
|
|
// Wait a bit for research to start
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
|
|
// Get research ID from URL or response
|
|
const currentUrl = page.url();
|
|
const researchIdMatch = currentUrl.match(/progress\/([a-f0-9-]+)/);
|
|
|
|
if (researchIdMatch) {
|
|
const researchId = researchIdMatch[1];
|
|
console.log(`\n✅ Research started with ID: ${researchId}`);
|
|
|
|
// Check server logs will show search engine usage
|
|
console.log('\n📋 Check server logs for search engine usage:');
|
|
console.log(' tail -100 /tmp/ldr_server.log | grep -i searxng');
|
|
} else {
|
|
console.log('\n⚠️ Could not extract research ID from URL');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error:', error.message);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
testResearchWithSearxng().catch(console.error);
|