Polish explorer frontend validation and utility pages

This commit is contained in:
defiQUG
2026-03-28 13:26:42 -07:00
parent 59eee21a3f
commit 1e3a3f00ef
7 changed files with 201 additions and 5 deletions

View File

@@ -0,0 +1,64 @@
const baseUrl = (process.env.BASE_URL || 'http://127.0.0.1:3000').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: '/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: '/transactions/0x0000000000000000000000000000000000000000000000000000000000000000',
expect: ['Loading transaction details', 'Transaction Details', 'Transaction not found'],
},
{
path: '/addresses/0x0000000000000000000000000000000000000000',
expect: ['Loading address details', 'Address Details', 'Open An Address'],
},
]
function hasExpectedBody(text, expectedSnippets) {
return expectedSnippets.some((snippet) => text.includes(snippet))
}
async function run() {
let failures = 0
for (const check of checks) {
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
}
if (!hasExpectedBody(body, check.expect)) {
console.error(`FAIL ${check.path}: expected one of ${check.expect.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
}
}
if (failures > 0) {
process.exitCode = 1
return
}
console.log(`All ${checks.length} route checks passed for ${baseUrl}`)
}
run()