From fb87a50a399b81a0ef900a8d33137c64d876ede5 Mon Sep 17 00:00:00 2001 From: Towsty Date: Sat, 12 Sep 2026 20:45:19 -0500 Subject: [PATCH] Show each LoRA dropdown label once --- components/LoraSelect.vue | 3 ++- tests/studio2-lora-label.test.mjs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/studio2-lora-label.test.mjs diff --git a/components/LoraSelect.vue b/components/LoraSelect.vue index a6e1576..3b3778a 100644 --- a/components/LoraSelect.vue +++ b/components/LoraSelect.vue @@ -97,7 +97,8 @@ v-for="name in availableNames" :key="name" :value="name" - >{{ labelFor(name) }}{{ filenameSubtitle ? ' — '+name : '' }} + :title="name" + >{{ labelFor(name) }} diff --git a/tests/studio2-lora-label.test.mjs b/tests/studio2-lora-label.test.mjs new file mode 100644 index 0000000..998627f --- /dev/null +++ b/tests/studio2-lora-label.test.mjs @@ -0,0 +1,19 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import {readFileSync} from 'node:fs' +import * as Vue from 'vue' +import {compile} from '@vue/compiler-dom' +import {renderToString} from '@vue/server-renderer' +import {loraFriendlyName,loraIdentityKey} from '../utils/loras.ts' + +test('LoRA dropdown renders one clean label or alias, with filename only in tooltip',async()=>{ + const source=readFileSync(new URL('../components/LoraSelect.vue',import.meta.url),'utf8') + const option=source.match(//)[0] + const render=new Function('Vue',compile('',{mode:'function',prefixIdentifiers:true}).code)(Vue) + const names=['xaigen-minimax csot.safetensors','folder/XAIgen-klein-portrait.safetensors'] + const aliases={[loraIdentityKey(names[1])]:'Portrait style'} + const html=await renderToString(Vue.createSSRApp({render,setup:()=>({availableNames:names,filenameSubtitle:true,labelFor:name=>loraFriendlyName(name,aliases)})})) + const options=[...html.matchAll(/]*title="([^"]*)"[^>]*>([^<]*)<\/option>/g)] + assert.deepEqual(options.map(match=>match[1]),names) + assert.deepEqual(options.map(match=>match[2]),['xaigen-minimax csot','Portrait style']) +})