mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 08:02:38 +00:00
* fix: keep instance groups when editing auto-invite and push them from sync Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: compare settings.yaml without undeclared instance groups on push Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix: read a missing auto_invite as empty when diffing settings.yaml on push Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: update ee-repo-ref to f2fced19fcae81de7f6dac545010ce404c052e1b This commit updates the EE repository reference after PR #813 was merged in windmill-ee-private. Previous ee-repo-ref: cf4258c1232720ca3b82db2b22ea1fb4bca9533e New ee-repo-ref: f2fced19fcae81de7f6dac545010ce404c052e1b Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
/**
|
|
* Regression guard: `sync push` (pushWorkspaceSettings) applies the domain invite and
|
|
* the instance groups of `auto_invite` through their own endpoints, and never clears
|
|
* instance groups that settings.yaml does not declare.
|
|
*/
|
|
|
|
import { expect, test, describe, beforeEach, mock } from "bun:test";
|
|
|
|
let editAutoInviteCalls: unknown[] = [];
|
|
let editInstanceGroupsCalls: unknown[] = [];
|
|
const remoteAutoInvite = {
|
|
enabled: true,
|
|
domain: "*",
|
|
operator: false,
|
|
mode: "invite",
|
|
instance_groups: ["eng"],
|
|
instance_groups_roles: { eng: "developer" },
|
|
};
|
|
|
|
// Every wmill.* call reachable from pushWorkspaceSettings is stubbed: bun shares one
|
|
// mocked module across test files, and names missing from whichever mock loads first
|
|
// stay missing for the others.
|
|
mock.module("../gen/services.gen.ts", () => ({
|
|
getSettings: async () => ({ auto_invite: remoteAutoInvite }),
|
|
getWorkspaceName: async () => "phoenix",
|
|
changeWorkspaceName: async () => {},
|
|
changeWorkspaceColor: async () => {},
|
|
editWebhook: async () => {},
|
|
editAutoInvite: async (a: unknown) => {
|
|
editAutoInviteCalls.push(a);
|
|
},
|
|
editInstanceGroups: async (a: unknown) => {
|
|
editInstanceGroupsCalls.push(a);
|
|
},
|
|
editErrorHandler: async () => {},
|
|
editSuccessHandler: async () => {},
|
|
editCopilotConfig: async () => {},
|
|
editLargeFileStorageConfig: async () => {},
|
|
editWorkspaceGitSyncConfig: async () => {},
|
|
editWorkspaceDefaultApp: async () => {},
|
|
editDefaultScripts: async () => {},
|
|
workspaceMuteCriticalAlertsUi: async () => {},
|
|
updateOperatorSettings: async () => {},
|
|
editDataTableConfig: async () => {},
|
|
editSlackCommand: async () => {},
|
|
setWorkspaceSlackOauthConfig: async () => {},
|
|
deleteWorkspaceSlackOauthConfig: async () => {},
|
|
}));
|
|
|
|
const { pushWorkspaceSettings } = await import("../src/core/settings.ts");
|
|
|
|
describe("pushWorkspaceSettings auto_invite", () => {
|
|
beforeEach(() => {
|
|
editAutoInviteCalls = [];
|
|
editInstanceGroupsCalls = [];
|
|
});
|
|
|
|
test("an instance-group-only change updates the groups and leaves the domain invite", async () => {
|
|
await pushWorkspaceSettings("phoenix", "settings", undefined, {
|
|
name: "phoenix",
|
|
auto_invite: { ...remoteAutoInvite, instance_groups_roles: { eng: "admin" } },
|
|
});
|
|
expect(editAutoInviteCalls.length).toBe(0);
|
|
expect(editInstanceGroupsCalls).toEqual([
|
|
{
|
|
workspace: "phoenix",
|
|
requestBody: { groups: ["eng"], roles: { eng: "admin" } },
|
|
},
|
|
]);
|
|
});
|
|
|
|
test("a settings.yaml without instance_groups does not clear them", async () => {
|
|
const { instance_groups: _g, instance_groups_roles: _r, ...domainInvite } =
|
|
remoteAutoInvite;
|
|
await pushWorkspaceSettings("phoenix", "settings", undefined, {
|
|
name: "phoenix",
|
|
auto_invite: { ...domainInvite, operator: true },
|
|
});
|
|
expect(editAutoInviteCalls.length).toBe(1);
|
|
expect(editInstanceGroupsCalls.length).toBe(0);
|
|
});
|
|
});
|