mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 16:20:25 +00:00
* fix: carry folder display names through fork deploy and diff Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: fold the folder display name check into the existing deploy test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: carry resource types' file settings and resources' type through fork deploy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump windmill-utils-internal to 1.8.6 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: document folder display_name in the api and pick up windmill-utils-internal 1.8.6 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
3.9 KiB
TypeScript
124 lines
3.9 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { deployItem } from "../windmill-utils-internal/src/deploy.ts";
|
|
|
|
// Variables, resources and folders are deployed from a body built field by field rather than
|
|
// spread from the source item, so any field left out of it is silently dropped in the target.
|
|
test("deployItem: carries labels for variables, resources and folders", async () => {
|
|
const labels = ["prod", "billing"];
|
|
const writes: [string, any][] = [];
|
|
const provider = (exists: boolean) =>
|
|
({
|
|
existsVariable: async () => exists,
|
|
existsResource: async () => exists,
|
|
existsFolder: async () => exists,
|
|
getVariable: async () => ({ value: "v", is_secret: false, labels }),
|
|
getResource: async () => ({
|
|
value: {},
|
|
resource_type: "postgresql",
|
|
labels,
|
|
}),
|
|
getFolder: async () => ({
|
|
name: "x",
|
|
display_name: "X folder",
|
|
owners: [],
|
|
extra_perms: {},
|
|
labels,
|
|
}),
|
|
...Object.fromEntries(
|
|
[
|
|
"createVariable",
|
|
"updateVariable",
|
|
"createResource",
|
|
"updateResource",
|
|
"createFolder",
|
|
"updateFolder",
|
|
].map((fn) => [
|
|
fn,
|
|
async (p: any) => void writes.push([fn, p.requestBody]),
|
|
]),
|
|
),
|
|
}) as any;
|
|
|
|
for (const exists of [false, true]) {
|
|
for (const [kind, path] of [
|
|
["variable", "f/x/v"],
|
|
["resource", "f/x/r"],
|
|
["folder", "f/x"],
|
|
]) {
|
|
const result = await deployItem(
|
|
provider(exists),
|
|
kind as any,
|
|
path,
|
|
"src",
|
|
"dst",
|
|
);
|
|
expect(result).toEqual({ success: true });
|
|
}
|
|
}
|
|
|
|
expect(writes.map(([fn]) => fn).sort()).toEqual([
|
|
"createFolder",
|
|
"createResource",
|
|
"createVariable",
|
|
"updateFolder",
|
|
"updateResource",
|
|
"updateVariable",
|
|
]);
|
|
for (const [, body] of writes) expect(body.labels).toEqual(labels);
|
|
// The compare page flags a folder whose display name differs, so dropping it leaves a
|
|
// conflict no deploy can clear.
|
|
for (const [fn, body] of writes) {
|
|
if (fn.endsWith("Folder")) expect(body.display_name).toEqual("X folder");
|
|
if (fn.endsWith("Resource")) expect(body.resource_type).toEqual("postgresql");
|
|
}
|
|
});
|
|
|
|
test("deployItem: carries a resource type's file settings and clears unset ones", async () => {
|
|
const bodies: Record<string, any> = {};
|
|
const deploy = (exists: boolean, rt: any) =>
|
|
deployItem(
|
|
{
|
|
existsResourceType: async () => exists,
|
|
getResourceType: async () => rt,
|
|
createResourceType: async (p: any) => void (bodies.create = p.requestBody),
|
|
updateResourceType: async (p: any) => void (bodies.update = p.requestBody),
|
|
} as any,
|
|
"resource_type",
|
|
"csv_file",
|
|
"src",
|
|
"dst",
|
|
);
|
|
for (const rt of [
|
|
{ name: "csv_file", schema: {}, format_extension: "csv" },
|
|
{ name: "csv_file", schema: {}, is_fileset: true },
|
|
]) {
|
|
await deploy(false, rt);
|
|
await deploy(true, rt);
|
|
for (const body of [bodies.create, bodies.update]) {
|
|
expect(body.format_extension ?? undefined).toEqual(rt.format_extension);
|
|
expect(body.is_fileset ?? false).toEqual(rt.is_fileset ?? false);
|
|
}
|
|
}
|
|
// A type that stopped being a file type reads back without the fields.
|
|
await deploy(true, { name: "csv_file", schema: {} });
|
|
expect(bodies.update.format_extension).toBeNull();
|
|
expect(bodies.update.is_fileset).toEqual(false);
|
|
});
|
|
|
|
test("deployItem: clears a folder's labels when the source has none", async () => {
|
|
let body: any;
|
|
await deployItem(
|
|
{
|
|
existsFolder: async () => true,
|
|
// A folder with cleared labels reads back without the field at all.
|
|
getFolder: async () => ({ name: "x", owners: [], extra_perms: {} }),
|
|
updateFolder: async (p: any) => void (body = p.requestBody),
|
|
} as any,
|
|
"folder",
|
|
"f/x",
|
|
"src",
|
|
"dst",
|
|
);
|
|
expect(body.labels).toEqual([]);
|
|
});
|