mirror of https://github.com/openclaw/openclaw.git
test: narrow telegram setup prepare result
Regeneration-Prompt: | During PR #27727 prepare, rebasing onto current main exposed a pnpm check failure in extensions/telegram/src/setup-surface.test.ts because telegramSetupWizard.prepare is optional and the test accessed prepared.cfg without proving the result exists. Keep runtime behavior unchanged. Add the smallest test-side assertion/helper needed to narrow the optional prepare result before reading cfg, then rerun the full prepare gates on the refreshed prep branch.
This commit is contained in:
parent
098f0f3d13
commit
a7ab64e394
|
|
@ -31,40 +31,62 @@ async function runFinalize(cfg: OpenClawConfig, accountId: string) {
|
|||
return prompter.note;
|
||||
}
|
||||
|
||||
function expectPreparedResult(
|
||||
prepared: Awaited<ReturnType<typeof runPrepare>>,
|
||||
): { cfg: OpenClawConfig } & Exclude<Awaited<ReturnType<typeof runPrepare>>, void | undefined> {
|
||||
expect(prepared).toBeDefined();
|
||||
if (
|
||||
!prepared ||
|
||||
typeof prepared !== "object" ||
|
||||
!("cfg" in prepared) ||
|
||||
prepared.cfg === undefined
|
||||
) {
|
||||
throw new Error("Expected prepare result with cfg");
|
||||
}
|
||||
return prepared as { cfg: OpenClawConfig } & Exclude<
|
||||
Awaited<ReturnType<typeof runPrepare>>,
|
||||
void | undefined
|
||||
>;
|
||||
}
|
||||
|
||||
describe("telegramSetupWizard.prepare", () => {
|
||||
it('adds groups["*"].requireMention=true for fresh setups', async () => {
|
||||
const prepared = await runPrepare(
|
||||
{
|
||||
channels: {
|
||||
telegram: {
|
||||
botToken: "tok",
|
||||
const prepared = expectPreparedResult(
|
||||
await runPrepare(
|
||||
{
|
||||
channels: {
|
||||
telegram: {
|
||||
botToken: "tok",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
),
|
||||
);
|
||||
|
||||
expect(prepared?.cfg.channels?.telegram?.groups).toEqual({
|
||||
expect(prepared.cfg.channels?.telegram?.groups).toEqual({
|
||||
"*": { requireMention: true },
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves an explicit wildcard group mention setting", async () => {
|
||||
const prepared = await runPrepare(
|
||||
{
|
||||
channels: {
|
||||
telegram: {
|
||||
botToken: "tok",
|
||||
groups: {
|
||||
"*": { requireMention: false },
|
||||
const prepared = expectPreparedResult(
|
||||
await runPrepare(
|
||||
{
|
||||
channels: {
|
||||
telegram: {
|
||||
botToken: "tok",
|
||||
groups: {
|
||||
"*": { requireMention: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
),
|
||||
);
|
||||
|
||||
expect(prepared?.cfg.channels?.telegram?.groups).toEqual({
|
||||
expect(prepared.cfg.channels?.telegram?.groups).toEqual({
|
||||
"*": { requireMention: false },
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue