refactor: reuse shared source display labels
This commit is contained in:
@@ -3045,6 +3045,29 @@ test('model info hash readers preserve field precedence and casing', () => {
|
||||
assert.equal(getSourceModelDisplayHash({}), '');
|
||||
});
|
||||
|
||||
test('model info metadata source labels match the shared source label contract', () => {
|
||||
const getInfoMetadataSourceLabel = eval(`(${extractMethod(modelInfoMethodsSource, 'getInfoMetadataSourceLabel')})`);
|
||||
const dialog = {
|
||||
sourceKey: 'metadata',
|
||||
getInfoMetadataSourceKey() {
|
||||
return this.sourceKey;
|
||||
},
|
||||
};
|
||||
|
||||
const expectedLabels = new Map([
|
||||
['huggingface', 'HuggingFace'],
|
||||
['civarchive', 'CivArchive'],
|
||||
['civitai', 'CivitAI'],
|
||||
['lora_manager_archive', 'LoRA Archive'],
|
||||
['metadata', 'metadata source'],
|
||||
]);
|
||||
|
||||
for (const [sourceKey, expectedLabel] of expectedLabels) {
|
||||
dialog.sourceKey = sourceKey;
|
||||
assert.equal(getInfoMetadataSourceLabel.call(dialog), expectedLabel);
|
||||
}
|
||||
});
|
||||
|
||||
test('workflow signature tracks model strength for bypass and custom LoRA loaders', () => {
|
||||
const getWorkflowSignatureData = eval(`(${extractMethod(workflowStateMethodsSource, 'getWorkflowSignatureData')})`);
|
||||
const dialog = { capabilities: { node_rules: {} } };
|
||||
|
||||
@@ -4,6 +4,7 @@ import { escapeHtml, escapeJsString, getFilenameFromPath, sanitizeDescriptionHtm
|
||||
import { getModelCardUrl } from "../utils/url_utils.js";
|
||||
import { extractComfyWorkflow } from "../utils/workflow_metadata.js";
|
||||
import { getSha256Field, normalizeSha256 } from "../utils/hash_utils.js";
|
||||
import { getSourceDisplayLabel } from "../utils/source_labels.js";
|
||||
import { getCivitaiModelUrl } from "../globals.js";
|
||||
export const modelInfoMethods = {
|
||||
escapeHtml,
|
||||
@@ -1874,11 +1875,7 @@ export const modelInfoMethods = {
|
||||
|
||||
getInfoMetadataSourceLabel(data = {}) {
|
||||
const key = this.getInfoMetadataSourceKey(data);
|
||||
if (key === 'huggingface') return 'HuggingFace';
|
||||
if (key === 'civarchive') return 'CivArchive';
|
||||
if (key === 'civitai') return 'CivitAI';
|
||||
if (key === 'lora_manager_archive') return 'LoRA Archive';
|
||||
return 'metadata source';
|
||||
return getSourceDisplayLabel(key, { fallback: 'metadata source' });
|
||||
},
|
||||
|
||||
getInfoMetadataSourceIcon(data = {}) {
|
||||
|
||||
Reference in New Issue
Block a user