2026-05-17 08:38:41 +00:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
|
2026-06-24 12:35:59 +08:00
|
|
|
const settingsModel = readFileSync(new URL('../src/utils/settingsModelHelper.js', import.meta.url), 'utf8')
|
2026-05-17 08:38:41 +00:00
|
|
|
const settingsView = readFileSync(new URL('../src/views/SettingsView.vue', import.meta.url), 'utf8')
|
2026-06-24 12:35:59 +08:00
|
|
|
const llmSettingsPanel = readFileSync(new URL('../src/views/LlmSettingsPanel.vue', import.meta.url), 'utf8')
|
2026-05-17 08:38:41 +00:00
|
|
|
|
|
|
|
|
function testLlmSectionReplacesVlmWithReranker() {
|
|
|
|
|
assert.doesNotMatch(settingsView, /VLM 模型/)
|
2026-06-26 22:42:00 +08:00
|
|
|
assert.match(llmSettingsPanel, /Rerank/)
|
2026-06-24 12:35:59 +08:00
|
|
|
assert.match(settingsModel, /rerankerProvider/)
|
2026-05-17 08:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
2026-06-26 22:42:00 +08:00
|
|
|
function testLlmSectionUsesTableAndAddModelDialog() {
|
|
|
|
|
assert.match(llmSettingsPanel, /model-table-toolbar[\s\S]*添加模型/)
|
|
|
|
|
assert.match(llmSettingsPanel, /<table class="model-config-table">/)
|
|
|
|
|
assert.match(llmSettingsPanel, /model-dialog-overlay/)
|
|
|
|
|
assert.match(llmSettingsPanel, /供应商[\s\S]*接口地址[\s\S]*API Key[\s\S]*model_id[\s\S]*模型类型/)
|
|
|
|
|
assert.match(llmSettingsPanel, /大语言模型[\s\S]*Embedding[\s\S]*Rerank/)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testSettingsModelKeepsExtensibleModelRows() {
|
|
|
|
|
assert.match(settingsModel, /models:\s*buildLlmModelRows/)
|
|
|
|
|
assert.match(settingsModel, /buildLlmModelRows/)
|
2026-05-17 08:38:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function run() {
|
|
|
|
|
testLlmSectionReplacesVlmWithReranker()
|
2026-06-26 22:42:00 +08:00
|
|
|
testLlmSectionUsesTableAndAddModelDialog()
|
|
|
|
|
testSettingsModelKeepsExtensibleModelRows()
|
2026-05-17 08:38:41 +00:00
|
|
|
console.log('settings llm section tests passed')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run()
|