test(#1461/#1468/#1470): source-grep regression guards (covers shipped fixes)

Added AFTER #1471 fix commits — these are regression guards (not
red-green TDD per se) that assert the shipped behavior stays applied.

- test-mobile-page-actions-presence.js: index.html script tag +
  filter-toggle / pause mirror, score-toast popover, bottom-nav More
  sheet mirrors, bounded retry, route-change close
- test-issue-1468-no-unknown-channel.js: assert offending
  `payload.channel || "unknown"` is gone + `if (!payload.channel)
  continue` is present in channels.js
- test-issue-1470-node-tile-helper.js: assert _applyTilesToNodeMap
  helper exists, both inset-map call-sites use it (no remaining
  hardcoded OSM tileLayer in nodes.js), roles.js exports
  window.getActiveTileProvider

Wired into test-all.sh.
This commit is contained in:
openclaw-bot
2026-05-28 22:07:25 +00:00
parent f88c413dc9
commit 21f92a299d
4 changed files with 165 additions and 0 deletions
+5
View File
@@ -45,6 +45,11 @@ node test-issue-1450-logo-aspect.js
node test-issue-1454-channels-toggle.js
node test-issue-1456-score-labels.js
# #1461 mobile UX overhaul + #1468 channel-synthesis + #1470 node-detail tile helper
node test-mobile-page-actions-presence.js
node test-issue-1468-no-unknown-channel.js
node test-issue-1470-node-tile-helper.js
echo ""
echo "═══════════════════════════════════════"
echo " All tests passed"
+39
View File
@@ -0,0 +1,39 @@
/**
* #1468 — drop client-side "unknown" channel synthesis.
*
* Added AFTER #1471's fix commit — these tests assert the fix stays applied
* (regression guards, not red-green TDD per se).
*
* The buggy code did: `var channelName = payload.channel || 'unknown';`
* which synthesized a literal "unknown" channel row in the sidebar when
* a CHAN message arrived without a decoded channel name. The fix drops
* those rows entirely with `if (!payload.channel) continue;`.
*
* Source-grep invariants — reverting the fix breaks these.
*/
'use strict';
const fs = require('fs');
const path = require('path');
let passed = 0, failed = 0;
function assert(cond, msg) {
if (cond) { passed++; console.log(' ✓ ' + msg); }
else { failed++; console.error(' ✗ ' + msg); }
}
const channelsSrc = fs.readFileSync(
path.join(__dirname, 'public', 'channels.js'), 'utf8');
console.log('\n=== #1468 A: offending fallback is gone ===');
assert(
!/payload\.channel\s*\|\|\s*['"]unknown['"]/.test(channelsSrc),
'channels.js no longer contains `payload.channel || "unknown"`');
console.log('\n=== #1468 B: new drop logic is present ===');
assert(
/if\s*\(\s*!\s*payload\.channel\s*\)\s*continue\s*;/.test(channelsSrc),
'channels.js drops CHAN payloads with no channel name (if (!payload.channel) continue)');
console.log(`\n#1468 results: ${passed} passed, ${failed} failed`);
process.exit(failed === 0 ? 0 : 1);
+55
View File
@@ -0,0 +1,55 @@
/**
* #1470 — node-detail map inset honors customizer dark-tile provider.
*
* Added AFTER #1471's fix commit — these tests assert the fix stays applied
* (regression guards, not red-green TDD per se).
*
* The buggy code hardcoded `L.tileLayer('https://{s}.tile.openstreetmap.org/...')`
* at both inset-map call-sites in nodes.js, ignoring the customizer dark-tile
* pick. The fix routes both call-sites through a new _applyTilesToNodeMap
* helper that reads from MC_TILE_PROVIDERS via window.getActiveTileProvider().
*
* Source-grep invariants — reverting the fix breaks these.
*/
'use strict';
const fs = require('fs');
const path = require('path');
let passed = 0, failed = 0;
function assert(cond, msg) {
if (cond) { passed++; console.log(' ✓ ' + msg); }
else { failed++; console.error(' ✗ ' + msg); }
}
const nodesSrc = fs.readFileSync(
path.join(__dirname, 'public', 'nodes.js'), 'utf8');
const rolesSrc = fs.readFileSync(
path.join(__dirname, 'public', 'roles.js'), 'utf8');
console.log('\n=== #1470 A: _applyTilesToNodeMap helper exists in nodes.js ===');
assert(
/function\s+_applyTilesToNodeMap\s*\(/.test(nodesSrc),
'nodes.js defines function _applyTilesToNodeMap(map)');
// At least 2 call-sites (the 2 inset-map render paths)
var callCount = (nodesSrc.match(/_applyTilesToNodeMap\s*\(/g) || []).length;
assert(
callCount >= 3, // 1 definition + ≥2 call-sites
'nodes.js calls _applyTilesToNodeMap at >= 2 inset-map render sites (found '
+ (callCount - 1) + ' calls)');
console.log('\n=== #1470 B: no remaining hardcoded OSM tileLayer in nodes.js ===');
assert(
!/L\.tileLayer\(\s*['"]https:\/\/\{s\}\.tile\.openstreetmap\.org\//.test(nodesSrc),
'nodes.js no longer hardcodes OSM tileLayer for inset maps');
console.log('\n=== #1470 C: roles.js exports getActiveTileProvider ===');
assert(
/window\.getActiveTileProvider\s*=\s*function/.test(rolesSrc),
'roles.js defines window.getActiveTileProvider');
assert(
/MC_TILE_PROVIDERS/.test(rolesSrc) && /MC_getDarkTileProvider/.test(rolesSrc),
'roles.js consults MC_TILE_PROVIDERS + MC_getDarkTileProvider registry');
console.log(`\n#1470 results: ${passed} passed, ${failed} failed`);
process.exit(failed === 0 ? 0 : 1);
+66
View File
@@ -0,0 +1,66 @@
/**
* #1461/#1467 — mobile-page-actions.js presence + handler invariants.
*
* Added AFTER #1471's fix commit — these tests assert the fix stays applied
* (regression guards, not red-green TDD per se).
*
* Source-grep invariants (cheap, deterministic). Reverting the production
* code must break these.
*/
'use strict';
const fs = require('fs');
const path = require('path');
let passed = 0, failed = 0;
function assert(cond, msg) {
if (cond) { passed++; console.log(' ✓ ' + msg); }
else { failed++; console.error(' ✗ ' + msg); }
}
const indexHtml = fs.readFileSync(
path.join(__dirname, 'public', 'index.html'), 'utf8');
const mpaSrc = fs.readFileSync(
path.join(__dirname, 'public', 'mobile-page-actions.js'), 'utf8');
console.log('\n=== #1461/#1467 A: index.html loads mobile-page-actions.js ===');
assert(
/<script[^>]*src=["']mobile-page-actions\.js\?v=__BUST__["']/.test(indexHtml),
'index.html includes <script src="mobile-page-actions.js?v=__BUST__">');
console.log('\n=== #1461/#1467 B: mobile-page-actions exports expected handlers ===');
// Filter-toggle / pause mirroring into .nav-left (#1461 #2)
assert(
/filterToggleBtn|filter-toggle-btn/.test(mpaSrc),
'mobile-page-actions mirrors the .filter-toggle-btn into the navbar');
assert(
/pktPauseBtn/.test(mpaSrc),
'mobile-page-actions mirrors the pktPauseBtn into the navbar');
// Score-toast popover (#1461 #8)
assert(
/traffic share|bridge|centrality|score|usefulness/i.test(mpaSrc),
'mobile-page-actions intercepts title= tooltips for score-style metrics');
assert(
/mcMobileToast/.test(mpaSrc),
'mobile-page-actions renders a mcMobileToast popover on touch');
// Bottom-nav More-sheet mirrors (#1467)
assert(
/favToggle/.test(mpaSrc) && /searchToggle/.test(mpaSrc) && /customizeToggle/.test(mpaSrc),
'mobile-page-actions mirrors Favorites/Search/Customize into the More sheet');
assert(
/data-bottom-nav-sheet/.test(mpaSrc),
'mobile-page-actions targets the [data-bottom-nav-sheet] element');
assert(
/data-mpa-mirror/.test(mpaSrc),
'mobile-page-actions marks injected items with data-mpa-mirror for idempotency');
// Bounded retry (polish round 1)
assert(
/retryCount\s*<\s*\d+/.test(mpaSrc),
'mobile-page-actions caps moreSheet retry to a bounded count (no unbounded setTimeout)');
// Route-change close (#1461 #6)
assert(
/mobileDetailSheet/.test(mpaSrc),
'mobile-page-actions closes the mobile detail sheet on route change');
console.log(`\n#1461/#1467 results: ${passed} passed, ${failed} failed`);
process.exit(failed === 0 ? 0 : 1);