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,20 +1,9 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { EditorState } from "@codemirror/state";
|
||||
import { json } from "@codemirror/lang-json";
|
||||
import { foldable } from "@codemirror/language";
|
||||
|
||||
const redisJsonEditorSource = readFileSync(new URL("../../components/redis/RedisJsonEditor.vue", import.meta.url), "utf8");
|
||||
const cellDetailEditorSource = readFileSync(new URL("../useCellDetailEditor.ts", import.meta.url), "utf8");
|
||||
|
||||
describe("Redis JSON editor folding", () => {
|
||||
it("opts the Redis JSON editor into the shared folding controls", () => {
|
||||
expect(redisJsonEditorSource).toMatch(/language:\s*"json"[\s\S]*folding:\s*true/);
|
||||
expect(redisJsonEditorSource).toMatch(/lineNumbers:\s*props\.lineNumbers/);
|
||||
expect(cellDetailEditorSource).toContain("...(options.folding ? [foldGutter()] : []),");
|
||||
expect(cellDetailEditorSource).toContain("...(options.folding ? foldKeymap : []),");
|
||||
});
|
||||
|
||||
it("provides foldable ranges for JSON objects and arrays", () => {
|
||||
const state = EditorState.create({
|
||||
doc: `{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { useSaveSqlFolderSelection } from "@/composables/useSaveSqlFolderSelection";
|
||||
|
||||
@@ -12,8 +11,6 @@ function deferred<T>() {
|
||||
return { promise, resolve, reject };
|
||||
}
|
||||
|
||||
const appSource = readFileSync(new URL("../../App.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("save SQL folder selection", () => {
|
||||
it("keeps save and reselection blocked until folder creation completes", async () => {
|
||||
const creation = deferred<string>();
|
||||
@@ -24,9 +21,6 @@ describe("save SQL folder selection", () => {
|
||||
|
||||
expect(folder.pending.value).toBe(true);
|
||||
expect(folder.selection.value).toBe("existing-folder");
|
||||
expect(appSource).toContain("if (saveSqlFolderCreationPending.value) return;");
|
||||
expect(appSource).toContain(':disabled="saveSqlFolderCreationPending"');
|
||||
expect(appSource).toContain(':disabled="saveSqlFolderCreationPending || !saveSqlName.trim()"');
|
||||
|
||||
creation.resolve("created-folder");
|
||||
await pendingSelection;
|
||||
|
||||
@@ -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