test(backend): add comprehensive test coverage for backend modules

Added a new `.coveragerc` file configuring coverage thresholds and exclusions.
Included `pytest.ini` to enable coverage reporting for multiple backend modules (`main`, `llm`, `prompt`, `geoip`, `tts_asr`) with a 90 % fail‑under requirement and detailed HTML output.
Implemented a suite of unit tests:

* `test_geoip.py` – validates geo‑location lookup logic.
* `test_llm_extended.py` – tests LLm response extraction and Ollama interactions.
* `test_main_endpoints.py` – covers API endpoints for completions, OCR, and TTS.
* `test_prompt_extended.py` – verifies language sanitization, timestamp generation, and prompt building.
* `test_tts_asr_coverage.py` – checks device detection, cache clearing, and model loading under various environment configurations.
* `test_tts_asr_extended.py` – further tests TTS/ASR device selection and time‑outs.

Updated `backend/requirements.txt` to use newer, compatible packages, removed obsolete testing dependencies, and added `qwen-tts`.
Modified `backend/tts_asr.py` to work with the new `Qwen3TTSModel`, simplified imports, and adjusted device mapping logic.

Additionally, frontend changes added a new `TreeNodeItem` component, updated Markdown rendering, added TTS instruction fields, and reworked context menu handling.

No breaking changes were introduced.
This commit is contained in:
2026-04-07 23:38:23 +08:00
parent bece7be267
commit 2fdc996af9
19 changed files with 3420 additions and 2325 deletions
+23 -9
View File
@@ -202,10 +202,10 @@ const switchView = (view) => {
v-model.number="store.backgroundOpacity"
class="range-slider"
/>
</div>
</section>
</div>
</section>
<!-- View Switch -->
<!-- View Switch -->
<section class="settings-section">
<h3>{{ t('view') || '视图' }}</h3>
<div class="view-switch">
@@ -306,12 +306,27 @@ const switchView = (view) => {
<option value="AUD">AUD ($)</option>
<option value="CAD">CAD ($)</option>
</select>
</div>
</section>
</div>
</section>
<!-- About -->
<section class="settings-section">
<h3>{{ t('about') }}</h3>
<!-- TTS Settings -->
<section class="settings-section">
<h3>{{ t('ttsSettings') || '语音设置' }}</h3>
<div class="form-group">
<label>{{ t('voiceInstruction') || '声音描述' }}</label>
<input
type="text"
v-model="store.ttsInstruct"
class="select-input"
:placeholder="t('voiceInstructionPlaceholder') || '例如:用温柔的语气说'"
/>
<p class="help-text">{{ t('voiceInstructionDesc') || '描述你想要的声音风格,如语气、情感等' }}</p>
</div>
</section>
<!-- About -->
<section class="settings-section">
<h3>{{ t('about') }}</h3>
<div class="about-card">
<h4>llm-in-text</h4>
<p>A smart Markdown editor with local LLM intelligence.</p>
@@ -641,4 +656,3 @@ const switchView = (view) => {
font-weight: 600;
}
</style>