@@ -142,12 +142,18 @@ describe("resolveMessagingTarget (directory fallback)", () => {
|
142 | 142 | { kind: "group", id: "replacement-id", name: "support" } satisfies ChannelDirectoryEntry, |
143 | 143 | ]); |
144 | 144 | const firstPlugin = { |
145 | | - ...createChannelTestPluginBase({ id: "richchat" }), |
| 145 | + ...createChannelTestPluginBase({ |
| 146 | +id: "richchat", |
| 147 | +capabilities: { chatTypes: ["group"] }, |
| 148 | +}), |
146 | 149 | directory: { listGroups: firstListGroups }, |
147 | 150 | messaging: { targetResolver: {} }, |
148 | 151 | } satisfies ChannelPlugin; |
149 | 152 | const replacementPlugin = { |
150 | | - ...createChannelTestPluginBase({ id: "richchat" }), |
| 153 | + ...createChannelTestPluginBase({ |
| 154 | +id: "richchat", |
| 155 | +capabilities: { chatTypes: ["group"] }, |
| 156 | +}), |
151 | 157 | directory: { listGroups: replacementListGroups }, |
152 | 158 | messaging: { targetResolver: {} }, |
153 | 159 | } satisfies ChannelPlugin; |
@@ -218,6 +224,37 @@ describe("resolveMessagingTarget (directory fallback)", () => {
|
218 | 224 | expect(mocks.listGroupsLive).not.toHaveBeenCalled(); |
219 | 225 | }); |
220 | 226 | |
| 227 | +it("defaults bare id-like targets to user for direct-only channel plugins", async () => { |
| 228 | +const directOnlyPlugin = { |
| 229 | + ...createChannelTestPluginBase({ |
| 230 | +id: "openclaw-weixin", |
| 231 | +capabilities: { chatTypes: ["direct"] }, |
| 232 | +}), |
| 233 | +messaging: { |
| 234 | +targetResolver: { |
| 235 | +looksLikeId: (raw: string) => raw.endsWith("@im.wechat"), |
| 236 | +}, |
| 237 | +}, |
| 238 | +} satisfies ChannelPlugin; |
| 239 | + |
| 240 | +const result = await expectOkResolution({ |
| 241 | + cfg, |
| 242 | +channel: "openclaw-weixin", |
| 243 | +input: "wxid_abc123@im.wechat", |
| 244 | +plugin: directOnlyPlugin, |
| 245 | +}); |
| 246 | + |
| 247 | +expect(result.target).toEqual({ |
| 248 | +to: "wxid_abc123@im.wechat", |
| 249 | +kind: "user", |
| 250 | +display: "wxid_abc123@im.wechat", |
| 251 | +source: "normalized", |
| 252 | +resolutionSource: "normalized", |
| 253 | +}); |
| 254 | +expect(mocks.listGroups).not.toHaveBeenCalled(); |
| 255 | +expect(mocks.listGroupsLive).not.toHaveBeenCalled(); |
| 256 | +}); |
| 257 | + |
221 | 258 | it("uses catalog plugin target grammar for unloaded numeric topic ids", async () => { |
222 | 259 | mocks.getLoadedChannelPlugin.mockReturnValue(undefined); |
223 | 260 | mocks.getChannelPlugin.mockReturnValue({ |
|