diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-16 05:10:38 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-16 05:10:38 -0500 |
| commit | afd2ddad818cdbf9f4b77d43efb91c35b6c57946 (patch) | |
| tree | 970b50e89b274aa9d26f46e83d5b77bb55ac2ef4 /scripts/theme-studio/test-app-core.mjs | |
| parent | 1208d96a10e7982650bf1a1118018b5ba471cc60 (diff) | |
| download | dotemacs-afd2ddad818cdbf9f4b77d43efb91c35b6c57946.tar.gz dotemacs-afd2ddad818cdbf9f4b77d43efb91c35b6c57946.zip | |
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.
Diffstat (limited to 'scripts/theme-studio/test-app-core.mjs')
| -rw-r--r-- | scripts/theme-studio/test-app-core.mjs | 25 |
1 files changed, 24 insertions, 1 deletions
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']); +}); |
