From afd2ddad818cdbf9f4b77d43efb91c35b6c57946 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 16 Jun 2026 05:10:38 -0500 Subject: feat(theme-studio): alphabetize packages in the assignment dropdown The assignment-view dropdown listed package faces in APPS build order (bespoke apps first, then inventory). generate.py builds them that way, so the list wasn't alphabetical. I added a pure appViewKeysSorted helper that orders the app keys by display label, and buildViewSel uses it. The @code and @ui editor entries above the divider are unchanged. --- scripts/theme-studio/test-app-core.mjs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'scripts/theme-studio/test-app-core.mjs') diff --git a/scripts/theme-studio/test-app-core.mjs b/scripts/theme-studio/test-app-core.mjs index 7f537d128..a55abadd0 100644 --- a/scripts/theme-studio/test-app-core.mjs +++ b/scripts/theme-studio/test-app-core.mjs @@ -9,7 +9,7 @@ import { fileURLToPath } from 'node:url'; import { nameToHex, normalizePkgFace, buildPkgmap, packagesForExport, mergePackagesInto, effResolve, resolveSyntaxFg, resolveUiAttr, dropdownRowTextColor, paletteOptionList, spanNeighborHex, slugify, clearPalettePlan, deletePaletteColumnPlan, groundColumnMembersFromPalette, areAllLocked, lockToggleLabel, toggleLockSet, - galleryModel, + galleryModel, appViewKeysSorted, } from './app-core.js'; import { planPaletteGenerator, entriesForGeneratedColumn } from './palette-generator-core.js'; import { oklch2hex, deltaE } from './colormath.js'; @@ -823,3 +823,26 @@ test('dropdownRowTextColor: the filled default row contrasts against its fill', test('dropdownRowTextColor: a default row with no fill inherits (empty)', () => { assert.equal(dropdownRowTextColor('', '', stubTextOn), ''); }); + +// appViewKeysSorted: the assignment-view dropdown lists package apps +// alphabetically by display label, independent of the APPS build order +// (generate.py emits bespoke apps first, then inventory apps). +test('appViewKeysSorted: sorts app keys by display label, case-insensitive', () => { + const apps = { dashboard: { label: 'Dashboard' }, magit: { label: 'Magit' }, + alert: { label: 'alert' }, 'web-mode': { label: 'web-mode' } }; + assert.deepEqual(appViewKeysSorted(apps), ['alert', 'dashboard', 'magit', 'web-mode']); +}); +test('appViewKeysSorted: bespoke-then-inventory build order comes out alphabetical', () => { + const apps = { magit: { label: 'Magit' }, dashboard: { label: 'Dashboard' }, + alert: { label: 'alert' }, consult: { label: 'consult' } }; + assert.deepEqual(appViewKeysSorted(apps), ['alert', 'consult', 'dashboard', 'magit']); +}); +test('appViewKeysSorted: empty or nullish input yields an empty list', () => { + assert.deepEqual(appViewKeysSorted({}), []); + assert.deepEqual(appViewKeysSorted(null), []); + assert.deepEqual(appViewKeysSorted(undefined), []); +}); +test('appViewKeysSorted: an app with no label falls back to its key for ordering', () => { + const apps = { zebra: {}, apple: { label: 'apple' } }; + assert.deepEqual(appViewKeysSorted(apps), ['apple', 'zebra']); +}); -- cgit v1.2.3