mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 19:21:27 -03:00
The folder context menu now reads: the content action (check for updates) on top, then the folder operations as one group (new subfolder, rename), then the destructive entry behind its own divider. Gating the three folder entries per page could leave the menu with dangling separators — the recipes sidebar hides all of them and keeps only the update check, which already rendered one stray divider before this change and would have rendered two after it. Add _updateContextMenuSeparators: a divider survives only when a visible entry sits on both sides, and a run of consecutive ones collapses to a single line. The three per-item display toggles fold into one loop. The template order is guarded by a regression test that parses templates/components/context_menu.html, plus behaviour tests for the divider collapsing.
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { readFileSync } from 'fs';
|
|
import path from 'path';
|
|
|
|
// Regression guard for the sidebar folder context-menu layout: the update check
|
|
// sits on top, the folder operations form a single group, and the destructive
|
|
// entry stays last behind its own divider. SidebarManager gates those groups
|
|
// per page and collapses the dividers when a group is hidden, so a reorder here
|
|
// also changes what the recipes page shows.
|
|
describe('Sidebar folder context menu layout', () => {
|
|
const repoRoot = path.resolve(__dirname, '../../..');
|
|
const html = readFileSync(
|
|
path.join(repoRoot, 'templates/components/context_menu.html'),
|
|
'utf-8'
|
|
);
|
|
|
|
const menuHtml = html.slice(
|
|
html.indexOf('id="sidebarFolderContextMenu"'),
|
|
html.indexOf('<!-- Sidebar View Options Menu -->')
|
|
);
|
|
|
|
const sequence = [...menuHtml.matchAll(/<div class="([^"]+)"([^>]*)>/g)].map(([, classes, rest]) => {
|
|
if (classes.includes('context-menu-separator')) return 'separator';
|
|
return /data-action="([^"]+)"/.exec(rest)?.[1] || null;
|
|
});
|
|
|
|
it('keeps the update check first and the folder operations grouped', () => {
|
|
expect(sequence).toEqual([
|
|
'check-folder-updates',
|
|
'separator',
|
|
'create-subfolder',
|
|
'rename-folder',
|
|
'separator',
|
|
'delete-folder',
|
|
]);
|
|
});
|
|
|
|
it('keeps the destructive entry last and visually marked', () => {
|
|
const deleteEntry = menuHtml.match(/<div class="([^"]*)"\s+data-action="delete-folder"/);
|
|
expect(deleteEntry).not.toBeNull();
|
|
expect(deleteEntry[1]).toContain('delete-item');
|
|
expect(sequence[sequence.length - 1]).toBe('delete-folder');
|
|
});
|
|
});
|