fix(sql-file): open and save custom-filtered text files

This commit is contained in:
zipg authored and GitHub committed 2026-09-02 11:55:00 +08:00
1 parent d3a6a69796
commit 9b6f3c48e4
8 files changed
+113 -58

No files matched your search

+6 -1
View File
@@ -1,13 +1,18 @@
// @vitest-environment happy-dom
import { describe, expect, it } from "vitest";
import { ExternalSqlFileTooLargeError, externalSqlFileDisplayTitles, externalSqlFileOpenErrorMessage, formatSqlFileSize, MAX_EXTERNAL_SQL_EDITOR_FILE_BYTES, normalizeExternalSqlPath, readBrowserSqlFile } from "@/lib/sql/sqlFileOpen";
import { ExternalSqlFileTooLargeError, externalSqlFileDisplayTitles, externalSqlFileOpenErrorMessage, formatSqlFileSize, isSqlFilePath, MAX_EXTERNAL_SQL_EDITOR_FILE_BYTES, normalizeExternalSqlPath, readBrowserSqlFile } from "@/lib/sql/sqlFileOpen";
describe("external SQL file paths", () => {
it("normalizes Windows separators for identity checks", () => {
expect(normalizeExternalSqlPath(" C:\\work\\demo.sql ")).toBe("C:/work/demo.sql");
});
it("distinguishes SQL files from other filtered text files", () => {
expect(isSqlFilePath("C:\\work\\demo.SQL")).toBe(true);
expect(isSqlFilePath("/work/script.py")).toBe(false);
});
it("uses the shortest unique parent path for duplicate filenames", () => {
expect(externalSqlFileDisplayTitles(["/work/demo/create.sql", "/work/learn/create.sql", "/work/query.sql"])).toEqual(["demo/create.sql", "learn/create.sql", "query.sql"]);
});