fix(grid): show deleted row details in confirmation

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-08-20 20:49:47 +08:00
1 parent b3acf1e558
commit e2a4b26379
7 files changed
+284 -23

No files matched your search

@@ -0,0 +1,38 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const dataGridSource = readFileSync(new URL("../DataGrid.vue", import.meta.url), "utf8");
describe("DataGrid delete row confirmation details", () => {
it("still wires deleteRowDetails into the delete-row DangerConfirmDialog", () => {
const dialogStart = dataGridSource.indexOf('v-model:open="showDeleteRowConfirm"');
const dialogEnd = dataGridSource.indexOf('@confirm="confirmDeleteRow"', dialogStart);
expect(dialogStart).toBeGreaterThanOrEqual(0);
expect(dialogEnd).toBeGreaterThan(dialogStart);
const dialogSource = dataGridSource.slice(dialogStart, dialogEnd);
expect(dialogSource).toContain(':details="deleteRowDetails"');
});
it("uses the unbounded confirmation formatter for delete details", () => {
const detailsStart = dataGridSource.indexOf("const deleteRowDetails = computed");
const detailsEnd = dataGridSource.indexOf("const hasVisibleRows", detailsStart);
expect(detailsStart).toBeGreaterThanOrEqual(0);
expect(detailsEnd).toBeGreaterThan(detailsStart);
expect(dataGridSource.slice(detailsStart, detailsEnd)).toContain("formatGridItemCellForConfirmation");
expect(dataGridSource).toContain("formatCell(item.data[columnIndex], columnIndex, largeValueOriginalBytes(item, columnIndex), false)");
});
it("keeps close-on-confirm disabled so confirmDeleteRow runs before the dialog auto-closes", () => {
const dialogStart = dataGridSource.indexOf('v-model:open="showDeleteRowConfirm"');
const dialogEnd = dataGridSource.indexOf('@confirm="confirmDeleteRow"', dialogStart);
expect(dialogStart).toBeGreaterThanOrEqual(0);
expect(dialogEnd).toBeGreaterThan(dialogStart);
const dialogSource = dataGridSource.slice(dialogStart, dialogEnd);
expect(dialogSource).toContain(':close-on-confirm="false"');
});
});