Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

159 lines
5.5 KiB
JavaScript

const puppeteer = require('puppeteer');
const { browserConfig } = require('./browser_config');
const AuthHelper = require('./auth_helper');
const { CI_TEST_USER } = require('./auth_helper');
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
const isCI = !!process.env.CI;
async function submitResearchBatch(page, queries) {
// Submit all researches as quickly as possible
const results = [];
for (let i = 0; i < queries.length; i++) {
const query = queries[i];
console.log(`\nSubmitting research ${i + 1}: "${query}"`);
// Go to home page
await page.goto('http://127.0.0.1:5000/', { waitUntil: 'domcontentloaded' });
// Fill and submit form quickly
await page.waitForSelector('#query', { timeout: 5000 });
await page.type('#query', query);
// Select the model that's actually installed
try {
// First try to find the model dropdown by different possible selectors
const modelSelector = await page.evaluateHandle(() => {
// Try different selectors
return document.querySelector('#model-select') ||
document.querySelector('#model') ||
document.querySelector('[name="model"]') ||
document.querySelector('select[name="model"]');
});
if (modelSelector && modelSelector.asElement()) {
console.log('Found model selector, selecting llama3.1:8b');
await page.evaluate(() => {
const selector = document.querySelector('#model-select') ||
document.querySelector('#model') ||
document.querySelector('[name="model"]') ||
document.querySelector('select[name="model"]');
if (selector) {
selector.value = 'llama3.1:8b';
// Trigger change event
selector.dispatchEvent(new Event('change', { bubbles: true }));
}
});
} else {
console.log('No model selector found');
}
} catch (e) {
console.log('Error selecting model:', e.message);
}
// Intercept the response
const responsePromise = new Promise((resolve) => {
const handler = async (response) => {
if (response.url().includes('/api/start_research') && response.status() === 200) {
try {
const data = await response.json();
page.off('response', handler);
resolve(data);
} catch {
resolve(null);
}
}
};
page.on('response', handler);
// Timeout after 3 seconds
setTimeout(() => {
page.off('response', handler);
resolve({ timeout: true });
}, 3000);
});
// Submit
await page.click('button[type="submit"]');
// Wait for response
const response = await responsePromise;
if (response && !response.timeout) {
results.push({
query,
...response
});
console.log(`Response: ${JSON.stringify(response)}`);
} else {
console.log(`Failed to get response for research ${i + 1}`);
}
// Very short delay between submissions
await new Promise(resolve => setTimeout(resolve, 100));
}
return results;
}
(async () => {
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
const page = await browser.newPage();
let testPassed = false;
try {
// Authenticate (tries CI user first, falls back to registration)
const auth = new AuthHelper(page);
console.log('1. Authenticating...');
await auth.ensureAuthenticatedWithTimeout();
console.log('\n2. Testing concurrent research limit...\n');
// Submit 5 researches quickly
const queries = [
'First research about AI',
'Second research about Python',
'Third research about databases',
'Fourth research should be queued',
'Fifth research should be queued'
];
const results = await submitResearchBatch(page, queries);
// Analyze results
console.log('\n3. Results Summary:');
console.log('===================');
let started = 0;
let queued = 0;
results.forEach((result, index) => {
if (result.status === 'success') {
started++;
console.log(`Research ${index + 1}: STARTED (ID: ${result.research_id})`);
} else if (result.status === 'queued') {
queued++;
console.log(`Research ${index + 1}: QUEUED (ID: ${result.research_id}, Position: ${result.queue_position})`);
}
});
console.log(`\nTotal Started: ${started}`);
console.log(`Total Queued: ${queued}`);
if (started === 3 && queued === 2) {
console.log('\n✅ SUCCESS: Concurrent limit working correctly!');
testPassed = true;
} else {
console.log('\n❌ FAILURE: Expected 3 started and 2 queued');
}
} catch (error) {
console.error('Test failed:', error);
} finally {
await browser.close();
process.exit(testPassed ? 0 : 1);
}
})();