mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-04-02 10:48:51 -03:00
fix(recipe): show checkpoint-linked recipes in model modal (#851)
This commit is contained in:
@@ -6,6 +6,7 @@ const initializePageFeaturesMock = vi.fn();
|
||||
const getCurrentPageStateMock = vi.fn();
|
||||
const getSessionItemMock = vi.fn();
|
||||
const removeSessionItemMock = vi.fn();
|
||||
const getStorageItemMock = vi.fn();
|
||||
const RecipeContextMenuMock = vi.fn();
|
||||
const refreshVirtualScrollMock = vi.fn();
|
||||
const refreshRecipesMock = vi.fn();
|
||||
@@ -51,6 +52,7 @@ vi.mock('../../../static/js/state/index.js', () => ({
|
||||
vi.mock('../../../static/js/utils/storageHelpers.js', () => ({
|
||||
getSessionItem: getSessionItemMock,
|
||||
removeSessionItem: removeSessionItemMock,
|
||||
getStorageItem: getStorageItemMock,
|
||||
}));
|
||||
|
||||
vi.mock('../../../static/js/components/ContextMenu/index.js', () => ({
|
||||
@@ -117,11 +119,14 @@ describe('RecipeManager', () => {
|
||||
const map = {
|
||||
lora_to_recipe_filterLoraName: 'Flux Dream',
|
||||
lora_to_recipe_filterLoraHash: 'abc123',
|
||||
checkpoint_to_recipe_filterCheckpointName: null,
|
||||
checkpoint_to_recipe_filterCheckpointHash: null,
|
||||
viewRecipeId: '42',
|
||||
};
|
||||
return map[key] ?? null;
|
||||
});
|
||||
removeSessionItemMock.mockImplementation(() => { });
|
||||
getStorageItemMock.mockImplementation((_, defaultValue = null) => defaultValue);
|
||||
|
||||
renderRecipesPage();
|
||||
|
||||
@@ -166,6 +171,8 @@ describe('RecipeManager', () => {
|
||||
active: true,
|
||||
loraName: 'Flux Dream',
|
||||
loraHash: 'abc123',
|
||||
checkpointName: null,
|
||||
checkpointHash: null,
|
||||
recipeId: '42',
|
||||
});
|
||||
|
||||
@@ -177,6 +184,8 @@ describe('RecipeManager', () => {
|
||||
|
||||
expect(removeSessionItemMock).toHaveBeenCalledWith('lora_to_recipe_filterLoraName');
|
||||
expect(removeSessionItemMock).toHaveBeenCalledWith('lora_to_recipe_filterLoraHash');
|
||||
expect(removeSessionItemMock).toHaveBeenCalledWith('checkpoint_to_recipe_filterCheckpointName');
|
||||
expect(removeSessionItemMock).toHaveBeenCalledWith('checkpoint_to_recipe_filterCheckpointHash');
|
||||
expect(removeSessionItemMock).toHaveBeenCalledWith('viewRecipeId');
|
||||
expect(pageState.customFilter.active).toBe(false);
|
||||
expect(indicator.classList.contains('hidden')).toBe(true);
|
||||
@@ -227,4 +236,36 @@ describe('RecipeManager', () => {
|
||||
await manager.refreshRecipes();
|
||||
expect(refreshRecipesMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('restores checkpoint recipe filter state and indicator text', async () => {
|
||||
getSessionItemMock.mockImplementation((key) => {
|
||||
const map = {
|
||||
lora_to_recipe_filterLoraName: null,
|
||||
lora_to_recipe_filterLoraHash: null,
|
||||
checkpoint_to_recipe_filterCheckpointName: 'Flux Base',
|
||||
checkpoint_to_recipe_filterCheckpointHash: 'ckpt123',
|
||||
viewRecipeId: null,
|
||||
};
|
||||
return map[key] ?? null;
|
||||
});
|
||||
|
||||
const manager = new RecipeManager();
|
||||
await manager.initialize();
|
||||
|
||||
expect(pageState.customFilter).toEqual({
|
||||
active: true,
|
||||
loraName: null,
|
||||
loraHash: null,
|
||||
checkpointName: 'Flux Base',
|
||||
checkpointHash: 'ckpt123',
|
||||
recipeId: null,
|
||||
});
|
||||
|
||||
const indicator = document.getElementById('customFilterIndicator');
|
||||
const filterText = indicator.querySelector('#customFilterText');
|
||||
|
||||
expect(filterText.innerHTML).toContain('Recipes using checkpoint:');
|
||||
expect(filterText.innerHTML).toContain('Flux Base');
|
||||
expect(filterText.getAttribute('title')).toBe('Flux Base');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user