45 lines
1.7 KiB
JavaScript
45 lines
1.7 KiB
JavaScript
const queueManager = require('./backend/queueManager');
|
|
const botLogic = require('./backend/botLogic');
|
|
const configManager = require('./backend/configManager');
|
|
|
|
console.log("=== STARTING BACKEND UNIT TESTS ===");
|
|
|
|
// 1. Test QueueManager - Online Booking Limits
|
|
console.log("\nTesting QueueManager: Online Booking Limits");
|
|
const date = "2026-05-13";
|
|
const time = "10:00";
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
const res = queueManager.bookOnline(date, time);
|
|
console.log(`Booking ${i+1}:`, res.success ? `Success - ${res.token}` : `Failed - ${res.message}`);
|
|
}
|
|
|
|
// 2. Test QueueManager - Walkin Booking
|
|
console.log("\nTesting QueueManager: Walk-in Booking");
|
|
const walkRes = queueManager.bookWalkin(date, time);
|
|
console.log("Walkin result:", walkRes.token);
|
|
|
|
// 3. Test Bot Logic - WhatsApp Simulation
|
|
console.log("\nTesting BotLogic: WhatsApp Interactions");
|
|
async function testBot() {
|
|
const msg1 = await botLogic.handleMessage("9876543210", "Hi");
|
|
console.log("User: Hi -> Bot:", msg1.reply);
|
|
|
|
const msg2 = await botLogic.handleMessage("9876543210", "Book Token");
|
|
console.log("User: Book Token -> Bot:", msg2.reply);
|
|
console.log("Buttons:", msg2.buttons);
|
|
}
|
|
|
|
testBot();
|
|
|
|
// 4. Test ConfigManager - Multi-tenancy
|
|
console.log("\nTesting ConfigManager: Multi-tenancy");
|
|
const sharmaConfig = configManager.getTenantConfig('sharma-clinic');
|
|
console.log("Sharma Clinic Name:", sharmaConfig.name);
|
|
|
|
// 5. Test Multi-tenant Booking
|
|
console.log("\nTesting Multi-tenant Booking (Sharma Clinic)");
|
|
const sharmaRes = queueManager.bookOnline(date, time, 'sharma-clinic');
|
|
console.log("Sharma Booking Result:", sharmaRes.success ? `Success - ${sharmaRes.token} (Fee: ${sharmaRes.fee})` : "Failed");
|
|
|