mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
feat(recipes): show a summary modal after rematch runs
Replace the post-run toast cascade and the standalone L4 results modal with a summary modal modeled on the batch download summary: 3-state header, stat cards (matched / needs review / unresolved / errors), an L4 review table with per-entry undo, and a copyable report. Wired into the global, bulk and single-recipe rematch entries; complete no-op runs keep the lightweight toast. Obsolete results-modal code, styles and i18n keys are removed.
This commit is contained in:
@@ -95,6 +95,7 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
stateStub.currentPageType = 'recipes';
|
||||
stateStub.bulkMode = false;
|
||||
stateStub.selectedModels.clear();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
async function createBulkManager() {
|
||||
@@ -107,9 +108,9 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
expect(bulk.actionConfig.recipes.rematchMetadata).toBe(true);
|
||||
});
|
||||
|
||||
// Oracle R4-F1 pin: the complete toast must branch on `rematched` — a blind
|
||||
// `repaired` mirror would fire the skipped toast with count 0 here.
|
||||
it('toasts the rematched count when the bulk rematch succeeds', async () => {
|
||||
// Oracle R4-F1 pin: the summary modal must branch on `matched_entries` — a
|
||||
// blind `repaired` mirror would render 0 matched entries here.
|
||||
it('opens the summary modal when the bulk rematch succeeds', async () => {
|
||||
const bulk = await createBulkManager();
|
||||
stateStub.selectedModels.add('/recipes/a.webp');
|
||||
stateStub.selectedModels.add('/recipes/b.webp');
|
||||
@@ -140,23 +141,31 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
],
|
||||
{ relaxed: false }
|
||||
);
|
||||
expect(showToastMock).toHaveBeenCalledWith(
|
||||
// Non-noop runs open the summary modal instead of toasting.
|
||||
expect(showToastMock).not.toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchComplete',
|
||||
{ rematched: 4, skipped: 1, total: 3, entries: 4, recipes: 2, failures: 0 },
|
||||
'success'
|
||||
expect.anything(),
|
||||
expect.anything()
|
||||
);
|
||||
expect(showToastMock).not.toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchSkipped',
|
||||
expect.anything(),
|
||||
expect.anything()
|
||||
);
|
||||
const summaryModal = document.getElementById('rematchSummaryModal');
|
||||
expect(summaryModal).not.toBeNull();
|
||||
// unresolved_entries > 0 forces the warning header
|
||||
expect(summaryModal.querySelector('.summary-header').classList.contains('warning')).toBe(true);
|
||||
expect(summaryModal.querySelector('.stat-card-success .stat-card-value').textContent).toBe('4');
|
||||
expect(summaryModal.querySelector('.stat-card-total .stat-card-value').textContent).toBe('1');
|
||||
expect(summaryModal.querySelector('.stat-card-failure .stat-card-value').textContent).toBe('0');
|
||||
expect(updateSingleItemMock).toHaveBeenCalledWith('/recipes/a.webp', rematchedRecipe);
|
||||
expect(loadingManagerStub.showSimpleLoading).toHaveBeenCalled();
|
||||
expect(loadingManagerStub.hide).toHaveBeenCalled();
|
||||
expect(loadingManagerStub.restoreProgressBar).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('uses the errors toast variant when the bulk rematch has failures', async () => {
|
||||
it('opens the summary modal with a warning header when the bulk rematch has failures', async () => {
|
||||
const bulk = await createBulkManager();
|
||||
stateStub.selectedModels.add('/recipes/a.webp');
|
||||
stateStub.selectedModels.add('/recipes/b.webp');
|
||||
@@ -177,14 +186,14 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
await bulk.rematchSelectedRecipes();
|
||||
await confirmRematchOptions();
|
||||
|
||||
expect(showToastMock).toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchCompleteErrors',
|
||||
{ rematched: 3, skipped: 0, total: 2, entries: 3, recipes: 1, failures: 2 },
|
||||
'warning'
|
||||
);
|
||||
const summaryModal = document.getElementById('rematchSummaryModal');
|
||||
expect(summaryModal).not.toBeNull();
|
||||
expect(summaryModal.querySelector('.summary-header').classList.contains('warning')).toBe(true);
|
||||
expect(summaryModal.querySelector('.stat-card-success .stat-card-value').textContent).toBe('3');
|
||||
expect(summaryModal.querySelector('.stat-card-failure .stat-card-value').textContent).toBe('2');
|
||||
});
|
||||
|
||||
it('toasts an error when every selected recipe failed to rematch', async () => {
|
||||
it('opens the summary modal with an error header when every selected recipe failed to rematch', async () => {
|
||||
const bulk = await createBulkManager();
|
||||
stateStub.selectedModels.add('/recipes/a.webp');
|
||||
stateStub.selectedModels.add('/recipes/b.webp');
|
||||
@@ -205,11 +214,10 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
await bulk.rematchSelectedRecipes();
|
||||
await confirmRematchOptions();
|
||||
|
||||
expect(showToastMock).toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchAllFailed',
|
||||
{ total: 2, failures: 2 },
|
||||
'error'
|
||||
);
|
||||
const summaryModal = document.getElementById('rematchSummaryModal');
|
||||
expect(summaryModal).not.toBeNull();
|
||||
expect(summaryModal.querySelector('.summary-header').classList.contains('error')).toBe(true);
|
||||
expect(summaryModal.querySelector('.stat-card-failure .stat-card-value').textContent).toBe('2');
|
||||
expect(showToastMock).not.toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchSkipped',
|
||||
expect.anything(),
|
||||
@@ -217,7 +225,7 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('toasts an info message when entries had no local match', async () => {
|
||||
it('opens the summary modal when entries had no local match', async () => {
|
||||
const bulk = await createBulkManager();
|
||||
stateStub.selectedModels.add('/recipes/a.webp');
|
||||
stateStub.selectedModels.add('/recipes/b.webp');
|
||||
@@ -239,11 +247,11 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
await bulk.rematchSelectedRecipes();
|
||||
await confirmRematchOptions();
|
||||
|
||||
expect(showToastMock).toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchUnmatched',
|
||||
{ entries: 2, recipes: 1, total: 3 },
|
||||
'info'
|
||||
);
|
||||
const summaryModal = document.getElementById('rematchSummaryModal');
|
||||
expect(summaryModal).not.toBeNull();
|
||||
expect(summaryModal.querySelector('.summary-header').classList.contains('warning')).toBe(true);
|
||||
expect(summaryModal.querySelector('.stat-card-success .stat-card-value').textContent).toBe('0');
|
||||
expect(summaryModal.querySelector('.stat-card-total .stat-card-value').textContent).toBe('2');
|
||||
expect(showToastMock).not.toHaveBeenCalledWith(
|
||||
'toast.recipes.rematchSkipped',
|
||||
expect.anything(),
|
||||
@@ -409,7 +417,7 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('shows the L4 results modal when the bulk result carries l4_matches', async () => {
|
||||
it('lists L4 filename matches in the summary modal with undo buttons', async () => {
|
||||
const bulk = await createBulkManager();
|
||||
stateStub.selectedModels.add('/recipes/a.webp');
|
||||
|
||||
@@ -428,17 +436,18 @@ describe('BulkManager.rematchSelectedRecipes', () => {
|
||||
l4_matches: l4Matches,
|
||||
});
|
||||
|
||||
const { rematchModalManager } = await import(
|
||||
'../../../static/js/managers/RematchModalManager.js'
|
||||
);
|
||||
const showResultsSpy = vi
|
||||
.spyOn(rematchModalManager, 'showResultsModal')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
await bulk.rematchSelectedRecipes();
|
||||
await confirmRematchOptions();
|
||||
|
||||
expect(showResultsSpy).toHaveBeenCalledWith(l4Matches);
|
||||
showResultsSpy.mockRestore();
|
||||
const summaryModal = document.getElementById('rematchSummaryModal');
|
||||
expect(summaryModal).not.toBeNull();
|
||||
// L4 matches to review force the warning header
|
||||
expect(summaryModal.querySelector('.summary-header').classList.contains('warning')).toBe(true);
|
||||
expect(summaryModal.querySelector('.stat-card-skipped .stat-card-value').textContent).toBe('1');
|
||||
const rows = summaryModal.querySelectorAll('tr[data-l4-index]');
|
||||
expect(rows).toHaveLength(1);
|
||||
expect(rows[0].textContent).toContain('old.safetensors');
|
||||
expect(rows[0].textContent).toContain('new.safetensors');
|
||||
expect(rows[0].querySelector('.rematch-undo-btn[data-action="undo-match"][data-index="0"]')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user