Files
wehub-resource-sync 7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
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
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

194 lines
7.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Simple Research Test
* Minimal test to check if research can start
*/
const puppeteer = require('puppeteer');
const AuthHelper = require('./auth_helper');
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
const { setupDefaultModel } = require('./model_helper');
// NAVIGATION NOTE: Using 'domcontentloaded' instead of 'networkidle2' for page.goto()
// because networkidle2 waits for no network activity for 500ms, but WebSocket
// connections and background polling keep the network active, causing infinite hangs.
// See: test_login_validation.js and auth_helper.js for detailed explanation.
async function testSimpleResearch() {
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
const page = await browser.newPage();
const baseUrl = 'http://127.0.0.1:5000';
const authHelper = new AuthHelper(page, baseUrl);
let testPassed = false;
console.log('🔬 Simple Research Test\n');
// Monitor key API calls
page.on('response', async response => {
if (response.url().includes('/api/start_research') ||
response.url().includes('/research/start')) {
console.log(`\n📥 Research API Response:`);
console.log(` URL: ${response.url()}`);
console.log(` Status: ${response.status()} ${response.statusText()}`);
try {
const body = await response.text();
console.log(` Body: ${body.substring(0, 200)}...`);
} catch {
console.log(` Body: <unable to read>`);
}
}
});
try {
// Login
console.log('🔐 Logging in...');
await authHelper.ensureAuthenticatedWithTimeout();
console.log('✅ Logged in\n');
// Go to home
await page.goto(baseUrl, {
waitUntil: 'domcontentloaded',
timeout: 30000
});
// Check if we can find the form
console.log('📋 Checking form elements...');
const formCheck = await page.evaluate(() => {
return {
query: !!document.querySelector('#query'),
submit: !!document.querySelector('button[type="submit"]'),
form: !!document.querySelector('#research-form, form'),
provider: document.querySelector('#model_provider')?.value || 'not found',
model: document.querySelector('#model, input[name="model"]')?.value || 'not found'
};
});
console.log('Form elements found:');
console.log(` Query input: ${formCheck.query ? '✅' : '❌'}`);
console.log(` Submit button: ${formCheck.submit ? '✅' : '❌'}`);
console.log(` Form: ${formCheck.form ? '✅' : '❌'}`);
console.log(` Provider: ${formCheck.provider}`);
console.log(` Model: ${formCheck.model}`);
if (!formCheck.query || !formCheck.submit) {
throw new Error('Essential form elements not found');
}
// Set up model configuration before submitting
console.log('\n🔧 Configuring model...');
const modelConfigured = await setupDefaultModel(page);
if (!modelConfigured) {
throw new Error('Failed to configure model');
}
// Fill and submit
console.log('\n📝 Submitting research...');
await page.type('#query', 'What is 2+2?');
// Try different ways to submit - look for submit button within the form first
console.log('Looking for submit button...');
// First try to find submit button within the form specifically
const submitButton = await page.evaluate(() => {
const form = document.querySelector('#research-form, form');
if (form) {
const btn = form.querySelector('button[type="submit"], #start-research-btn, button:not([type="button"])');
if (btn) {
btn.click();
return true;
}
}
// Fallback: try any submit button on the page
const anySubmit = document.querySelector('#start-research-btn') ||
document.querySelector('button[type="submit"]') ||
Array.from(document.querySelectorAll('button')).find(b =>
b.textContent.includes('Start Research') ||
b.textContent.includes('Submit'));
if (anySubmit) {
anySubmit.click();
return true;
}
return false;
});
if (submitButton) {
console.log('✅ Submit button clicked');
// Wait for response or navigation
await Promise.race([
page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 10000 }).catch(() => null),
page.waitForResponse(response =>
response.url().includes('research') || response.url().includes('api'),
{ timeout: 10000 }
).catch(() => null),
new Promise(resolve => setTimeout(resolve, 5000))
]);
console.log('Navigation or response received');
} else {
console.log('❌ Submit button not found, trying Enter key...');
await page.focus('#query');
await page.keyboard.press('Enter');
await new Promise(resolve => setTimeout(resolve, 3000));
}
// Wait a bit more
await new Promise(resolve => setTimeout(resolve, 3000));
// Check final state
const finalState = await page.evaluate(() => {
const alerts = Array.from(document.querySelectorAll('.alert')).map(a => ({
type: a.className.includes('danger') ? 'error' :
a.className.includes('success') ? 'success' : 'info',
text: a.textContent.trim()
}));
return {
url: window.location.href,
alerts,
queryValue: document.querySelector('#query')?.value || ''
};
});
console.log('\n📊 Final state:');
console.log(` URL: ${finalState.url}`);
console.log(` Query still in input: ${finalState.queryValue ? 'Yes' : 'No'}`);
if (finalState.alerts.length > 0) {
console.log(` Alerts:`);
finalState.alerts.forEach(alert => {
const icon = alert.type === 'error' ? '❌' :
alert.type === 'success' ? '✅' : '️';
console.log(` ${icon} ${alert.text}`);
});
}
// Check if we were redirected to a research page
if (finalState.url.includes('/research/') || finalState.url.includes('/progress')) {
console.log('\n✅ Research started successfully!');
console.log(` Research ID: ${finalState.url.split('/').pop()}`);
testPassed = true;
} else if (finalState.alerts.some(a => a.type === 'error')) {
console.log('\n❌ Research failed to start - error shown');
} else {
console.log('\n⚠️ Research status unclear - still on home page');
}
} catch (error) {
console.error('\n❌ Test error:', error.message);
}
await browser.close();
console.log('\n🏁 Test completed');
process.exit(testPassed ? 0 : 1);
}
// Run the test
testSimpleResearch().catch(error => {
console.error('Fatal error:', error);
process.exit(1);
});