-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-bot-api.js
More file actions
56 lines (48 loc) · 1.63 KB
/
Copy pathtest-bot-api.js
File metadata and controls
56 lines (48 loc) · 1.63 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
56
/**
* Test script for the bot API
* This simulates a content submission to verify the bot works
*/
const testContentData = {
id: 'test-bot-submission-' + Date.now(),
title: 'Test Bot Submission',
description: 'This is a test submission to verify the bot API works correctly',
category: 'algorithms',
subtopic: 'testing',
type: 'guide',
repo: 'prepguides/test-repo',
path: 'test/README.md'
};
const testUserToken = 'test-token'; // This would be a real token in production
async function testBotAPI() {
console.log('🧪 Testing Bot API...');
console.log('Content Data:', testContentData);
try {
const response = await fetch('http://localhost:3000/api/github/create-content-pr', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
contentData: testContentData,
userToken: testUserToken
})
});
console.log('Response Status:', response.status);
if (response.ok) {
const result = await response.json();
console.log('✅ Bot API Test Successful!');
console.log('Result:', result);
} else {
const error = await response.json();
console.log('❌ Bot API Test Failed');
console.log('Error:', error);
}
} catch (error) {
console.log('❌ Bot API Test Error:', error.message);
}
}
// Only run if this file is executed directly
if (require.main === module) {
testBotAPI();
}
module.exports = { testBotAPI, testContentData };