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
164 lines
5.9 KiB
JavaScript
164 lines
5.9 KiB
JavaScript
const puppeteer = require('puppeteer');
|
|
const AuthHelper = require('./auth_helper');
|
|
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
|
|
|
|
(async () => {
|
|
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);
|
|
|
|
// Monitor console errors
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') {
|
|
console.log(` Browser error: ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
// Monitor network
|
|
page.on('response', async (response) => {
|
|
if (response.url().includes('/metrics/api/cost-analytics')) {
|
|
console.log(`API Response: ${response.status()}`);
|
|
try {
|
|
const text = await response.text();
|
|
console.log('API Data:', text.substring(0, 200));
|
|
} catch {}
|
|
}
|
|
});
|
|
|
|
try {
|
|
// Authenticate first
|
|
console.log('🔐 Ensuring authentication...');
|
|
await authHelper.ensureAuthenticated();
|
|
|
|
console.log('Loading page...');
|
|
// Clear cache and reload
|
|
await page.setCacheEnabled(false);
|
|
await page.goto('http://localhost:5000/metrics/costs?' + Date.now(), {
|
|
waitUntil: 'domcontentloaded',
|
|
timeout: 15000
|
|
});
|
|
|
|
// Wait for initial load
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
|
|
// Check loading state
|
|
const states = await page.evaluate(() => {
|
|
const loading = document.getElementById('loading');
|
|
const error = document.getElementById('error');
|
|
const content = document.getElementById('cost-content');
|
|
const noData = document.getElementById('no-data');
|
|
|
|
return {
|
|
loading: loading ? loading.style.display : 'not found',
|
|
error: error ? error.style.display : 'not found',
|
|
content: content ? content.style.display : 'not found',
|
|
noData: noData ? noData.style.display : 'not found'
|
|
};
|
|
});
|
|
|
|
console.log('Element states:', states);
|
|
|
|
// Try manual API call and simulate the loadCostData function
|
|
const apiTest = await page.evaluate(async () => {
|
|
try {
|
|
console.log('Starting manual API test...');
|
|
const response = await fetch('/metrics/api/cost-analytics?period=7d');
|
|
const data = await response.json();
|
|
console.log('API Response received:', data.status);
|
|
console.log('Total calls:', data.overview?.total_calls);
|
|
console.log('Total cost:', data.overview?.total_cost);
|
|
|
|
// Now simulate what the loadCostData function should do
|
|
if (data.status === 'success') {
|
|
console.log('Status is success');
|
|
if (data.overview.total_calls > 0) {
|
|
console.log('Total calls > 0, should show content');
|
|
|
|
// Try to manually call the show functions
|
|
function showContent() {
|
|
document.getElementById('loading').style.display = 'none';
|
|
document.getElementById('cost-content').style.display = 'block';
|
|
document.getElementById('error').style.display = 'none';
|
|
document.getElementById('no-data').style.display = 'none';
|
|
}
|
|
|
|
showContent();
|
|
console.log('Called showContent() manually');
|
|
} else {
|
|
console.log('Total calls is 0, should show no data');
|
|
}
|
|
} else {
|
|
console.log('Status is not success:', data.status);
|
|
}
|
|
|
|
return { success: true, data };
|
|
} catch (error) {
|
|
console.error('Manual API test failed:', error);
|
|
return { success: false, error: error.message };
|
|
}
|
|
});
|
|
|
|
console.log('Manual API test:', apiTest.success ? 'SUCCESS' : 'FAILED');
|
|
if (apiTest.success) {
|
|
console.log('API returned cost:', apiTest.data.overview?.total_cost);
|
|
console.log('API returned calls:', apiTest.data.overview?.total_calls);
|
|
}
|
|
|
|
// Test the actual logic from the page
|
|
const testLogic = await page.evaluate(() => {
|
|
// Simulate what the loadCostData function does
|
|
const testData = {
|
|
status: 'success',
|
|
overview: {
|
|
total_cost: 0.0,
|
|
total_calls: 58
|
|
}
|
|
};
|
|
|
|
console.log('Testing logic: total_calls =', testData.overview.total_calls);
|
|
console.log('Testing logic: total_cost =', testData.overview.total_cost);
|
|
|
|
if (testData.status === 'success') {
|
|
if (testData.overview.total_calls > 0) {
|
|
console.log('Should show content!');
|
|
return 'should_show_content';
|
|
}
|
|
console.log('Should show no data');
|
|
return 'should_show_no_data';
|
|
}
|
|
return 'unknown';
|
|
});
|
|
|
|
console.log('Logic test result:', testLogic);
|
|
|
|
// Wait a bit more
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
|
|
// Check final states after manual showContent
|
|
const finalStates = await page.evaluate(() => {
|
|
const loading = document.getElementById('loading');
|
|
const error = document.getElementById('error');
|
|
const content = document.getElementById('cost-content');
|
|
const noData = document.getElementById('no-data');
|
|
|
|
return {
|
|
loading: loading ? loading.style.display : 'not found',
|
|
error: error ? error.style.display : 'not found',
|
|
content: content ? content.style.display : 'not found',
|
|
noData: noData ? noData.style.display : 'not found'
|
|
};
|
|
});
|
|
|
|
console.log('Final element states:', finalStates);
|
|
|
|
console.log('✅ Done');
|
|
} catch (error) {
|
|
console.error('❌ Test failed:', error.message);
|
|
process.exitCode = 1;
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
})();
|