test: drop source-text assertion tests and merge locale checks

This commit is contained in:
t8y2 committed 2026-09-23 22:10:06 +08:00
1 parent 349d77d180
commit 8897e12714
257 files changed
+166 -12815

No files matched your search

-57
View File
@@ -1,6 +1,5 @@
import { beforeEach, test, vi } from "vitest";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createPinia, setActivePinia } from "pinia";
import { DEFAULT_SQL_FORMATTER_SETTINGS } from "../../apps/desktop/src/lib/sql/sqlFormatterConfig.ts";
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS } from "../../apps/desktop/src/lib/table/tableColumnTemplates.ts";
@@ -238,17 +237,6 @@ test("migrates legacy execute-all settings to current once and preserves later e
});
});
test("shows the table-open page size control in the Data settings tab", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
const dataSectionStart = source.indexOf("activeSettingsTab === 'data'");
const nextSectionStart = source.indexOf("activeSettingsTab === 'shortcuts'", dataSectionStart);
const control = source.indexOf('id="table-open-page-size"');
assert.ok(dataSectionStart >= 0);
assert.ok(nextSectionStart > dataSectionStart);
assert.ok(control > dataSectionStart && control < nextSectionStart);
});
test("defaults export batch size to 2000 rows", () => {
assert.equal(DEFAULT_EDITOR_SETTINGS.exportBatchSize, 2000);
assert.equal(normalizeEditorSettings({}).exportBatchSize, 2000);
@@ -376,14 +364,6 @@ test("defaults saved SQL to its saved target and normalizes persisted target mod
assert.equal(normalizeEditorSettings({ savedSqlOpenTargetMode: "invalid" as any }).savedSqlOpenTargetMode, "saved");
});
test("shows the saved SQL target selector in Editor settings", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
assert.match(source, /id="editor-saved-sql-open-target"/);
assert.match(source, /<SelectItem value="saved">/);
assert.match(source, /<SelectItem value="current">/);
});
test("defaults Vim mode to off and preserves saved booleans", () => {
assert.equal(DEFAULT_EDITOR_SETTINGS.vimModeEnabled, false);
assert.equal(normalizeEditorSettings({}).vimModeEnabled, false);
@@ -1024,27 +1004,6 @@ test("AI partner presets reuse a supported runtime adapter", () => {
assert.equal(getAiProviderPreset("openai-compatible", "https://api.example.com/v1").label, "OpenAI Compatible");
});
test("API AI provider settings expose and persist a default model ID", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
const modelControl = source.indexOf('<Input v-model="aiEditModel"');
assert.ok(modelControl >= 0);
assert.match(source.slice(modelControl - 300, modelControl + 300), /v-if="!aiIsCliProvider"[\s\S]*t\("ai\.defaultModel"\)[\s\S]*t\('ai\.manualModelPlaceholder'\)/);
assert.match(source, /model:\s*aiEditModel\.value/);
});
test("AI connection test uses the model currently entered in the config form", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
const testConnectionStart = source.indexOf("async function aiTestConn()");
const testConnectionEnd = source.indexOf("async function copyAiTestError()", testConnectionStart);
const testConnection = source.slice(testConnectionStart, testConnectionEnd);
assert.notEqual(testConnectionStart, -1);
assert.notEqual(testConnectionEnd, -1);
assert.match(testConnection, /const config = currentAiEditConfig\(\);[\s\S]*aiTestConnection\(config\)/);
assert.doesNotMatch(testConnection, /activeModel|config\.model\s*=/);
});
test("normalizes legacy AI config and fills provider defaults", () => {
const legacy = normalizeAiConfig({
provider: "openai",
@@ -1172,22 +1131,6 @@ test("normalizeEditorSettings keeps valid UI scales with two-decimal precision",
assert.equal(normalizeEditorSettings({ uiScale: 1.125 }).uiScale, 1.13);
});
test("shows persisted UI scales that are not available as presets", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
assert.match(source, /<SelectValue>\{\{ Math\.round\(editUiScale \* 100\) \}\}%<\/SelectValue>/);
});
test("settings page resets content scroll when switching categories", () => {
const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
assert.match(source, /const settingsContentScrollRef = ref<HTMLElement \| null>\(null\)/);
assert.match(source, /function resetSettingsContentScroll\(\)/);
assert.match(source, /if \(scroller\) scroller\.scrollTop = 0/);
assert.match(source, /watch\(activeSettingsTab, async \(tab\) => \{\s+void resetSettingsContentScroll\(\);/);
assert.match(source, /ref="settingsContentScrollRef" class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden/);
});
test("defaults SQL formatter settings", () => {
assert.deepEqual(DEFAULT_EDITOR_SETTINGS.sqlFormatter, DEFAULT_SQL_FORMATTER_SETTINGS);
assert.deepEqual(normalizeEditorSettings({}).sqlFormatter, DEFAULT_EDITOR_SETTINGS.sqlFormatter);