diff --git a/public/nodes.js b/public/nodes.js
index 947662ad..edf1ed1f 100644
--- a/public/nodes.js
+++ b/public/nodes.js
@@ -383,6 +383,9 @@
const sizes = Array.isArray(n.hash_sizes_seen) ? n.hash_sizes_seen : [];
value += ' varies';
}
+ if (size === 1 && n.role === 'repeater' && /^[0-9a-f]{64}$/i.test(key)) {
+ value += ' Inspect in Prefix Tool';
+ }
return renderNodeMetric('Hash Prefix', value, table);
}
diff --git a/tests/e2e/test-issue-1147-section-order-e2e.js b/tests/e2e/test-issue-1147-section-order-e2e.js
index 513db919..10a77eba 100644
--- a/tests/e2e/test-issue-1147-section-order-e2e.js
+++ b/tests/e2e/test-issue-1147-section-order-e2e.js
@@ -238,6 +238,116 @@ async function previewMetadata(browser) {
}
}
+// Partial #1154 U11: the node offers navigation, while the existing tool owns
+// the lookup and its visible, filtered repeater population.
+async function prefixToolNavigation(browser) {
+ const nodes = [
+ { public_key: 'ab00' + '11'.repeat(30), name: 'Selected repeater', role: 'repeater' },
+ { public_key: 'ab11' + '22'.repeat(30), name: 'Other repeater', role: 'repeater' },
+ { public_key: 'ab22' + '33'.repeat(30), name: 'Room fixture', role: 'room' },
+ { public_key: 'ab33' + '44'.repeat(30), name: 'Companion fixture', role: 'companion' },
+ { public_key: 'ab44' + '55'.repeat(30), name: 'Outside selected area', role: 'repeater' },
+ ].map(n => ({ hash_size: 1, advert_count: 1, first_seen: '2020-01-01T00:00:00Z', last_seen: '2020-01-02T00:00:00Z', ...n }));
+ const selected = nodes[0];
+ const destination = '#/analytics?tab=prefix-tool&prefix=' + selected.public_key;
+ const layouts = [
+ { name: 'full', width: 1400, root: '#node-stats', direct: true },
+ { name: 'side', width: 1400, root: '#nodesRight .detail-meta' },
+ { name: 'tablet', width: 800, root: '.slide-over-content dl' },
+ { name: 'mobile', width: 390, root: '#node-stats' },
+ { name: 'filtered', width: 1400, root: '#node-stats', direct: true, filtered: true },
+ ];
+ for (const theme of ['light', 'dark']) for (const layout of layouts) {
+ const ctx = await browser.newContext({ viewport: { width: layout.width, height: 1000 } });
+ await ctx.addInitScript(({ theme, filtered }) => {
+ localStorage.setItem('meshcore-theme', theme);
+ localStorage.setItem('meshcore-user-level', 'experienced');
+ if (filtered) {
+ localStorage.setItem('meshcore-region-filter', JSON.stringify(['TEST']));
+ localStorage.setItem('meshcore-area-filter', 'prefix-fixture');
+ }
+ // Observe the actual initial theme application and debounced refresh.
+ window.addEventListener('theme-refresh', () => { window.prefixThemeReady = true; }, { once: true });
+ }, { theme, filtered: !!layout.filtered });
+ const p = await ctx.newPage();
+ p.setDefaultTimeout(10000);
+ const errors = [], requests = [];
+ p.on('pageerror', e => errors.push(e.message));
+ p.on('console', m => { if (m.type() === 'error') errors.push(m.text() + ' ' + m.location().url); });
+ p.on('request', r => { const u = new URL(r.url()); if (u.pathname.startsWith('/api/')) requests.push(u); });
+ await p.route(/\/api\/nodes(?:\?.*)?$/, r => {
+ const q = new URL(r.request().url()).searchParams;
+ const visible = q.get('region') === 'TEST' && q.get('area') === 'prefix-fixture' ? nodes.slice(0, 4) : nodes;
+ return r.fulfill({ json: { nodes: visible, total: visible.length, has_more: false, counts: {} } });
+ });
+ await p.route(/\/api\/nodes\/[0-9a-f]{64}(?:\/[^?]*)?(?:\?.*)?$/, r => {
+ const parts = new URL(r.request().url()).pathname.split('/');
+ const n = nodes.find(n => n.public_key === parts[3]);
+ if (!n) return r.continue();
+ return r.fulfill({ json: !parts[4] ? { node: n, recentAdverts: [] }
+ : parts[4] === 'health' ? { node: n, stats: {}, observers: [], recentPackets: [] }
+ : parts[4] === 'neighbors' ? { neighbors: [] } : parts[4] === 'paths' ? { paths: [] } : {} });
+ });
+ await p.route('**/api/config/regions', r => r.fulfill({ json: { TEST: 'Test region' } }));
+ await p.route('**/api/config/areas', r => r.fulfill({ json: [{ key: 'prefix-fixture', label: 'Fixture area' }] }));
+ await p.route('**/api/config/region-quick-picks', r => r.fulfill({ json: { quickPicks: [] } }));
+ await p.route('**/api/nodes/reported', r => r.fulfill({ json: { nodes: [] } }));
+ await p.route('**/api/rf-params', r => r.fulfill({ json: { enabled: false } }));
+ await p.route(/\/api\/analytics\//, r => r.fulfill({ json: {} }));
+ try {
+ await step(`#1154 ${theme} ${layout.name}: inspect full key in Prefix Tool`, async () => {
+ await p.goto(BASE + '/#/nodes' + (layout.direct ? '/' + selected.public_key : ''), { waitUntil: 'domcontentloaded' });
+ await p.waitForFunction(() => window.prefixThemeReady && window._customizerV2.initDone && _themeRefreshTimer === null);
+ await p.evaluate(() => document.fonts.ready);
+ if (!layout.direct) {
+ requests.length = 0;
+ await p.locator('#nodesTable tbody tr[data-key="' + selected.public_key + '"] td:visible').first().click();
+ }
+ const root = p.locator(layout.root);
+ await root.waitFor();
+ const link = root.getByRole('link', { name: 'Inspect in Prefix Tool', exact: true });
+ assert(await link.count() === 1, 'known one-byte repeater must offer Inspect in Prefix Tool');
+ assert(await link.getAttribute('href') === destination, 'inspection must carry the full public key');
+ assert(await link.isVisible(), 'inspection link must be visible');
+ assert((await link.getAttribute('style') || '').includes('color:var(--link-color)'), 'inspection must use the shared link color');
+ assert(await p.locator('html').getAttribute('data-theme') === theme, 'wrong theme');
+ assert(await root.evaluate(el => el.scrollWidth <= el.clientWidth + 1), 'metadata overflows its layout');
+ const prefix = '/api/nodes/' + selected.public_key;
+ const expected = ['', '/health', ...(layout.name === 'tablet' ? [] : ['/neighbors', '/paths', '/clock-skew'])].map(s => prefix + s).sort();
+ const actual = requests.map(u => u.pathname).filter(u => u === prefix || u.startsWith(prefix + '/')).sort();
+ assert(JSON.stringify(actual) === JSON.stringify(expected), 'detail requests changed: ' + JSON.stringify(actual));
+ assert(!requests.some(u => u.pathname.startsWith('/api/analytics/')), 'rendering the link must not fetch analytics');
+ if (process.env.SCREENSHOT_DIR) {
+ fs.mkdirSync(process.env.SCREENSHOT_DIR, { recursive: true });
+ await root.screenshot({ path: path.join(process.env.SCREENSHOT_DIR, `prefix-link-${layout.name}-${theme}.png`) });
+ }
+ requests.length = 0;
+ if (theme === 'dark') {
+ await link.focus();
+ assert(await link.evaluate(el => document.activeElement === el), 'inspection link must accept keyboard focus');
+ await link.press('Enter');
+ } else await link.click();
+ await p.waitForURL(url => url.hash === destination);
+ await p.waitForFunction(() => document.getElementById('ptCheckerResults')?.textContent.includes('Derived prefixes:'));
+ assert(await p.locator('#analyticsTabs [data-tab="prefix-tool"]').evaluate(el => el.classList.contains('active')), 'Prefix Tool tab must be selected');
+ assert(await p.locator('#ptPrefixInput').inputValue() === selected.public_key, 'full key must be prefilled');
+ const resultKeys = await p.locator('#ptCheckerResults a').evaluateAll(links => links.map(a => a.getAttribute('href')));
+ const expectedKeys = [nodes[1], ...(layout.filtered ? [] : [nodes[4]])].map(n => '#/nodes/' + n.public_key);
+ assert(JSON.stringify(resultKeys.sort()) === JSON.stringify(expectedKeys.sort()), 'auto-results must exclude self, non-repeaters and filtered nodes: ' + JSON.stringify(resultKeys));
+ const bulk = requests.filter(u => u.pathname === '/api/nodes');
+ assert(bulk.length <= 1, 'Prefix Tool must reuse cached nodes or the existing bulk node loader');
+ for (const request of bulk) {
+ assert(request.searchParams.get('region') === (layout.filtered ? 'TEST' : null), 'region scope changed');
+ assert(request.searchParams.get('area') === (layout.filtered ? 'prefix-fixture' : null), 'area scope changed');
+ }
+ assert(await p.locator('#ptChecker').evaluate(el => el.scrollWidth <= el.clientWidth + 1), 'Prefix Tool checker overflows');
+ if (process.env.SCREENSHOT_DIR) await p.locator('#ptChecker').screenshot({ path: path.join(process.env.SCREENSHOT_DIR, `prefix-result-${layout.name}-${theme}.png`) });
+ });
+ await step(`#1154 ${theme} ${layout.name}: no page or console errors`, async () => assert(errors.length === 0, errors.join(' | ')));
+ } finally { await ctx.close(); }
+ }
+}
+
(async () => {
const browser = await chromium.launch({
headless: true,
@@ -353,6 +463,7 @@ async function previewMetadata(browser) {
});
await previewMetadata(browser);
+ await prefixToolNavigation(browser);
await browser.close();
console.log(`\n${passed}/${passed + failed} passed`);
diff --git a/tests/unit/test-frontend-helpers.js b/tests/unit/test-frontend-helpers.js
index 673f7663..a96846ac 100644
--- a/tests/unit/test-frontend-helpers.js
+++ b/tests/unit/test-frontend-helpers.js
@@ -4663,6 +4663,41 @@ console.log('\n=== nodes.js: preview metadata (#2309) ===');
assert.strictEqual(renderPreview({ hash_size: size }).value('Hash Prefix'), 'Unknown');
}
});
+ for (const size of [1, '1']) {
+ test('one-byte repeater prefix links its full key to Prefix Tool (' + typeof size + ')', () => {
+ const key = 'aBcDeF01'.repeat(8);
+ const value = renderPreview({ public_key: key, hash_size: size }).value('Hash Prefix');
+ assert.match(value, /]*>AB<\/code> \(1-byte\)/);
+ const link = value.match(/]*href="([^"]+)"[^>]*>Inspect in Prefix Tool<\/a>/);
+ assert.ok(link, 'known one-byte repeater must offer Inspect in Prefix Tool');
+ assert.strictEqual(link[1], '#/analytics?tab=prefix-tool&prefix=' + key);
+ assert.doesNotMatch(value, /collision|other nodes/i, 'navigation must not assert a collision');
+ });
+ }
+ test('Prefix Tool action requires a known one-byte size and a repeater', () => {
+ for (const size of [undefined, null, '', ' ', 'bad', '
', false, true, {}, [], NaN, Infinity, -1, 0, 1.5, 2, '2', 3, 4]) {
+ assert.doesNotMatch(renderPreview({ hash_size: size }).value('Hash Prefix'), / {
+ for (const key of ['', 'ab', 'ab'.repeat(31), 'a'.repeat(63), 'a'.repeat(65), 'g'.repeat(64), 'ab'.repeat(31) + '"><']) {
+ const value = renderPreview({ public_key: key, hash_size: 1 }).value('Hash Prefix');
+ assert.doesNotMatch(value, / \(1-byte\)/);
+ });
+ test('one-byte inspection link preserves the escaped variation marker', () => {
+ const bad = '">
';
+ const value = renderPreview({ hash_size: 1, hash_size_inconsistent: true, hash_sizes_seen: [1, bad] }).value('Hash Prefix');
+ assert.match(value, /]*>AB<\/code> \(1-byte\)/);
+ assert.match(value, /title="Seen: 1, "><img src=x onerror="bad\(\)">-byte"/);
+ assert.match(value, /<\/svg>varies<\/span>/);
+ assert.doesNotMatch(value, /
Inspect in Prefix Tool<\/a>/);
+ });
test('relay counts and hash-size tooltip text cannot inject markup', () => {
const bad = '">
';
const { value } = renderPreview({ relay_count_1h: bad, hash_size_inconsistent: true, hash_sizes_seen: [1, bad] });