1.2.0-rc1

This commit is contained in:
michael committed 2026-10-15 08:09:47 +02:00
1 parent 45ff46b7eb
commit fa9c122250
30 files changed
+6354 -989

No files matched your search

+24 -2
View File
@@ -1,9 +1,17 @@
import assert from "node:assert/strict";
import test from "node:test";
import { nextSequenceIdAfterRestore, restoreSqlText, sequenceSetvalSql, sqlLiteral, type QueryExecutor } from "../src/databaseExport.ts";
import { exportTableSql } from "../src/databaseExport.ts";
import {
databaseExportTables,
exportTableSql,
nextSequenceIdAfterRestore,
restoreSqlText,
sequenceSetvalSql,
sqlLiteral,
type QueryExecutor
} from "../src/databaseExport.ts";
const jsonbColumn = { dataType: "jsonb", udtName: "jsonb" };
const bigintArrayColumn = { dataType: "ARRAY", udtName: "_int8" };
test("sqlLiteral serializes primitive values", () => {
assert.equal(sqlLiteral(null), "NULL");
@@ -36,6 +44,20 @@ test("sqlLiteral serializes JSON columns as valid JSON values", () => {
assert.equal(sqlLiteral(true, jsonbColumn), "'true'");
});
test("sqlLiteral serializes PostgreSQL arrays with an explicit element type", () => {
assert.equal(sqlLiteral([], bigintArrayColumn), "ARRAY[]::bigint[]");
assert.equal(sqlLiteral(["32349965", "32349982"], bigintArrayColumn), "ARRAY['32349965', '32349982']::bigint[]");
assert.throws(
() => sqlLiteral(["value"], { dataType: "ARRAY", udtName: "_unsupported" }),
/Unsupported PostgreSQL array type/
);
});
test("database export inserts assignment rules before tickets that reference them", () => {
assert.ok(databaseExportTables.indexOf("organization_attribute_options") < databaseExportTables.indexOf("teamspace_assignment_rules"));
assert.ok(databaseExportTables.indexOf("teamspace_assignment_rules") < databaseExportTables.indexOf("tickets"));
});
test("generated table export never contains implicit object stringification", async () => {
const client: QueryExecutor = {
async query<T extends Record<string, unknown>>(text: string): Promise<{ rows: T[]; rowCount: number | null }> {
@@ -0,0 +1,38 @@
import assert from "node:assert/strict";
import test from "node:test";
import { parseZammadOrganizationAttributeOptions } from "../src/zammadOrganizationAttributes.ts";
test("parses the two organization select attributes and ignores unrelated attributes", () => {
const options = parseZammadOrganizationAttributeOptions([
{
id: 85,
name: "customer_owner",
data_option: { options: { ATOSS: "ATOSS", sdw: "SD Worx" } }
},
{
id: 12,
name: "unrelated",
data_option: { options: { no: "No" } }
},
{
id: 86,
name: "hotline_contract",
data_option: { options: { none: "(kein Hotlinevertrag)" } }
}
]);
assert.deepEqual(options, [
{ zammadAttributeId: 85, attributeName: "customer_owner", optionKey: "ATOSS", displayName: "ATOSS" },
{ zammadAttributeId: 85, attributeName: "customer_owner", optionKey: "sdw", displayName: "SD Worx" },
{ zammadAttributeId: 86, attributeName: "hotline_contract", optionKey: "none", displayName: "(kein Hotlinevertrag)" }
]);
});
test("rejects responses without both required attributes", () => {
assert.throws(
() => parseZammadOrganizationAttributeOptions([
{ id: 85, name: "customer_owner", data_option: { options: { ATOSS: "ATOSS" } } }
]),
/hotline_contract/
);
});