-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdebug.ts
More file actions
58 lines (52 loc) · 1.19 KB
/
debug.ts
File metadata and controls
58 lines (52 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Debug utilities for testing the chatbot locally
*
* Usage:
* - test_post(): Simulates a POST request from LINE webhook
* - test_send(): Sends a test message directly to LINE
*/
import lineService from './lineService';
import doPost from './app';
import CONFIG from './config';
/**
* Test the doPost function by simulating a LINE webhook event
* Change the message text to test different scenarios
*/
function test_post(): void {
const data = {
events: [
{
message: {
text: 'woody' // Change this to test different cocktail names
},
source: {
userId: CONFIG.CONFIG_DEBUG.USERID
},
replyToken: 'test-reply-token'
}
]
};
const testData = {
postData: {
contents: JSON.stringify(data)
}
};
doPost(testData);
}
/**
* Test sending a message directly to LINE
* Useful for testing the LINE API connection
*/
function test_send(): void {
const messageConfig = {
type: 'push',
to: CONFIG.CONFIG_DEBUG.USERID,
messages: [
{
'type': 'text',
'text': 'Hello! This is a test message from Over Party Lab Bot.'
}
]
};
lineService.pushMsg(messageConfig);
}