Prune explorer dead ends and harden route smoke
This commit is contained in:
@@ -1,65 +1,96 @@
|
||||
const baseUrl = (process.env.BASE_URL || 'http://127.0.0.1:3000').replace(/\/$/, '')
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const baseUrl = (process.env.BASE_URL || 'https://explorer.d-bis.org').replace(/\/$/, '');
|
||||
|
||||
const checks = [
|
||||
{ path: '/', expect: ['/addresses', '/transactions', '/watchlist', '/pools'] },
|
||||
{ path: '/blocks', expect: ['Latest Blocks', 'View blockchain blocks', 'Blocks'] },
|
||||
{ path: '/transactions', expect: ['Latest Transactions', 'Recent Transactions', 'Transactions'] },
|
||||
{ path: '/addresses', expect: ['Open An Address', 'Recently Active Addresses', 'Saved Watchlist'] },
|
||||
{ path: '/tokens', expect: ['Find A Token', 'Common token searches', 'Tokens'] },
|
||||
{ path: '/pools', expect: ['Canonical PMM routes', 'Pool operation shortcuts', 'Pools'] },
|
||||
{ path: '/routes', expect: ['Live Route Decision Tree', 'Coverage sweep + priority route cards', 'Routes'] },
|
||||
{ path: '/watchlist', expect: ['Saved Addresses', 'Watchlist', 'Export JSON'] },
|
||||
{ path: '/search?q=cUSDT', expect: ['Search Results', 'Results for', 'Search'] },
|
||||
{ path: '/blocks/1', expect: ['Loading block details', 'Block Details'] },
|
||||
{ path: '/', homeVisible: true, expectTexts: ['Gas & Network', 'Latest Blocks', 'Latest Transactions'] },
|
||||
{ path: '/blocks', activeView: 'blocksView', expectTexts: ['All Blocks'] },
|
||||
{ path: '/transactions', activeView: 'transactionsView', expectTexts: ['All Transactions'] },
|
||||
{ path: '/addresses', activeView: 'addressesView', expectTexts: ['All Addresses'] },
|
||||
{ path: '/tokens', activeView: 'tokensView', expectTexts: ['Tokens'] },
|
||||
{ path: '/pools', activeView: 'poolsView', expectTexts: ['Pools', 'Canonical PMM routes'] },
|
||||
{ path: '/routes', activeView: 'routesView', expectTexts: ['Routes', 'Live Route Decision Tree'] },
|
||||
{ path: '/watchlist', activeView: 'watchlistView', expectTexts: ['Watchlist'] },
|
||||
{ path: '/bridge', activeView: 'bridgeView', expectTexts: ['Bridge Monitoring'] },
|
||||
{ path: '/weth', activeView: 'wethView', expectTexts: ['WETH', 'Wrap ETH to WETH9'] },
|
||||
{ path: '/liquidity', activeView: 'liquidityView', expectTexts: ['Liquidity Access', 'Public Explorer Access Points'] },
|
||||
{ path: '/more', activeView: 'moreView', expectTexts: ['More', 'Tools & Services'] },
|
||||
{ path: '/analytics', activeView: 'analyticsView', expectTexts: ['Analytics Dashboard', 'Live Network Analytics'] },
|
||||
{ path: '/operator', activeView: 'operatorView', expectTexts: ['Operator Panel', 'Operator Access Hub'] },
|
||||
{ path: '/block/1', activeView: 'blockDetailView', expectTexts: ['Block Details'] },
|
||||
{
|
||||
path: '/transactions/0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
expect: ['Loading transaction details', 'Transaction Details', 'Transaction not found'],
|
||||
path: '/tx/0x0000000000000000000000000000000000000000000000000000000000000000',
|
||||
activeView: 'transactionDetailView',
|
||||
expectTexts: ['Transaction Details', 'Transaction not found'],
|
||||
},
|
||||
{
|
||||
path: '/addresses/0x0000000000000000000000000000000000000000',
|
||||
expect: ['Loading address details', 'Address Details', 'Open An Address'],
|
||||
path: '/address/0x93E66202A11B1772E55407B32B44e5Cd8eda7f22',
|
||||
activeView: 'addressDetailView',
|
||||
expectTexts: ['Address Details', 'Address'],
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
function hasExpectedBody(text, expectedSnippets) {
|
||||
return expectedSnippets.some((snippet) => text.includes(snippet))
|
||||
function hasExpectedText(text, snippets) {
|
||||
return snippets.some((snippet) => text.includes(snippet));
|
||||
}
|
||||
|
||||
async function run() {
|
||||
let failures = 0
|
||||
async function main() {
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage();
|
||||
let failures = 0;
|
||||
|
||||
for (const check of checks) {
|
||||
const url = `${baseUrl}${check.path}`
|
||||
const url = `${baseUrl}${check.path}`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url, { redirect: 'follow' })
|
||||
const body = await response.text()
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(`FAIL ${check.path}: HTTP ${response.status}`)
|
||||
failures += 1
|
||||
continue
|
||||
const response = await page.goto(url, { waitUntil: 'networkidle' });
|
||||
if (!response || !response.ok()) {
|
||||
console.error(`FAIL ${check.path}: HTTP ${response ? response.status() : 'no-response'}`);
|
||||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hasExpectedBody(body, check.expect)) {
|
||||
console.error(`FAIL ${check.path}: expected one of ${check.expect.join(' | ')}`)
|
||||
failures += 1
|
||||
continue
|
||||
const bodyText = await page.textContent('body');
|
||||
if (check.homeVisible) {
|
||||
const homeVisible = await page.$eval('#homeView', (el) => getComputedStyle(el).display !== 'none').catch(() => false);
|
||||
if (!homeVisible) {
|
||||
console.error(`FAIL ${check.path}: home view not visible`);
|
||||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
const activeView = await page.$eval('.detail-view.active', (el) => el.id).catch(() => null);
|
||||
if (activeView !== check.activeView) {
|
||||
console.error(`FAIL ${check.path}: expected active view ${check.activeView}, got ${activeView}`);
|
||||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`OK ${check.path}`)
|
||||
if (!hasExpectedText(bodyText || '', check.expectTexts)) {
|
||||
console.error(`FAIL ${check.path}: expected one of ${check.expectTexts.join(' | ')}`);
|
||||
failures += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`OK ${check.path}`);
|
||||
} catch (error) {
|
||||
console.error(`FAIL ${check.path}: ${error instanceof Error ? error.message : String(error)}`)
|
||||
failures += 1
|
||||
console.error(`FAIL ${check.path}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
failures += 1;
|
||||
}
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
|
||||
if (failures > 0) {
|
||||
process.exitCode = 1
|
||||
return
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`All ${checks.length} route checks passed for ${baseUrl}`)
|
||||
console.log(`All ${checks.length} route checks passed for ${baseUrl}`);
|
||||
}
|
||||
|
||||
run()
|
||||
main().catch((error) => {
|
||||
console.error(error instanceof Error ? error.stack || error.message : String(error));
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user