@bongos/core 1.25.22 → 1.25.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,10 +35,13 @@ const SHELL_SRC = read('shell.js');
35
35
  // SAME stub every time — real enough to fire DOM events at and read innerHTML
36
36
  // back from, which the pure-compute-only harness never needed before task 1003460
37
37
  // wired a real fetch() into the input handler.
38
- function bootPalette({ navItems = [], visibleIds = ['nav-profile', 'nav-work', 'shell-user'], modules = null, fetchImpl = undefined } = {}) {
38
+ // `asleepIds`: nav ids the shell has marked asleep (.nav-item--asleep) while founding.
39
+ function bootPalette({ navItems = [], visibleIds = ['nav-profile', 'nav-work', 'shell-user'], asleepIds = [], modules = null, fetchImpl = undefined } = {}) {
39
40
  const registry = {};
41
+ const asleepClass = (id) => ({ contains: (c) => c === 'nav-item--asleep' && asleepIds.includes(id) });
40
42
  const makeNav = (it) => ({
41
43
  hidden: !!it.hidden,
44
+ classList: asleepClass(`nav-${it.id}`),
42
45
  target: it.external ? '_blank' : '',
43
46
  getAttribute: (n) => (n === 'href' ? it.href : null),
44
47
  querySelector: (sel) => (sel === '.nav-item__label' ? { textContent: it.label } : null),
@@ -69,7 +72,7 @@ function bootPalette({ navItems = [], visibleIds = ['nav-profile', 'nav-work', '
69
72
  documentElement: { classList: { add() {}, remove() {} } },
70
73
  getElementById(id) {
71
74
  if (id === 'topbar-jump' || id === 'topbar-jump-kbd') return stubEl();
72
- return visibleIds.includes(id) ? { hidden: false } : null;
75
+ return visibleIds.includes(id) ? { hidden: false, classList: asleepClass(id) } : null;
73
76
  },
74
77
  querySelectorAll(sel) {
75
78
  if (sel === '#app-sidebar .nav-item') return navItems.map(makeNav);
@@ -429,3 +432,57 @@ test('closing and reopening clears the cache — a fresh open may see new DB sta
429
432
 
430
433
  assert.equal(calls.length, 2, 'a fresh open must not trust a memo carried over from the previous one');
431
434
  });
435
+
436
+ // ---- founding: a sleeping room is not a destination (task 1005285) ----------
437
+ // While a project is founded the shell marks each room the server says sleeps
438
+ // (/me.founding_mode.asleep, keyed by nav id) with .nav-item--asleep and hides it;
439
+ // the server refuses its page too. The jump list must not offer it either, or the
440
+ // founder is listed a room that is not open. Which rooms sleep is the server's own
441
+ // shapeFoundingMode, never a list typed here.
442
+ const require = (await import('node:module')).createRequire(import.meta.url);
443
+ const foundingMode = require('../modules/onboarding/founding-mode.js');
444
+ const ROOMS = [
445
+ { id: 'home', label: 'Home', href: '/' },
446
+ { id: 'work', label: 'Tasks', href: '/work' },
447
+ { id: 'goals', label: 'Goals', href: '/goals' },
448
+ { id: 'goal-map', label: 'Sky', href: '/goal-map' },
449
+ { id: 'board-room', label: 'Board Room', href: '/board-room' },
450
+ { id: 'collab', label: 'Collab', href: '/collab' },
451
+ { id: 'roster', label: 'Builders', href: '/roster' },
452
+ { id: 'profile', label: 'Profile', href: '/profile' },
453
+ { id: 'primer', label: 'Primer', href: '/primer' },
454
+ ];
455
+ const asleepAt = (stage) => Object.keys(foundingMode.shapeFoundingMode({ active: 'true', stage }).asleep).map((id) => `nav-${id}`);
456
+ const navIds = ROOMS.map((r) => `nav-${r.id}`).concat('shell-user');
457
+ const pages = (P) => P.compute('').filter((r) => r.group === 'Pages').map((r) => r.label);
458
+
459
+ test('founding: a room the server says sleeps is neither a page nor a section in the jump list (task 1005285)', () => {
460
+ const asleepIds = asleepAt('scope');
461
+ assert.deepEqual([...asleepIds].sort(), ['nav-collab', 'nav-goal-map', 'nav-goals', 'nav-roster', 'nav-work'],
462
+ 'at scope the server puts Tasks, Goals, Sky, Collab and Builders to sleep');
463
+ const P = bootPalette({ navItems: ROOMS.map((r) => ({ ...r })), visibleIds: navIds, asleepIds });
464
+ assert.deepEqual(pages(P), ['Home', 'Board Room', 'Profile', 'Primer'], 'only the open rooms are listed');
465
+ const all = P.compute('');
466
+ assert.ok(!all.some((r) => r.group === 'Tasks'), 'no Tasks tab is offered while Tasks sleeps');
467
+ assert.ok(all.some((r) => r.group === 'Profile') && all.some((r) => r.group === 'Primer'), 'an open room keeps its sections');
468
+ assert.ok(!P.compute('tas').some((r) => r.href === '/work' || r.href.indexOf('/work#') === 0), 'searching for it finds nothing that goes there');
469
+ });
470
+
471
+ test('founding: a room opens in the jump list the moment its stage is behind (task 1005285)', () => {
472
+ const asleepIds = asleepAt('charter'); // scope and strategize are done: Goals, Sky and Tasks woke
473
+ const P = bootPalette({ navItems: ROOMS.map((r) => ({ ...r })), visibleIds: navIds, asleepIds });
474
+ assert.deepEqual(pages(P), ['Home', 'Tasks', 'Goals', 'Sky', 'Board Room', 'Profile', 'Primer']);
475
+ assert.ok(P.compute('').some((r) => r.group === 'Tasks'), 'the woken room brings its tabs');
476
+ });
477
+
478
+ test('a project that is not founding: the jump list is exactly what it was (task 1005285)', () => {
479
+ const P = bootPalette({ navItems: ROOMS.map((r) => ({ ...r })), visibleIds: navIds });
480
+ assert.deepEqual(pages(P), ROOMS.map((r) => r.label));
481
+ assert.ok(P.compute('').some((r) => r.group === 'Tasks'));
482
+ });
483
+
484
+ test('the jump list reads the sleeping mark, the one shell.js stamps from /me (task 1005285)', () => {
485
+ assert.match(SHELL_SRC, /classList\.add\('nav-item--asleep'\)/, 'shell.js marks a sleeping room with this class');
486
+ assert.match(PALETTE_SRC, /contains\('nav-item--asleep'\)/, 'and the palette skips exactly that class');
487
+ assert.doesNotMatch(PALETTE_SRC.replace(/\/\/.*$/gm, ''), /founding|asleepRooms|WAKES/, 'the palette never works out which rooms sleep on its own');
488
+ });