|
15 | 15 | pass "bar move outline has no post-release settling state" |
16 | 16 |
|
17 | 17 | run_node_test <<'JS' |
| 18 | +const fs = require('fs') |
18 | 19 | const bar = requireFromRoot('shell/plugins/bar/BarModel.js') |
| 20 | +const barSource = fs.readFileSync(root + '/shell/plugins/bar/Bar.qml', 'utf8') |
| 21 | +
|
| 22 | +// A center module is mounted twice — drawn copy plus zero-size placeholder — |
| 23 | +// and the order they register in is not stable across a live reconfiguration, |
| 24 | +// so panel routing has to pick the one that is actually on screen. |
| 25 | +const drawn = { moduleName: 'omarchy.clock', visible: true, width: 28, height: 81 } |
| 26 | +const placeholder = { moduleName: 'omarchy.clock', visible: false, width: 0, height: 0 } |
| 27 | +assertEqual(bar.isDrawnSlot(drawn), true, 'bar recognises a drawn slot') |
| 28 | +assertEqual(bar.isDrawnSlot(placeholder), false, 'bar recognises a layout placeholder') |
| 29 | +assertEqual(bar.pickDrawnSlot([placeholder, drawn]), drawn, 'bar picks the drawn slot when the placeholder registers first') |
| 30 | +assertEqual(bar.pickDrawnSlot([drawn, placeholder]), drawn, 'bar picks the drawn slot when it registers first') |
| 31 | +assertEqual(bar.pickDrawnSlot([placeholder]), placeholder, 'bar falls back to the placeholder when nothing is drawn') |
| 32 | +assertEqual(bar.pickDrawnSlot([]), null, 'bar reports no slot when there are none') |
| 33 | +assertEqual(bar.pickDrawnSlot(null), null, 'bar tolerates a missing slot list') |
| 34 | +assert( |
| 35 | + /BarModel\.pickDrawnSlot\(candidates\)/.test(barSource), |
| 36 | + 'bar routes panels through the drawn-slot picker' |
| 37 | +) |
| 38 | +
|
| 39 | +// The open-panel mark sits on the module's desktop-facing edge at every |
| 40 | +// position: under a top bar, over a bottom one, inward from left and right. |
| 41 | +const indicator = barSource.slice(barSource.indexOf('id: openPanelIndicator'), barSource.indexOf('id: openPanelIndicator') + 1600) |
| 42 | +assert( |
| 43 | + /x: root\.vertical\s*\n\s*\? \(root\.position === "left" \? parent\.width - width - inset : inset\)/.test(indicator), |
| 44 | + 'bar pins the open-panel mark to the desktop-facing edge on vertical bars' |
| 45 | +) |
| 46 | +assert( |
| 47 | + /root\.position === "top" \? parent\.height - height - inset : inset/.test(indicator), |
| 48 | + 'bar pins the open-panel mark to the desktop-facing edge on horizontal bars' |
| 49 | +) |
| 50 | +assert( |
| 51 | + /key in activeItem/.test(barSource), |
| 52 | + 'bar asks whether a widget declares an indicator hint before reading it' |
| 53 | +) |
| 54 | +assert( |
| 55 | + /width: root\.vertical \? Style\.space\(2\) : slot\.panelIndicatorExtent/.test(indicator) && |
| 56 | + /height: root\.vertical \? slot\.panelIndicatorExtent : Style\.space\(2\)/.test(indicator), |
| 57 | + 'bar sizes the open-panel mark from the same content hint on both axes' |
| 58 | +) |
19 | 59 |
|
20 | 60 | assertEqual(bar.normalizePosition('left'), 'left', 'bar accepts valid positions') |
21 | 61 | assertEqual(bar.normalizePosition('sideways'), 'top', 'bar defaults invalid positions') |
|
0 commit comments