mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-06-01 23:14:13 +00:00
b2d654bf61
## Closes #1415 — packets cross-viewport jank ## Closes #1458 — Tufte mobile-packets P0 findings (folded into same branch) Single PR covers both issues — they touch the same files (`public/packets.js`, `public/style.css`) and a split would invite merge thrash. ### #1415 — column priority + chrome compaction Locked column-priority tiers (operator spec): | Tier | Viewport | Columns | |---|---|---| | 1 | always (mobile through desktop) | expand · time · type · details | | 2 | tablet+ (>768px) | path | | 3 | desktop only (>1024px) | hash · observer · rpt | Enforced via existing `data-priority` system in `TableResponsive.apply` (priorities 3 → hide ≤1024, 5 → hide ≤768). CSS: - `.col-expand` pinned to `width/min-width/max-width: 32px` at every viewport — kills the 50–180px dead column that pushed every data column right. - `.col-details` capped at `max-width: 480px` so wide viewports stop wasting hundreds of px on the last column. - `@media (max-width: 480px)` hides page-header BYOP, shrinks the h2, and tightens row padding → pre-table chrome drops from ~280px to ~140px. ### #1458 — Tufte mobile P0 findings **P0-A: semantic-first detail panel.** Was: `"Packet Byte Breakdown (134 bytes)"` title + giant neon hex grid above the meaningful fields. Now: type badge + decoded summary + hop count + `src → dst` lead the panel, followed by the existing `.detail-meta` dl (reordered: Payload Type → Path → Timestamp → Observer). **P0-B: raw-bytes disclosure.** Hex legend / hex dump / field table wrapped in `<details class="detail-technical">`. Disclosure copy reads "Show raw bytes". Collapsed by default on phones (`window.innerWidth ≤ 480`), expanded on tablet+. **P0-C: mobile filter-zone collapse.** The always-on filter-expression input above `.filter-bar` is now wrapped with `.pkt-filter-expr` and hidden under the `@media (max-width: 480px)` block. Reveals when the existing "Filters ▾" toggle adds `.filters-expanded` to the sibling `.filter-bar` (CSS `:has()` selector — one tap reveals both chrome rows together). ### TDD `test-issue-1415-packets-layout.js` — pure source-grep, no browser: - col-expand class on first `<th>` + `<td>` + CSS 32px pin - locked column-priority tier values per column - `.col-details` max-width ≤ 480px - mobile @media block: hides BYOP, hides `.pkt-filter-expr` (revealed by `.filters-expanded`) - detail-meta order: Payload Type before Observer - `<details class="detail-technical">` wrapper exists with "Show raw bytes" summary - detail-title leads with a type badge; `.detail-srcdst` emitted - old "Packet Byte Breakdown (N bytes)" title literal removed Red commit `d4372d82` (8 assertion failures, no compile errors), green commit `4fab9dbd` (#1415 work), follow-up commit `a5218035` (#1458 work) keeps everything green. 26 assertions, 0 failed. --------- Co-authored-by: openclaw-bot <bot@openclaw>
143 lines
6.0 KiB
JavaScript
143 lines
6.0 KiB
JavaScript
/**
|
|
* E2E (#1056): Fluid table columns + "+N hidden" pill.
|
|
*
|
|
* Boots Chromium against a local corescope-server and verifies that the
|
|
* primary tables (Packets, Nodes, Observers) collapse priority-tagged
|
|
* columns at narrow viewports, render a "+N hidden" pill in the header
|
|
* showing the count, and that clicking the pill reveals the hidden columns.
|
|
*
|
|
* Tested viewports: 768, 1080, 1440 (parent task: 768/1080/1440/1920).
|
|
*
|
|
* Usage: BASE_URL=http://localhost:13581 node test-table-fluid-e2e.js
|
|
*/
|
|
'use strict';
|
|
const { chromium } = require('playwright');
|
|
|
|
const BASE = process.env.BASE_URL || 'http://localhost:13581';
|
|
|
|
let passed = 0, failed = 0;
|
|
async function step(name, fn) {
|
|
try { await fn(); passed++; console.log(' ✓ ' + name); }
|
|
catch (e) { failed++; console.error(' ✗ ' + name + ': ' + e.message); }
|
|
}
|
|
function assert(c, m) { if (!c) throw new Error(m || 'assertion failed'); }
|
|
|
|
const PAGES = [
|
|
{ hash: '#/packets', tableSel: '#pktTable', name: 'packets' },
|
|
{ hash: '#/nodes', tableSel: '#nodesTable', name: 'nodes' },
|
|
{ hash: '#/observers', tableSel: '#obsTable', name: 'observers' },
|
|
];
|
|
|
|
const VIEWPORTS = [
|
|
{ w: 768, h: 900, expectHidden: true },
|
|
{ w: 1080, h: 900, expectHidden: true },
|
|
{ w: 1440, h: 900, expectHidden: false }, // wide enough — no hide expected (or 0)
|
|
{ w: 1920, h: 900, expectHidden: false }, // AC #5: also exercise 1920px
|
|
];
|
|
|
|
// Per-(page, viewport) override map. After #1415 the packets table's
|
|
// column priorities were rewritten to the locked spec — at 1080px (>1024)
|
|
// every packets column is visible (data-priority 3 columns reveal above
|
|
// 1024px, priority 5 above 768px). The /nodes and /observers tables still
|
|
// match the original #1056 contract. Default falls through to VIEWPORTS.
|
|
function expectHidden(pageName, w) {
|
|
if (pageName === 'packets' && w >= 1080) return false;
|
|
const vp = VIEWPORTS.find(v => v.w === w);
|
|
return vp ? vp.expectHidden : false;
|
|
}
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({
|
|
headless: true,
|
|
executablePath: process.env.CHROMIUM_PATH || undefined,
|
|
args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
|
|
});
|
|
|
|
console.log(`\n=== #1056 fluid tables E2E against ${BASE} ===`);
|
|
|
|
for (const vp of VIEWPORTS) {
|
|
const ctx = await browser.newContext({ viewport: { width: vp.w, height: vp.h } });
|
|
const page = await ctx.newPage();
|
|
page.setDefaultTimeout(8000);
|
|
page.on('pageerror', (e) => console.error('[pageerror]', e.message));
|
|
|
|
for (const p of PAGES) {
|
|
const tag = `${p.name}@${vp.w}`;
|
|
|
|
await step(`${tag}: page renders`, async () => {
|
|
await page.goto(BASE + '/' + p.hash, { waitUntil: 'domcontentloaded' });
|
|
await page.waitForSelector(p.tableSel, { timeout: 8000 });
|
|
// give responsive logic a tick
|
|
await page.waitForTimeout(300);
|
|
});
|
|
|
|
await step(`${tag}: no horizontal table scroll`, async () => {
|
|
const overflow = await page.evaluate((sel) => {
|
|
const t = document.querySelector(sel);
|
|
if (!t) return { ok: false, reason: 'no table' };
|
|
// Either the table itself or a wrapper must not horizontally overflow
|
|
// its container at this viewport.
|
|
const wrap = t.closest('.table-fluid-wrap, .obs-table-scroll, .table-scroll-wrap') || t.parentElement;
|
|
return {
|
|
tableW: t.scrollWidth,
|
|
wrapW: wrap.clientWidth,
|
|
// Allow a few px tolerance for sub-pixel rounding / scrollbar gutter.
|
|
ok: t.scrollWidth <= wrap.clientWidth + 8,
|
|
};
|
|
}, p.tableSel);
|
|
assert(overflow.ok, `table overflows: tableW=${overflow.tableW} wrapW=${overflow.wrapW}`);
|
|
});
|
|
|
|
await step(`${tag}: +N hidden pill state matches hidden columns`, async () => {
|
|
const info = await page.evaluate((sel) => {
|
|
const t = document.querySelector(sel);
|
|
if (!t) return { ok: false, reason: 'no table' };
|
|
const heads = Array.from(t.querySelectorAll('thead th'));
|
|
const hiddenHeads = heads.filter(h => h.classList.contains('col-hidden'));
|
|
const pill = t.querySelector('.col-hidden-pill');
|
|
return {
|
|
hiddenCount: hiddenHeads.length,
|
|
hasPill: !!pill,
|
|
pillText: pill ? pill.textContent.trim() : '',
|
|
pillVisible: pill ? pill.offsetParent !== null : false,
|
|
};
|
|
}, p.tableSel);
|
|
|
|
if (expectHidden(p.name, vp.w)) {
|
|
assert(info.hiddenCount >= 1, `expected ≥1 hidden col at ${vp.w}px, got ${info.hiddenCount}`);
|
|
assert(info.hasPill && info.pillVisible, `expected visible +N pill at ${vp.w}px`);
|
|
assert(/\+\d+/.test(info.pillText), `pill text "${info.pillText}" missing +N marker`);
|
|
const m = info.pillText.match(/\+(\d+)/);
|
|
const n = m ? parseInt(m[1], 10) : -1;
|
|
assert(n === info.hiddenCount, `pill says +${n} but ${info.hiddenCount} columns are hidden`);
|
|
} else {
|
|
// wide: no hidden cols, pill should be absent or hidden
|
|
if (info.hasPill) assert(!info.pillVisible || /\+0/.test(info.pillText), `expected no/zero pill at ${vp.w}px, got "${info.pillText}"`);
|
|
}
|
|
});
|
|
|
|
if (expectHidden(p.name, vp.w)) {
|
|
await step(`${tag}: clicking pill reveals hidden columns`, async () => {
|
|
// Click pill
|
|
const pillSel = `${p.tableSel} .col-hidden-pill`;
|
|
await page.click(pillSel);
|
|
await page.waitForTimeout(150);
|
|
const after = await page.evaluate((sel) => {
|
|
const t = document.querySelector(sel);
|
|
const heads = Array.from(t.querySelectorAll('thead th'));
|
|
return heads.filter(h => h.classList.contains('col-hidden')).length;
|
|
}, p.tableSel);
|
|
assert(after === 0, `expected 0 hidden cols after pill click, got ${after}`);
|
|
});
|
|
}
|
|
}
|
|
|
|
await ctx.close();
|
|
}
|
|
|
|
await browser.close();
|
|
|
|
console.log(`\n=== #1056 fluid tables E2E: ${passed} passed, ${failed} failed ===`);
|
|
process.exit(failed ? 1 : 0);
|
|
})();
|