test: drop source-text assertion tests and merge locale checks
This commit is contained in:
1 parent
349d77d180
commit
8897e12714
257 files changed
+166
-12815
No files matched your search
@@ -1,9 +1,7 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { shallowRef, reactive, nextTick, effectScope } from "vue";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ColumnInfo, TreeNode } from "@/types/database";
|
||||
|
||||
const source = readFileSync(new URL("../useSidebarTreeExportRuntime.ts", import.meta.url), "utf8");
|
||||
const toastMock = vi.hoisted(() => vi.fn());
|
||||
const copyToClipboardMock = vi.hoisted(() => vi.fn());
|
||||
const addExportTaskMock = vi.hoisted(() => vi.fn());
|
||||
@@ -40,19 +38,6 @@ import { useSidebarTreeExportRuntime } from "@/composables/useSidebarTreeExportR
|
||||
import { DEFAULT_DATA_GRID_EXTRACTOR_OPTIONS } from "@/lib/dataGrid/dataGridCopyExtractor";
|
||||
import { isLoadingStructurePreview, showStructurePreviewDialog, structurePreviewDefaultFileName, structurePreviewError, structurePreviewSql, structurePreviewTitle } from "@/components/sidebar/sidebarTreeDialogState";
|
||||
|
||||
function functionBody(name: string): string {
|
||||
const signature = new RegExp(`(?:async\\s+)?function\\s+${name}\\s*\\([^)]*\\)\\s*(?::\\s*[^\\{]+)?\\{`, "m").exec(source);
|
||||
if (!signature) throw new Error(`Missing function ${name}`);
|
||||
const bodyStart = signature.index + signature[0].length;
|
||||
let depth = 1;
|
||||
for (let index = bodyStart; index < source.length; index += 1) {
|
||||
if (source[index] === "{") depth += 1;
|
||||
else if (source[index] === "}") depth -= 1;
|
||||
if (depth === 0) return source.slice(bodyStart, index);
|
||||
}
|
||||
throw new Error(`Unclosed function ${name}`);
|
||||
}
|
||||
|
||||
function deferred<T>() {
|
||||
let resolve!: (value: T) => void;
|
||||
let reject!: (reason?: unknown) => void;
|
||||
@@ -355,29 +340,6 @@ describe("useSidebarTreeExportRuntime", () => {
|
||||
expect(showStructurePreviewDialog.value).toBe(true);
|
||||
});
|
||||
|
||||
it("prompts for export options before it opens the save dialog", () => {
|
||||
const exportDataXlsx = functionBody("exportDataXlsx");
|
||||
|
||||
expect(source).toContain('import XlsxHeaderDialog from "@/components/export/XlsxHeaderDialog.vue"');
|
||||
expect(exportDataXlsx).toContain("await api.getColumns(");
|
||||
expect(exportDataXlsx).toContain("hasXlsxHeaderComments(columnInfos.map((column) => column.comment))");
|
||||
expect(exportDataXlsx.indexOf("await showSidebarTreeXlsxHeaderDialog(")).toBeLessThan(exportDataXlsx.indexOf('await exportTableData(target, "xlsx"'));
|
||||
});
|
||||
|
||||
it("falls back to field-name headers when column metadata is unavailable", () => {
|
||||
const exportDataXlsx = functionBody("exportDataXlsx");
|
||||
|
||||
expect(exportDataXlsx).toContain("// Export still works with field-name headers when column metadata is unavailable.");
|
||||
expect(exportDataXlsx).toContain('await exportTableData(target, "xlsx"');
|
||||
});
|
||||
|
||||
it("sends the selected mode's header overrides to both XLSX export paths", () => {
|
||||
const exportTableData = functionBody("exportTableData");
|
||||
|
||||
expect(exportTableData).toContain("buildXlsxHeaderOverrides(result.columns, comments, headerMode)");
|
||||
expect(exportTableData).toContain("columnComments,");
|
||||
});
|
||||
|
||||
it("keeps the original table and export options when selection changes during XLSX preparation", async () => {
|
||||
const metadata = deferred<ColumnInfo[]>();
|
||||
apiMock.getColumns.mockReturnValueOnce(metadata.promise);
|
||||
|
||||
Reference in new issue
Block a user