mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 00:50:27 +00:00
refactor: deduplicate setup wizard helpers
This commit is contained in:
@@ -110,6 +110,54 @@ describe("createScopedChannelConfigBase", () => {
|
||||
}).channels,
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("can force default account config into accounts.default", () => {
|
||||
const base = createScopedChannelConfigBase({
|
||||
sectionKey: "demo",
|
||||
listAccountIds: () => ["default", "alt"],
|
||||
resolveAccount: (_cfg, accountId) => ({ accountId: accountId ?? "default" }),
|
||||
defaultAccountId: () => "default",
|
||||
clearBaseFields: [],
|
||||
allowTopLevel: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
base.setAccountEnabled!({
|
||||
cfg: {
|
||||
channels: {
|
||||
demo: {
|
||||
token: "secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
}).channels?.demo,
|
||||
).toEqual({
|
||||
token: "secret",
|
||||
accounts: {
|
||||
default: { enabled: true },
|
||||
},
|
||||
});
|
||||
expect(
|
||||
base.deleteAccount!({
|
||||
cfg: {
|
||||
channels: {
|
||||
demo: {
|
||||
token: "secret",
|
||||
accounts: {
|
||||
default: { enabled: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: "default",
|
||||
}).channels?.demo,
|
||||
).toEqual({
|
||||
token: "secret",
|
||||
accounts: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("createScopedDmSecurityResolver", () => {
|
||||
|
||||
@@ -35,6 +35,7 @@ export {
|
||||
buildSingleChannelSecretPromptState,
|
||||
createAccountScopedAllowFromSection,
|
||||
createAccountScopedGroupAccessSection,
|
||||
createAllowFromSection,
|
||||
createLegacyCompatChannelDmPolicy,
|
||||
createNestedChannelAllowFromSetter,
|
||||
createNestedChannelDmPolicy,
|
||||
@@ -55,13 +56,16 @@ export {
|
||||
patchChannelConfigForAccount,
|
||||
promptLegacyChannelAllowFrom,
|
||||
promptLegacyChannelAllowFromForAccount,
|
||||
promptParsedAllowFromForAccount,
|
||||
promptParsedAllowFromForScopedChannel,
|
||||
promptSingleChannelSecretInput,
|
||||
promptResolvedAllowFrom,
|
||||
resolveParsedAllowFromEntries,
|
||||
resolveEntriesWithOptionalToken,
|
||||
resolveSetupAccountId,
|
||||
resolveGroupAllowlistWithLookupNotes,
|
||||
runSingleChannelSecretStep,
|
||||
setAccountAllowFromForChannel,
|
||||
setAccountDmAllowFromForChannel,
|
||||
setAccountGroupPolicyForChannel,
|
||||
setChannelDmPolicyWithAllowFrom,
|
||||
@@ -75,5 +79,17 @@ export {
|
||||
splitSetupEntries,
|
||||
} from "../channels/plugins/setup-wizard-helpers.js";
|
||||
export { createAllowlistSetupWizardProxy } from "../channels/plugins/setup-wizard-proxy.js";
|
||||
export {
|
||||
createDelegatedFinalize,
|
||||
createDelegatedPrepare,
|
||||
createDelegatedResolveConfigured,
|
||||
createDelegatedSetupWizardProxy,
|
||||
} from "../channels/plugins/setup-wizard-proxy.js";
|
||||
export {
|
||||
createCliPathTextInput,
|
||||
createDelegatedSetupWizardStatusResolvers,
|
||||
createDelegatedTextInputShouldPrompt,
|
||||
createDetectedBinaryStatus,
|
||||
} from "../channels/plugins/setup-wizard-binary.js";
|
||||
|
||||
export { formatResolvedUnresolvedNote } from "./resolution-notes.js";
|
||||
|
||||
@@ -99,6 +99,15 @@ describe("plugin-sdk subpath exports", () => {
|
||||
expect(typeof setupSdk.DEFAULT_ACCOUNT_ID).toBe("string");
|
||||
expect(typeof setupSdk.createAccountScopedAllowFromSection).toBe("function");
|
||||
expect(typeof setupSdk.createAccountScopedGroupAccessSection).toBe("function");
|
||||
expect(typeof setupSdk.createAllowFromSection).toBe("function");
|
||||
expect(typeof setupSdk.createCliPathTextInput).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedFinalize).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedPrepare).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedResolveConfigured).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedSetupWizardProxy).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedSetupWizardStatusResolvers).toBe("function");
|
||||
expect(typeof setupSdk.createDelegatedTextInputShouldPrompt).toBe("function");
|
||||
expect(typeof setupSdk.createDetectedBinaryStatus).toBe("function");
|
||||
expect(typeof setupSdk.createLegacyCompatChannelDmPolicy).toBe("function");
|
||||
expect(typeof setupSdk.createNestedChannelDmPolicy).toBe("function");
|
||||
expect(typeof setupSdk.createTopLevelChannelDmPolicy).toBe("function");
|
||||
@@ -107,7 +116,10 @@ describe("plugin-sdk subpath exports", () => {
|
||||
expect(typeof setupSdk.mergeAllowFromEntries).toBe("function");
|
||||
expect(typeof setupSdk.patchNestedChannelConfigSection).toBe("function");
|
||||
expect(typeof setupSdk.patchTopLevelChannelConfigSection).toBe("function");
|
||||
expect(typeof setupSdk.promptParsedAllowFromForAccount).toBe("function");
|
||||
expect(typeof setupSdk.resolveParsedAllowFromEntries).toBe("function");
|
||||
expect(typeof setupSdk.resolveGroupAllowlistWithLookupNotes).toBe("function");
|
||||
expect(typeof setupSdk.setAccountAllowFromForChannel).toBe("function");
|
||||
expect(typeof setupSdk.setAccountDmAllowFromForChannel).toBe("function");
|
||||
expect(typeof setupSdk.setTopLevelChannelDmPolicyWithAllowFrom).toBe("function");
|
||||
expect(typeof setupSdk.formatResolvedUnresolvedNote).toBe("function");
|
||||
|
||||
Reference in New Issue
Block a user