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

93 lines
3.3 KiB
JavaScript

/**
* Metrics Charts UI Test
*
* Tests the metrics dashboard to ensure both token consumption and search activity
* charts are rendering correctly using Chart.js. Validates canvas elements and
* takes screenshots for visual verification.
*
* Prerequisites: Web server running on http://127.0.0.1:5000
*
* Usage: node tests/ui_tests/test_metrics_charts.js
*/
const puppeteer = require('puppeteer');
const AuthHelper = require('./auth_helper');
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
async function testChartsScroll() {
const isCI = !!process.env.CI;
console.log(`📊 Testing charts with scrolling (CI mode: ${isCI})...`);
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);
await page.setViewport({ width: 1400, height: 900 });
let failed = false;
try {
// Login first
await authHelper.ensureAuthenticatedWithTimeout();
console.log('✅ Logged in');
await page.goto(`${baseUrl}/metrics/`, {
waitUntil: 'domcontentloaded',
timeout: 10000
});
// Wait for metrics to load
await new Promise(resolve => setTimeout(resolve, 6000));
// Scroll to the charts section
await page.evaluate(() => {
const chartsSection = document.querySelector('.chart-container');
if (chartsSection) {
chartsSection.scrollIntoView({ behavior: 'smooth', block: 'center' });
} else {
// Fallback: scroll to middle of page
window.scrollTo(0, document.body.scrollHeight / 2);
}
});
// Wait for scroll to complete
await new Promise(resolve => setTimeout(resolve, 2000));
// Take screenshot of charts area (skip in CI — diagnostic only)
if (!isCI) {
await page.screenshot({ path: 'charts_scroll_test.png', fullPage: false });
console.log('📸 Charts screenshot saved as charts_scroll_test.png');
}
// Check if both charts have content
const chartContent = await page.evaluate(() => {
const tokenChart = document.getElementById('time-series-chart');
const searchChart = document.getElementById('search-activity-chart');
return {
tokenChartExists: !!tokenChart,
searchChartExists: !!searchChart,
// Check if canvas has been drawn on (Chart.js renders to canvas)
tokenChartCanvas: tokenChart ? tokenChart.tagName === 'CANVAS' : false,
searchChartCanvas: searchChart ? searchChart.tagName === 'CANVAS' : false
};
});
console.log('📊 Chart Canvas Check:');
console.log(` Token chart canvas: ${chartContent.tokenChartCanvas}`);
console.log(` Search chart canvas: ${chartContent.searchChartCanvas}`);
console.log('🎉 Chart scroll test completed!');
} catch (error) {
console.log(`❌ Test failed: ${error.message}`);
failed = true;
} finally {
await browser.close();
process.exit(failed ? 1 : 0);
}
}
testChartsScroll().catch(err => { console.error(err); process.exit(1); });