@symerian/symi 3.0.20 → 3.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{audio-preflight-BaCdNfrk.js → audio-preflight-D7BVT-ls.js} +4 -4
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{chrome-UfmVM0xR.js → chrome-B5CO2vB5.js} +7 -7
- package/dist/{deliver-BqXdac6W.js → deliver-CrwjsDwv.js} +1 -1
- package/dist/extensionAPI.js +7 -7
- package/dist/{image-DIWsXYcW.js → image-Csu7WcLW.js} +1 -1
- package/dist/{manager-DW3SxcPr.js → manager-BkkVjTO8.js} +1 -1
- package/dist/{pi-embedded-BNch0U5F.js → pi-embedded-Dhp64z5l.js} +16 -16
- package/dist/{pi-embedded-helpers-IkHl02JF.js → pi-embedded-helpers-840E4hop.js} +4 -4
- package/dist/{pw-ai-nMkA-oDJ.js → pw-ai-CBgJf_RR.js} +1 -1
- package/dist/{runner-DNEC58JI.js → runner-BbFKo1ne.js} +1 -1
- package/dist/{synthesis-BWAr0sZ9.js → synthesis-DoEM0E8_.js} +7 -7
- package/dist/{web-7a-m_UxL.js → web-BYXJn-Ps.js} +7 -7
- package/package.json +1 -1
- package/extensions/imessage/index.ts +0 -17
- package/extensions/imessage/node_modules/.bin/symi +0 -21
- package/extensions/imessage/package.json +0 -15
- package/extensions/imessage/src/channel.outbound.test.ts +0 -66
- package/extensions/imessage/src/channel.ts +0 -298
- package/extensions/imessage/src/runtime.ts +0 -14
- package/extensions/imessage/symi.plugin.json +0 -9
- package/extensions/line/index.ts +0 -19
- package/extensions/line/node_modules/.bin/symi +0 -21
- package/extensions/line/package.json +0 -30
- package/extensions/line/src/card-command.ts +0 -344
- package/extensions/line/src/channel.logout.test.ts +0 -133
- package/extensions/line/src/channel.sendPayload.test.ts +0 -312
- package/extensions/line/src/channel.startup.test.ts +0 -133
- package/extensions/line/src/channel.ts +0 -801
- package/extensions/line/src/runtime.ts +0 -14
- package/extensions/line/symi.plugin.json +0 -9
- package/extensions/signal/index.ts +0 -17
- package/extensions/signal/node_modules/.bin/symi +0 -21
- package/extensions/signal/package.json +0 -15
- package/extensions/signal/src/channel.ts +0 -302
- package/extensions/signal/src/runtime.ts +0 -14
- package/extensions/signal/symi.plugin.json +0 -9
- package/extensions/telegram/index.ts +0 -17
- package/extensions/telegram/node_modules/.bin/symi +0 -21
- package/extensions/telegram/package.json +0 -15
- package/extensions/telegram/src/channel.test.ts +0 -125
- package/extensions/telegram/src/channel.ts +0 -560
- package/extensions/telegram/src/runtime.ts +0 -14
- package/extensions/telegram/symi.plugin.json +0 -9
- package/extensions/whatsapp/index.ts +0 -17
- package/extensions/whatsapp/node_modules/.bin/symi +0 -21
- package/extensions/whatsapp/package.json +0 -15
- package/extensions/whatsapp/src/channel.ts +0 -465
- package/extensions/whatsapp/src/resolve-target.test.ts +0 -170
- package/extensions/whatsapp/src/runtime.ts +0 -14
- package/extensions/whatsapp/symi.plugin.json +0 -9
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
import type { SymiConfig, PluginRuntime } from "symi/plugin-sdk";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { linePlugin } from "./channel.js";
|
|
4
|
-
import { setLineRuntime } from "./runtime.js";
|
|
5
|
-
|
|
6
|
-
type LineRuntimeMocks = {
|
|
7
|
-
pushMessageLine: ReturnType<typeof vi.fn>;
|
|
8
|
-
pushMessagesLine: ReturnType<typeof vi.fn>;
|
|
9
|
-
pushFlexMessage: ReturnType<typeof vi.fn>;
|
|
10
|
-
pushTemplateMessage: ReturnType<typeof vi.fn>;
|
|
11
|
-
pushLocationMessage: ReturnType<typeof vi.fn>;
|
|
12
|
-
pushTextMessageWithQuickReplies: ReturnType<typeof vi.fn>;
|
|
13
|
-
createQuickReplyItems: ReturnType<typeof vi.fn>;
|
|
14
|
-
buildTemplateMessageFromPayload: ReturnType<typeof vi.fn>;
|
|
15
|
-
sendMessageLine: ReturnType<typeof vi.fn>;
|
|
16
|
-
chunkMarkdownText: ReturnType<typeof vi.fn>;
|
|
17
|
-
resolveLineAccount: ReturnType<typeof vi.fn>;
|
|
18
|
-
resolveTextChunkLimit: ReturnType<typeof vi.fn>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
function createRuntime(): { runtime: PluginRuntime; mocks: LineRuntimeMocks } {
|
|
22
|
-
const pushMessageLine = vi.fn(async () => ({ messageId: "m-text", chatId: "c1" }));
|
|
23
|
-
const pushMessagesLine = vi.fn(async () => ({ messageId: "m-batch", chatId: "c1" }));
|
|
24
|
-
const pushFlexMessage = vi.fn(async () => ({ messageId: "m-flex", chatId: "c1" }));
|
|
25
|
-
const pushTemplateMessage = vi.fn(async () => ({ messageId: "m-template", chatId: "c1" }));
|
|
26
|
-
const pushLocationMessage = vi.fn(async () => ({ messageId: "m-loc", chatId: "c1" }));
|
|
27
|
-
const pushTextMessageWithQuickReplies = vi.fn(async () => ({
|
|
28
|
-
messageId: "m-quick",
|
|
29
|
-
chatId: "c1",
|
|
30
|
-
}));
|
|
31
|
-
const createQuickReplyItems = vi.fn((labels: string[]) => ({ items: labels }));
|
|
32
|
-
const buildTemplateMessageFromPayload = vi.fn(() => ({ type: "buttons" }));
|
|
33
|
-
const sendMessageLine = vi.fn(async () => ({ messageId: "m-media", chatId: "c1" }));
|
|
34
|
-
const chunkMarkdownText = vi.fn((text: string) => [text]);
|
|
35
|
-
const resolveTextChunkLimit = vi.fn(() => 123);
|
|
36
|
-
const resolveLineAccount = vi.fn(
|
|
37
|
-
({ cfg, accountId }: { cfg: SymiConfig; accountId?: string }) => {
|
|
38
|
-
const resolved = accountId ?? "default";
|
|
39
|
-
const lineConfig = (cfg.channels?.line ?? {}) as {
|
|
40
|
-
accounts?: Record<string, Record<string, unknown>>;
|
|
41
|
-
};
|
|
42
|
-
const accountConfig = resolved !== "default" ? (lineConfig.accounts?.[resolved] ?? {}) : {};
|
|
43
|
-
return {
|
|
44
|
-
accountId: resolved,
|
|
45
|
-
config: { ...lineConfig, ...accountConfig },
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const runtime = {
|
|
51
|
-
channel: {
|
|
52
|
-
line: {
|
|
53
|
-
pushMessageLine,
|
|
54
|
-
pushMessagesLine,
|
|
55
|
-
pushFlexMessage,
|
|
56
|
-
pushTemplateMessage,
|
|
57
|
-
pushLocationMessage,
|
|
58
|
-
pushTextMessageWithQuickReplies,
|
|
59
|
-
createQuickReplyItems,
|
|
60
|
-
buildTemplateMessageFromPayload,
|
|
61
|
-
sendMessageLine,
|
|
62
|
-
resolveLineAccount,
|
|
63
|
-
},
|
|
64
|
-
text: {
|
|
65
|
-
chunkMarkdownText,
|
|
66
|
-
resolveTextChunkLimit,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
} as unknown as PluginRuntime;
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
runtime,
|
|
73
|
-
mocks: {
|
|
74
|
-
pushMessageLine,
|
|
75
|
-
pushMessagesLine,
|
|
76
|
-
pushFlexMessage,
|
|
77
|
-
pushTemplateMessage,
|
|
78
|
-
pushLocationMessage,
|
|
79
|
-
pushTextMessageWithQuickReplies,
|
|
80
|
-
createQuickReplyItems,
|
|
81
|
-
buildTemplateMessageFromPayload,
|
|
82
|
-
sendMessageLine,
|
|
83
|
-
chunkMarkdownText,
|
|
84
|
-
resolveLineAccount,
|
|
85
|
-
resolveTextChunkLimit,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
describe("linePlugin outbound.sendPayload", () => {
|
|
91
|
-
it("sends flex message without dropping text", async () => {
|
|
92
|
-
const { runtime, mocks } = createRuntime();
|
|
93
|
-
setLineRuntime(runtime);
|
|
94
|
-
const cfg = { channels: { line: {} } } as SymiConfig;
|
|
95
|
-
|
|
96
|
-
const payload = {
|
|
97
|
-
text: "Now playing:",
|
|
98
|
-
channelData: {
|
|
99
|
-
line: {
|
|
100
|
-
flexMessage: {
|
|
101
|
-
altText: "Now playing",
|
|
102
|
-
contents: { type: "bubble" },
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
await linePlugin.outbound!.sendPayload!({
|
|
109
|
-
to: "line:group:1",
|
|
110
|
-
text: payload.text,
|
|
111
|
-
payload,
|
|
112
|
-
accountId: "default",
|
|
113
|
-
cfg,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
expect(mocks.pushFlexMessage).toHaveBeenCalledTimes(1);
|
|
117
|
-
expect(mocks.pushMessageLine).toHaveBeenCalledWith("line:group:1", "Now playing:", {
|
|
118
|
-
verbose: false,
|
|
119
|
-
accountId: "default",
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("sends template message without dropping text", async () => {
|
|
124
|
-
const { runtime, mocks } = createRuntime();
|
|
125
|
-
setLineRuntime(runtime);
|
|
126
|
-
const cfg = { channels: { line: {} } } as SymiConfig;
|
|
127
|
-
|
|
128
|
-
const payload = {
|
|
129
|
-
text: "Choose one:",
|
|
130
|
-
channelData: {
|
|
131
|
-
line: {
|
|
132
|
-
templateMessage: {
|
|
133
|
-
type: "confirm",
|
|
134
|
-
text: "Continue?",
|
|
135
|
-
confirmLabel: "Yes",
|
|
136
|
-
confirmData: "yes",
|
|
137
|
-
cancelLabel: "No",
|
|
138
|
-
cancelData: "no",
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
await linePlugin.outbound!.sendPayload!({
|
|
145
|
-
to: "line:user:1",
|
|
146
|
-
text: payload.text,
|
|
147
|
-
payload,
|
|
148
|
-
accountId: "default",
|
|
149
|
-
cfg,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
expect(mocks.buildTemplateMessageFromPayload).toHaveBeenCalledTimes(1);
|
|
153
|
-
expect(mocks.pushTemplateMessage).toHaveBeenCalledTimes(1);
|
|
154
|
-
expect(mocks.pushMessageLine).toHaveBeenCalledWith("line:user:1", "Choose one:", {
|
|
155
|
-
verbose: false,
|
|
156
|
-
accountId: "default",
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("attaches quick replies when no text chunks are present", async () => {
|
|
161
|
-
const { runtime, mocks } = createRuntime();
|
|
162
|
-
setLineRuntime(runtime);
|
|
163
|
-
const cfg = { channels: { line: {} } } as SymiConfig;
|
|
164
|
-
|
|
165
|
-
const payload = {
|
|
166
|
-
channelData: {
|
|
167
|
-
line: {
|
|
168
|
-
quickReplies: ["One", "Two"],
|
|
169
|
-
flexMessage: {
|
|
170
|
-
altText: "Card",
|
|
171
|
-
contents: { type: "bubble" },
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
await linePlugin.outbound!.sendPayload!({
|
|
178
|
-
to: "line:user:2",
|
|
179
|
-
text: "",
|
|
180
|
-
payload,
|
|
181
|
-
accountId: "default",
|
|
182
|
-
cfg,
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
expect(mocks.pushFlexMessage).not.toHaveBeenCalled();
|
|
186
|
-
expect(mocks.pushMessagesLine).toHaveBeenCalledWith(
|
|
187
|
-
"line:user:2",
|
|
188
|
-
[
|
|
189
|
-
{
|
|
190
|
-
type: "flex",
|
|
191
|
-
altText: "Card",
|
|
192
|
-
contents: { type: "bubble" },
|
|
193
|
-
quickReply: { items: ["One", "Two"] },
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
{ verbose: false, accountId: "default" },
|
|
197
|
-
);
|
|
198
|
-
expect(mocks.createQuickReplyItems).toHaveBeenCalledWith(["One", "Two"]);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("sends media before quick-reply text so buttons stay visible", async () => {
|
|
202
|
-
const { runtime, mocks } = createRuntime();
|
|
203
|
-
setLineRuntime(runtime);
|
|
204
|
-
const cfg = { channels: { line: {} } } as SymiConfig;
|
|
205
|
-
|
|
206
|
-
const payload = {
|
|
207
|
-
text: "Hello",
|
|
208
|
-
mediaUrl: "https://example.com/img.jpg",
|
|
209
|
-
channelData: {
|
|
210
|
-
line: {
|
|
211
|
-
quickReplies: ["One", "Two"],
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
await linePlugin.outbound!.sendPayload!({
|
|
217
|
-
to: "line:user:3",
|
|
218
|
-
text: payload.text,
|
|
219
|
-
payload,
|
|
220
|
-
accountId: "default",
|
|
221
|
-
cfg,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
expect(mocks.sendMessageLine).toHaveBeenCalledWith("line:user:3", "", {
|
|
225
|
-
verbose: false,
|
|
226
|
-
mediaUrl: "https://example.com/img.jpg",
|
|
227
|
-
accountId: "default",
|
|
228
|
-
});
|
|
229
|
-
expect(mocks.pushTextMessageWithQuickReplies).toHaveBeenCalledWith(
|
|
230
|
-
"line:user:3",
|
|
231
|
-
"Hello",
|
|
232
|
-
["One", "Two"],
|
|
233
|
-
{ verbose: false, accountId: "default" },
|
|
234
|
-
);
|
|
235
|
-
const mediaOrder = mocks.sendMessageLine.mock.invocationCallOrder[0];
|
|
236
|
-
const quickReplyOrder = mocks.pushTextMessageWithQuickReplies.mock.invocationCallOrder[0];
|
|
237
|
-
expect(mediaOrder).toBeLessThan(quickReplyOrder);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("uses configured text chunk limit for payloads", async () => {
|
|
241
|
-
const { runtime, mocks } = createRuntime();
|
|
242
|
-
setLineRuntime(runtime);
|
|
243
|
-
const cfg = { channels: { line: { textChunkLimit: 123 } } } as SymiConfig;
|
|
244
|
-
|
|
245
|
-
const payload = {
|
|
246
|
-
text: "Hello world",
|
|
247
|
-
channelData: {
|
|
248
|
-
line: {
|
|
249
|
-
flexMessage: {
|
|
250
|
-
altText: "Card",
|
|
251
|
-
contents: { type: "bubble" },
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
await linePlugin.outbound!.sendPayload!({
|
|
258
|
-
to: "line:user:3",
|
|
259
|
-
text: payload.text,
|
|
260
|
-
payload,
|
|
261
|
-
accountId: "primary",
|
|
262
|
-
cfg,
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
expect(mocks.resolveTextChunkLimit).toHaveBeenCalledWith(cfg, "line", "primary", {
|
|
266
|
-
fallbackLimit: 5000,
|
|
267
|
-
});
|
|
268
|
-
expect(mocks.chunkMarkdownText).toHaveBeenCalledWith("Hello world", 123);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe("linePlugin config.formatAllowFrom", () => {
|
|
273
|
-
it("strips line:user: prefixes without lowercasing", () => {
|
|
274
|
-
const formatted = linePlugin.config.formatAllowFrom!({
|
|
275
|
-
cfg: {} as SymiConfig,
|
|
276
|
-
allowFrom: ["line:user:UABC", "line:UDEF"],
|
|
277
|
-
});
|
|
278
|
-
expect(formatted).toEqual(["UABC", "UDEF"]);
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
describe("linePlugin groups.resolveRequireMention", () => {
|
|
283
|
-
it("uses account-level group settings when provided", () => {
|
|
284
|
-
const { runtime } = createRuntime();
|
|
285
|
-
setLineRuntime(runtime);
|
|
286
|
-
|
|
287
|
-
const cfg = {
|
|
288
|
-
channels: {
|
|
289
|
-
line: {
|
|
290
|
-
groups: {
|
|
291
|
-
"*": { requireMention: false },
|
|
292
|
-
},
|
|
293
|
-
accounts: {
|
|
294
|
-
primary: {
|
|
295
|
-
groups: {
|
|
296
|
-
"group-1": { requireMention: true },
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
} as SymiConfig;
|
|
303
|
-
|
|
304
|
-
const requireMention = linePlugin.groups!.resolveRequireMention!({
|
|
305
|
-
cfg,
|
|
306
|
-
accountId: "primary",
|
|
307
|
-
groupId: "group-1",
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
expect(requireMention).toBe(true);
|
|
311
|
-
});
|
|
312
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ChannelGatewayContext,
|
|
3
|
-
ChannelAccountSnapshot,
|
|
4
|
-
SymiConfig,
|
|
5
|
-
PluginRuntime,
|
|
6
|
-
ResolvedLineAccount,
|
|
7
|
-
RuntimeEnv,
|
|
8
|
-
} from "symi/plugin-sdk";
|
|
9
|
-
import { describe, expect, it, vi } from "vitest";
|
|
10
|
-
import { linePlugin } from "./channel.js";
|
|
11
|
-
import { setLineRuntime } from "./runtime.js";
|
|
12
|
-
|
|
13
|
-
function createRuntime() {
|
|
14
|
-
const probeLineBot = vi.fn(async () => ({ ok: false }));
|
|
15
|
-
const monitorLineProvider = vi.fn(async () => ({
|
|
16
|
-
account: { accountId: "default" },
|
|
17
|
-
handleWebhook: async () => {},
|
|
18
|
-
stop: () => {},
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const runtime = {
|
|
22
|
-
channel: {
|
|
23
|
-
line: {
|
|
24
|
-
probeLineBot,
|
|
25
|
-
monitorLineProvider,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
logging: {
|
|
29
|
-
shouldLogVerbose: () => false,
|
|
30
|
-
},
|
|
31
|
-
} as unknown as PluginRuntime;
|
|
32
|
-
|
|
33
|
-
return { runtime, probeLineBot, monitorLineProvider };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createRuntimeEnv(): RuntimeEnv {
|
|
37
|
-
return {
|
|
38
|
-
log: vi.fn(),
|
|
39
|
-
error: vi.fn(),
|
|
40
|
-
exit: vi.fn((code: number): never => {
|
|
41
|
-
throw new Error(`exit ${code}`);
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function createStartAccountCtx(params: {
|
|
47
|
-
token: string;
|
|
48
|
-
secret: string;
|
|
49
|
-
runtime: RuntimeEnv;
|
|
50
|
-
}): ChannelGatewayContext<ResolvedLineAccount> {
|
|
51
|
-
const snapshot: ChannelAccountSnapshot = {
|
|
52
|
-
accountId: "default",
|
|
53
|
-
configured: true,
|
|
54
|
-
enabled: true,
|
|
55
|
-
running: false,
|
|
56
|
-
};
|
|
57
|
-
return {
|
|
58
|
-
accountId: "default",
|
|
59
|
-
account: {
|
|
60
|
-
accountId: "default",
|
|
61
|
-
enabled: true,
|
|
62
|
-
channelAccessToken: params.token,
|
|
63
|
-
channelSecret: params.secret,
|
|
64
|
-
tokenSource: "config" as const,
|
|
65
|
-
config: {} as ResolvedLineAccount["config"],
|
|
66
|
-
},
|
|
67
|
-
cfg: {} as SymiConfig,
|
|
68
|
-
runtime: params.runtime,
|
|
69
|
-
abortSignal: new AbortController().signal,
|
|
70
|
-
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
|
|
71
|
-
getStatus: () => snapshot,
|
|
72
|
-
setStatus: vi.fn(),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
describe("linePlugin gateway.startAccount", () => {
|
|
77
|
-
it("fails startup when channel secret is missing", async () => {
|
|
78
|
-
const { runtime, monitorLineProvider } = createRuntime();
|
|
79
|
-
setLineRuntime(runtime);
|
|
80
|
-
|
|
81
|
-
await expect(
|
|
82
|
-
linePlugin.gateway!.startAccount!(
|
|
83
|
-
createStartAccountCtx({
|
|
84
|
-
token: "token",
|
|
85
|
-
secret: " ",
|
|
86
|
-
runtime: createRuntimeEnv(),
|
|
87
|
-
}),
|
|
88
|
-
),
|
|
89
|
-
).rejects.toThrow(
|
|
90
|
-
'LINE webhook mode requires a non-empty channel secret for account "default".',
|
|
91
|
-
);
|
|
92
|
-
expect(monitorLineProvider).not.toHaveBeenCalled();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("fails startup when channel access token is missing", async () => {
|
|
96
|
-
const { runtime, monitorLineProvider } = createRuntime();
|
|
97
|
-
setLineRuntime(runtime);
|
|
98
|
-
|
|
99
|
-
await expect(
|
|
100
|
-
linePlugin.gateway!.startAccount!(
|
|
101
|
-
createStartAccountCtx({
|
|
102
|
-
token: " ",
|
|
103
|
-
secret: "secret",
|
|
104
|
-
runtime: createRuntimeEnv(),
|
|
105
|
-
}),
|
|
106
|
-
),
|
|
107
|
-
).rejects.toThrow(
|
|
108
|
-
'LINE webhook mode requires a non-empty channel access token for account "default".',
|
|
109
|
-
);
|
|
110
|
-
expect(monitorLineProvider).not.toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("starts provider when token and secret are present", async () => {
|
|
114
|
-
const { runtime, monitorLineProvider } = createRuntime();
|
|
115
|
-
setLineRuntime(runtime);
|
|
116
|
-
|
|
117
|
-
await linePlugin.gateway!.startAccount!(
|
|
118
|
-
createStartAccountCtx({
|
|
119
|
-
token: "token",
|
|
120
|
-
secret: "secret",
|
|
121
|
-
runtime: createRuntimeEnv(),
|
|
122
|
-
}),
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
expect(monitorLineProvider).toHaveBeenCalledWith(
|
|
126
|
-
expect.objectContaining({
|
|
127
|
-
channelAccessToken: "token",
|
|
128
|
-
channelSecret: "secret",
|
|
129
|
-
accountId: "default",
|
|
130
|
-
}),
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
});
|