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
-72
@@ -1,20 +1,11 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { test } from "vitest";
|
||||
import { compileScript, parse } from "vue/compiler-sfc";
|
||||
import { createDataGridCellContextMenuItems } from "../../apps/desktop/src/lib/dataGrid/dataGridContextMenu";
|
||||
|
||||
const dataGridPath = "apps/desktop/src/components/grid/DataGrid.vue";
|
||||
const dataGridSource = readFileSync(dataGridPath, "utf8");
|
||||
|
||||
test("DataGrid context menu script compiles", () => {
|
||||
const { descriptor, errors } = parse(dataGridSource, { filename: dataGridPath });
|
||||
|
||||
assert.deepEqual(errors, []);
|
||||
assert.ok(descriptor.scriptSetup);
|
||||
compileScript(descriptor, { id: "data-grid-context-menu-test" });
|
||||
});
|
||||
|
||||
test("set NULL applies a real null value only to editable selections", () => {
|
||||
const handler = dataGridSource.match(/function setSelectionNull\(\) \{[^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
@@ -23,69 +14,6 @@ test("set NULL applies a real null value only to editable selections", () => {
|
||||
assert.doesNotMatch(handler, /fillSelectionWithValue\(["'](?:NULL)?["']\)/);
|
||||
});
|
||||
|
||||
test("generated selection values restore grid focus for keyboard shortcuts", () => {
|
||||
const applyHandler = dataGridSource.match(/function applyGeneratedSelectionValue\([^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.match(applyHandler, /if \(applied\)[^]*nextTick\(\(\) => window\.requestAnimationFrame\(\(\) => gridRef\.value\?\.focus\(\{ preventScroll: true \}\)\)\)/);
|
||||
});
|
||||
|
||||
test("column-header context menus defer copy statement generation", () => {
|
||||
const handler = dataGridSource.match(/function onHeaderContext\([^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.doesNotMatch(handler, /prefetchCopyStatements/);
|
||||
});
|
||||
|
||||
test("context-menu invalidation clears cell and header targets together", () => {
|
||||
const handler = dataGridSource.match(/function invalidateContextMenuTarget\(\) \{[^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.match(handler, /contextSelectionIsSynthetic\.value = false;/);
|
||||
assert.match(handler, /contextCell\.value = null;/);
|
||||
assert.match(handler, /contextHeaderColumn\.value = null;/);
|
||||
assert.match(handler, /contextHeaderColumnIndex\.value = null;/);
|
||||
assert.match(handler, /contextHeaderVisibleColIdx\.value = null;/);
|
||||
});
|
||||
|
||||
test("header context menu wires batch hide and show-all to the column layout pipeline", () => {
|
||||
assert.match(dataGridSource, /hideColumn: hideContextColumn,/);
|
||||
assert.match(dataGridSource, /hideSelectedColumns,/);
|
||||
assert.match(dataGridSource, /showAllColumnsMenu: showAllColumns,/);
|
||||
assert.match(dataGridSource, /hiddenColumnCount: hiddenColumnCount\.value,/);
|
||||
|
||||
const hideWrapper = dataGridSource.match(/function hideColumns\(columnIndexes: number\[\]\) \{[^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.match(hideWrapper, /applyColumnOrderChange\(\(\) => hideColumnsInLayout\(columnIndexes\)\)/);
|
||||
assert.match(hideWrapper, /clearCellSelection\(\);/);
|
||||
assert.match(hideWrapper, /clampGridHorizontalScroll\(\)/);
|
||||
|
||||
// 显示全部列也走 applyColumnOrderChange,隐藏期间产生的可见索引偏移会被重新对齐。
|
||||
const showAllWrapper = dataGridSource.match(/function showAllColumns\(\) \{[^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.match(showAllWrapper, /applyColumnOrderChange\(showAllColumnsInLayout\)/);
|
||||
});
|
||||
|
||||
test("select-all context menus invalidate a stale specialized target", () => {
|
||||
const header = dataGridSource.match(/<div\s+class="data-grid-header-cell shrink-0 px-2 py-1\.5[^]*?@click="selectAllCells"[^]*?>/u)?.[0] ?? "";
|
||||
|
||||
assert.match(header, /@contextmenu="invalidateContextMenuTarget"/);
|
||||
});
|
||||
|
||||
test("right-clicking outside the old cell or column selection resets it before selecting the target", () => {
|
||||
const handler = dataGridSource.match(/function onCellContext\([^]*?\n\}/)?.[0] ?? "";
|
||||
const clear = handler.indexOf("clearCellSelection();");
|
||||
const select = handler.indexOf("selectSingleCell(rowIndex, visibleColIdx);");
|
||||
|
||||
assert.ok(clear >= 0);
|
||||
assert.ok(clear < select);
|
||||
});
|
||||
|
||||
test("menu-close invalidation is deferred and guarded from a newer open", () => {
|
||||
const handler = dataGridSource.match(/function onGridContextMenuClose\(\) \{[^]*?\n\}/)?.[0] ?? "";
|
||||
|
||||
assert.match(handler, /queueMicrotask\(\(\) => \{/);
|
||||
assert.match(handler, /if \(lifecycle !== contextMenuLifecycle\) return;/);
|
||||
assert.match(handler, /invalidateContextMenuTarget\(\);/);
|
||||
});
|
||||
|
||||
test("editable cell selections expose generation after bulk edit", () => {
|
||||
const icon = {};
|
||||
const action = () => {};
|
||||
|
||||
Reference in new issue
Block a user