feat(export): support name and comment XLSX headers
This commit is contained in:
15 files changed
+171
-63
No files matched your search
@@ -13,8 +13,8 @@ const mocks = vi.hoisted(() => ({
|
||||
vi.mock("@/components/export/XlsxHeaderDialog.vue", () => ({
|
||||
default: {
|
||||
emits: ["confirm"],
|
||||
mounted(this: { $emit: (event: string, value: boolean) => void }) {
|
||||
queueMicrotask(() => this.$emit("confirm", true));
|
||||
mounted(this: { $emit: (event: string, value: string) => void }) {
|
||||
queueMicrotask(() => this.$emit("confirm", "name-comment"));
|
||||
},
|
||||
render() {
|
||||
return null;
|
||||
@@ -120,11 +120,23 @@ describe("useDataGridExport XLSX headers", () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("maps comments independently for every result sheet", async () => {
|
||||
it("maps combined headers independently for every result sheet", async () => {
|
||||
const state = useDataGridExport(createOptions());
|
||||
|
||||
await state.exportAllResultsXlsx();
|
||||
|
||||
expect(mocks.exportQueryResultsXlsx).toHaveBeenCalledWith(expect.any(String), expect.arrayContaining([expect.objectContaining({ sheetName: "Ids", columnComments: ["Identifier"] }), expect.objectContaining({ sheetName: "Names", columnComments: ["Display name"] })]));
|
||||
expect(mocks.exportQueryResultsXlsx).toHaveBeenCalledWith(expect.any(String), expect.arrayContaining([expect.objectContaining({ sheetName: "Ids", columnComments: ["id (Identifier)"] }), expect.objectContaining({ sheetName: "Names", columnComments: ["name (Display name)"] })]));
|
||||
});
|
||||
|
||||
it("uses ordinal result comments when single-table metadata is unavailable", async () => {
|
||||
const options = createOptions();
|
||||
options.tableMeta = computed(() => undefined);
|
||||
options.columnComments = computed(() => ["Joined identifier"]);
|
||||
options.allColumnComments = computed(() => ["Joined identifier"]);
|
||||
const state = useDataGridExport(options);
|
||||
|
||||
await state.exportAllResultsXlsx();
|
||||
|
||||
expect(mocks.exportQueryResultsXlsx).toHaveBeenCalledWith(expect.any(String), expect.arrayContaining([expect.objectContaining({ sheetName: "Ids", columnComments: ["id (Joined identifier)"] })]));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user