// Appearance ribbon: compact by default, with full-width expansion and the same // persisted visibility/reorder controls. No browser or Rust service required. import assert from 'node:assert/strict'; import fs from 'node:fs'; const html = fs.readFileSync('src/admin/web/index.html', 'utf8'); const css = fs.readFileSync('src/admin/web/style.css', 'utf8'); const js = fs.readFileSync('src/admin/web/app/preferences.js', 'utf8'); const registry = JSON.parse(fs.readFileSync('src/admin/web/dashboard-widgets.json', 'utf8')); const locales = ['en_US', 'pl_pl'].map(id => JSON.parse(fs.readFileSync(`langs/${id}.json`, 'utf8')).translations); for (const id of ['dashboard-widget-list', 'dashboard-widget-expand', 'dashboard-widget-scroll-prev', 'dashboard-widget-scroll-next', 'overview-layout-open-settings', 'ui-dashboard-density']) { assert(html.includes(`id="${id}"`), `missing ${id}`); } assert.match(html, /class="appearance-settings-grid dashboard-appearance-grid"/); assert.match(css, /\.appearance-settings-grid\.dashboard-appearance-grid\s*\{[^}]*grid-template-columns:\s*minmax\(0, 1fr\)/s, 'dashboard setting layout must use the full available width'); assert.match(css, /\.dashboard-appearance-grid \.dashboard-widget-list\s*\{[^}]*flex-wrap:\s*nowrap;[^}]*overflow-x:\s*auto;/s, 'the default card selector must be a horizontal ribbon, not a tall two-column list'); assert.match(css, /\.dashboard-appearance-grid \.dashboard-widget-list\.is-expanded\s*\{[^}]*display:\s*grid;/s); assert.match(css, /\.dashboard-widget-settings-controls > \.dashboard-widget-scroll-button/); assert(js.includes('list.scrollLeft = previousScroll'), 'rebuilding settings must preserve horizontal scroll position'); assert(js.includes('focusedId') && js.includes('preventScroll: true'), 'keyboard focus must survive updates'); assert(js.includes('saveAppearancePreference({ dashboard_hidden_widgets:') && js.includes('saveAppearancePreference({ dashboard_widgets:'), 'both APIs must retain persistence'); assert(js.includes('const up = el("button", "←"') && js.includes('const down = el("button", "→"'), 'horizontal order controls must align with the ribbon'); assert.equal(registry.length, 62, 'all configured Overview cards must remain available'); for (const translation of locales) { for (const key of ['dashboardWidgetsShowAll', 'dashboardWidgetsCompact', 'dashboardWidgetsScrollBack', 'dashboardWidgetsScrollNext', 'dashboardWidgetsScrollHelp', 'dashboardWidgetsMoveEarlier', 'dashboardWidgetsMoveLater']) { assert(translation[key], `missing ${key}`); } } console.log('PASS: full-width compact Appearance ribbon with expandable 62-card layout, keyboard focus and preference persistence');