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

@@ -1,59 +0,0 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const contentAreaSource = readFileSync(new URL("../../../components/layout/ContentArea.vue", import.meta.url), "utf8");
const connectionTreeSource = readFileSync(new URL("../../../components/sidebar/ConnectionTree.vue", import.meta.url), "utf8");
const ddlViewDialogSource = readFileSync(new URL("../../../components/objects/DdlViewDialog.vue", import.meta.url), "utf8");
const objectBrowserSource = readFileSync(new URL("../../../components/objects/ObjectBrowser.vue", import.meta.url), "utf8");
const fetchTableDdlSource = objectBrowserSource.match(/async function fetchTableDdl(?:\([^)]*\))?[\s\S]*?(?=\nasync function fetchTableColumns\()/)?.[0] ?? "";
const exportStructureSource = objectBrowserSource.match(/async function exportStructure\([\s\S]*?(?=\nasync function exportDataLegacy\()/)?.[0] ?? "";
function openingTag(source: string, componentName: string): string {
return source.match(new RegExp(`<${componentName}\\b[\\s\\S]*?>`))?.[0] ?? "";
}
describe("ContentArea external catalog wiring", () => {
it("passes the object browser catalog to ObjectBrowser", () => {
expect(openingTag(contentAreaSource, "ObjectBrowser")).toContain(':catalog="activeTab.objectBrowser?.catalog"');
});
it("does not attach object browser state to DataGrid", () => {
expect(openingTag(contentAreaSource, "DataGrid")).not.toContain("activeTab.objectBrowser?.catalog");
});
it("passes the sidebar catalog to the DDL dialog", () => {
expect(openingTag(connectionTreeSource, "SidebarDdlViewDialog")).toContain(':catalog="sidebarDdlTarget.catalog"');
});
it("forwards the DDL dialog catalog to the persistent DDL loader", () => {
expect(ddlViewDialogSource).toMatch(/loadObjectDdl\([\s\S]*?objectType: props\.objectType,[\s\S]*?catalog: props\.catalog/);
});
});
describe("ContentArea object browser refresh wiring", () => {
it("routes content refresh through the ObjectBrowser handle", () => {
expect(contentAreaSource).toContain('if (props.activeTab.mode === "objects") return objectBrowserRef.value?.refresh?.() ?? false;');
});
it("exposes object and active table-info reloads as refresh", () => {
expect(objectBrowserSource).toMatch(/function refresh\(\): boolean \{\s+void reload\(\{ preserveExistingRows: true \}\);\s+void refreshActiveTableInfo\(\);\s+return true;\s+\}/);
expect(objectBrowserSource).toContain("defineExpose({ focusSearch, refresh, matchesRefreshScope });");
});
it("shows the configured content refresh shortcut on the refresh button", () => {
expect(objectBrowserSource).toContain("formatShortcut(settingsStore.editorSettings.shortcuts.refreshData)");
expect(objectBrowserSource).toMatch(/<Button[^>]*:title="refreshTooltip"[^>]*@click="refresh">/);
});
});
describe("ObjectBrowser DDL API boundaries", () => {
it("uses the cached display DDL boundary for the table information panel", () => {
expect(fetchTableDdlSource).toMatch(/loadObjectDdl\(tableMetadataRequest\(row\), \{ force \}\)/);
expect(objectBrowserSource).toMatch(/function tableMetadataRequest\([\s\S]*?catalog: props\.catalog/);
});
it("keeps structure exports on the portable base DDL", () => {
expect(exportStructureSource).toMatch(/api\.getTableDdl\([\s\S]*?props\.catalog, true\);/);
expect(exportStructureSource).not.toContain("api.getTableDisplayDdl(");
});
});
@@ -1,29 +1,7 @@
import { readFileSync } from "node:fs";
import { nextTick, ref, watch } from "vue";
import { describe, expect, it } from "vitest";
const objectBrowserSource = readFileSync(new URL("../../../components/objects/ObjectBrowser.vue", import.meta.url), "utf8");
describe("ObjectBrowser context watcher", () => {
it("watches context fields independently", () => {
expect(objectBrowserSource).toContain("[() => props.connection.id, () => props.database, () => props.schema]");
expect(objectBrowserSource).not.toContain("() => [props.connection.id, props.database, props.schema]");
});
it("invalidates object requests before waiting for the new connection", () => {
const watcher = objectBrowserSource.match(/watch\(\s*\[\(\) => props\.connection\.id[\s\S]*?\{ immediate: true \},\s*\);/)?.[0] ?? "";
expect(watcher).toContain("const contextEpoch = objectBrowserRowsLoadGuard.invalidate();");
expect(watcher.indexOf("objectBrowserRowsLoadGuard.invalidate()")).toBeLessThan(watcher.indexOf("await connectionStore.ensureConnected"));
expect(watcher).toContain("reload({ allowCachedObjects: true, contextEpoch })");
});
it("loads MongoDB collections through the existing objects view", () => {
expect(objectBrowserSource).toContain("api.mongoListCollections");
expect(objectBrowserSource).toContain("buildMongoObjectBrowserRows");
expect(objectBrowserSource).toContain("objects.searchCollections");
});
it("ignores connection object replacement when the context values stay unchanged", async () => {
const connection = ref({ id: "connection-1" });
const database = ref("database-1");