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

113 lines
3.3 KiB
JavaScript

/**
* Model Helper
* Utility functions for selecting models in tests
*/
/**
* Select a model in the custom dropdown
* @param {Page} page - Puppeteer page object
* @param {string} modelValue - The model value to select (e.g., 'llama3.2:3b')
* @returns {Promise<boolean>} - True if successful
*/
async function selectModel(page, modelValue) {
try {
// Set the model value directly in both inputs
const success = await page.evaluate((model) => {
// Set the visible input (for display)
const modelInput = document.querySelector('#model');
if (!modelInput) {
console.error('Model input not found');
return false;
}
modelInput.value = model;
// More importantly, set the hidden input that gets submitted
const hiddenInput = document.querySelector('#model_hidden');
if (!hiddenInput) {
console.error('Hidden model input not found');
return false;
}
hiddenInput.value = model;
// Trigger change event on hidden input
hiddenInput.dispatchEvent(new Event('change', { bubbles: true }));
console.log(`Model set to: ${model}`);
return true;
}, modelValue);
return success;
} catch (error) {
console.error('Error selecting model:', error);
return false;
}
}
/**
* Select a model provider
* @param {Page} page - Puppeteer page object
* @param {string} provider - The provider to select (e.g., 'OLLAMA', 'OPENAI')
* @returns {Promise<boolean>} - True if successful
*/
async function selectProvider(page, provider) {
try {
const providerSelect = await page.$('#model_provider');
if (!providerSelect) {
console.error('Provider select not found');
return false;
}
await page.select('#model_provider', provider);
console.log(`Provider set to: ${provider}`);
return true;
} catch (error) {
console.error('Error selecting provider:', error);
return false;
}
}
/**
* Set up a research with a default working model configuration
* @param {Page} page - Puppeteer page object
* @param {Object} options - Configuration options
* @returns {Promise<boolean>} - True if successful
*/
async function setupDefaultModel(page, options = {}) {
const defaults = {
provider: 'OLLAMA',
model: 'llama3.2:3b',
...options
};
// Wait for DOM to be hydrated before interacting
try {
await page.waitForSelector('#model_provider', { timeout: 5000 });
} catch {
console.error('model_helper: #model_provider not found within 5s');
return false;
}
// Select provider
const providerSet = await selectProvider(page, defaults.provider);
if (!providerSet) {
console.error('Failed to set provider');
return false;
}
// Select model
const modelSet = await selectModel(page, defaults.model);
if (!modelSet) {
console.error('Failed to set model');
return false;
}
console.log(`✅ Model configuration set: ${defaults.provider}/${defaults.model}`);
return true;
}
module.exports = {
selectModel,
selectProvider,
setupDefaultModel
};