From 65875a14c012dac23d7714d2f4d2bb7fed412262 Mon Sep 17 00:00:00 2001 From: KavyaCSH Date: Wed, 29 Jul 2026 11:41:13 +0530 Subject: [PATCH] Remove test files from repository --- test-api.ts | 41 ---------------- test-db.js | 12 ----- test-db2.js | 16 ------- test-db3.js | 12 ----- test-dispense.ts | 57 ----------------------- test-gemini.js | 19 -------- test-grn.ts | 60 ------------------------ test-history.js | 29 ------------ test-models.js | 8 ---- test-phase2.ts | 116 ---------------------------------------------- test-remaining.ts | 61 ------------------------ test_ai.ts | 11 ----- 12 files changed, 442 deletions(-) delete mode 100644 test-api.ts delete mode 100644 test-db.js delete mode 100644 test-db2.js delete mode 100644 test-db3.js delete mode 100644 test-dispense.ts delete mode 100644 test-gemini.js delete mode 100644 test-grn.ts delete mode 100644 test-history.js delete mode 100644 test-models.js delete mode 100644 test-phase2.ts delete mode 100644 test-remaining.ts delete mode 100644 test_ai.ts diff --git a/test-api.ts b/test-api.ts deleted file mode 100644 index 44fe2f4..0000000 --- a/test-api.ts +++ /dev/null @@ -1,41 +0,0 @@ -async function testAPI() { - console.log("1. Requesting Token for jayam_web_ai..."); - - const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - grant_type: "client_credentials", - client_id: "jayam_web_ai", - client_secret: "my_secret_key" - }) - }); - - const tokenData = await tokenResponse.json(); - - if (!tokenData.access_token) { - console.error("Failed to get token!", tokenData); - return; - } - - console.log("✅ Successfully received real JWT token!"); - console.log("Token:", tokenData.access_token.substring(0, 30) + "...\n"); - - console.log("2. Using Token to search for drugs (Catalogue API)..."); - - const searchResponse = await fetch("http://localhost:8080/v1/drugs/search?q=Losartan", { - method: "GET", - headers: { - "Authorization": `Bearer ${tokenData.access_token}`, - "X-Actor-Id": "usr_ph_1234" - } - }); - - const searchData = await searchResponse.json(); - - console.log(`✅ API Response Status: ${searchResponse.status}`); - console.log("Drug Search Results:"); - console.log(JSON.stringify(searchData, null, 2)); -} - -testAPI(); diff --git a/test-db.js b/test-db.js deleted file mode 100644 index bd0a515..0000000 --- a/test-db.js +++ /dev/null @@ -1,12 +0,0 @@ -const { Pool } = require('pg'); -const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' }); - -pool.query("SELECT id, status, extracted_data FROM prescriptions ORDER BY created_at DESC LIMIT 2") - .then(res => { - console.log(res.rows); - pool.end(); - }) - .catch(err => { - console.error(err); - pool.end(); - }); diff --git a/test-db2.js b/test-db2.js deleted file mode 100644 index 5283a36..0000000 --- a/test-db2.js +++ /dev/null @@ -1,16 +0,0 @@ -const { Pool } = require('pg'); -const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' }); - -pool.query("SELECT * FROM dispensing_records ORDER BY created_at DESC LIMIT 5") - .then(res => { - console.log('dispensing_records:', res.rows); - return pool.query("SELECT * FROM stock_movements ORDER BY created_at DESC LIMIT 5"); - }) - .then(res => { - console.log('stock_movements:', res.rows); - pool.end(); - }) - .catch(err => { - console.error(err); - pool.end(); - }); diff --git a/test-db3.js b/test-db3.js deleted file mode 100644 index f44c849..0000000 --- a/test-db3.js +++ /dev/null @@ -1,12 +0,0 @@ -const { Pool } = require('pg'); -const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' }); - -pool.query("SELECT id, brand_name FROM products") - .then(res => { - console.log('products:', res.rows); - pool.end(); - }) - .catch(err => { - console.error(err); - pool.end(); - }); diff --git a/test-dispense.ts b/test-dispense.ts deleted file mode 100644 index 3dbc3f5..0000000 --- a/test-dispense.ts +++ /dev/null @@ -1,57 +0,0 @@ -async function testDispense() { - console.log("1. Logging in as jayam_web_ai..."); - - const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - grant_type: "client_credentials", - client_id: "jayam_web_ai", - client_secret: "my_secret_key" - }) - }); - - const token = (await tokenResponse.json()).access_token; - - console.log("\n2. Running Precheck for a pregnant patient..."); - const precheckResponse = await fetch("http://localhost:8080/v1/orders/ord_123/precheck", { - method: "POST", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_1234", - "Content-Type": "application/json" - }, - body: JSON.stringify({ - clinical_context: { - pregnancy: { status: "pregnant" } - }, - items: [ - { product_id: "prd_4410", qty: 30 } // Losar 50 - ] - }) - }); - - console.log("Precheck Results:", JSON.stringify(await precheckResponse.json(), null, 2)); - - console.log("\n3. Executing Dispense transaction (requesting 30 units of Losar 50)..."); - const dispenseResponse = await fetch("http://localhost:8080/v1/orders/ord_123/dispense", { - method: "POST", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_1234", - "Idempotency-Key": "random-uuid-here-" + Date.now(), - "Content-Type": "application/json" - }, - body: JSON.stringify({ - subject_ref: "pat_123", - items: [ - { product_id: "prd_4410", qty: 30 } - ] - }) - }); - - console.log("Dispense Status:", dispenseResponse.status); - console.log("Dispense Results:", JSON.stringify(await dispenseResponse.json(), null, 2)); -} - -testDispense(); diff --git a/test-gemini.js b/test-gemini.js deleted file mode 100644 index 765d4ed..0000000 --- a/test-gemini.js +++ /dev/null @@ -1,19 +0,0 @@ -require('dotenv').config(); -const { GoogleGenAI } = require('@google/genai'); -const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); -ai.models.generateContent({ - model: 'gemini-3.6-flash', - contents: [ - 'Hello', - { - inlineData: { - data: Buffer.from('hello').toString("base64"), - mimeType: 'text/plain' - } - } - ], -}).then(res => { - console.log('Success:', res.text); -}).catch(err => { - console.error('Error:', err); -}); diff --git a/test-grn.ts b/test-grn.ts deleted file mode 100644 index 141c1fa..0000000 --- a/test-grn.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { pool } from './src/db/pool'; - -async function testGRN() { - console.log("1. Requesting Token..."); - const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - grant_type: "client_credentials", - client_id: "jayam_web_ai", - client_secret: "my_secret_key" - }) - }); - const tokenData = await tokenResponse.json(); - const token = tokenData.access_token; - - if (!token) { - console.error("No token received", tokenData); - return; - } - - const batchNo = "BAT-" + Date.now(); - - console.log(`2. Sending GRN for Losar 50 (prd_4410), Batch: ${batchNo}...`); - const grnResponse = await fetch("http://localhost:8080/v1/inventory/grn", { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_admin", - "idempotency-key": "idemp-" + Date.now() - }, - body: JSON.stringify({ - lines: [ - { - batch_no: batchNo, - product_id: "prd_4410", - expiry: "2027-12-31", - qty: 500, - purchase_price: "50.00" - } - ] - }) - }); - - const grnData = await grnResponse.json(); - console.log("GRN Response Status:", grnResponse.status); - console.log("GRN Response Data:", grnData); - - console.log("\n3. Verifying Database..."); - const batchRes = await pool.query("SELECT * FROM batches WHERE batch_no = $1", [batchNo]); - console.log("Batch in DB:", batchRes.rows); - - const stockMoveRes = await pool.query("SELECT * FROM stock_movements WHERE batch_no = $1", [batchNo]); - console.log("Stock Movements in DB:", stockMoveRes.rows); - - process.exit(0); -} - -testGRN(); diff --git a/test-history.js b/test-history.js deleted file mode 100644 index aeac9a0..0000000 --- a/test-history.js +++ /dev/null @@ -1,29 +0,0 @@ -const http = require('http'); - -const options = { - hostname: 'localhost', - port: 8080, - path: '/v1/orders/history', - method: 'GET', - headers: { - 'Authorization': 'Bearer test', - 'X-Actor-Id': 'act_admin' - } -}; - -const req = http.request(options, res => { - console.log(`statusCode: ${res.statusCode}`); - let data = ''; - res.on('data', d => { - data += d; - }); - res.on('end', () => { - console.log(data); - }); -}); - -req.on('error', error => { - console.error(error); -}); - -req.end(); diff --git a/test-models.js b/test-models.js deleted file mode 100644 index 06028bb..0000000 --- a/test-models.js +++ /dev/null @@ -1,8 +0,0 @@ -require('dotenv').config(); -const { GoogleGenAI } = require('@google/genai'); -const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); -ai.models.list().then(res => { - console.log(res); -}).catch(err => { - console.error('Error:', err); -}); diff --git a/test-phase2.ts b/test-phase2.ts deleted file mode 100644 index 54f5a35..0000000 --- a/test-phase2.ts +++ /dev/null @@ -1,116 +0,0 @@ -import fs from 'fs'; -import path from 'path'; - -async function testPhase2() { - console.log("1. Creating dummy image file..."); - const dummyFilePath = path.join(__dirname, 'dummy_rx.jpg'); - fs.writeFileSync(dummyFilePath, 'dummy image content'); - - console.log("2. Requesting Token..."); - const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - grant_type: "client_credentials", - client_id: "jayam_web_ai", - client_secret: "my_secret_key" - }) - }); - const tokenData = await tokenResponse.json(); - const token = tokenData.access_token; - - if (!token) { - console.error("No token received", tokenData); - return; - } - - console.log("3. Uploading Prescription (POST /v1/prescriptions/upload)..."); - - // Use fetch with FormData to upload file - const formData = new FormData(); - const fileBlob = new Blob([fs.readFileSync(dummyFilePath)], { type: 'image/jpeg' }); - formData.append('image', fileBlob, 'dummy_rx.jpg'); - - const uploadResponse = await fetch("http://localhost:8080/v1/prescriptions/upload", { - method: "POST", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_admin" - }, - body: formData as any - }); - - const uploadData = await uploadResponse.json(); - console.log("Upload Status:", uploadResponse.status); - console.log("Upload Data:", uploadData); - const rxId = uploadData.id; - - if (uploadResponse.status !== 202) { - console.error("Upload failed"); - return; - } - - console.log("\n4. Polling for Extraction Results (waiting 6 seconds)..."); - await new Promise(resolve => setTimeout(resolve, 6000)); - - const pollResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}`, { - method: "GET", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_admin" - } - }); - - const pollData = await pollResponse.json(); - console.log("Poll Status:", pollResponse.status); - console.log("Image Path (S3 URL):", pollData.image_path); - console.log("Extracted Data:", JSON.stringify(pollData.extracted_data, null, 2)); - - console.log("\n5. Testing Confirmation - Human Gate 1"); - console.log("Attempting to confirm without explicit selection on low-confidence item..."); - - const badConfirmPayload = { - items: [ - { explicitly_confirmed: true }, - { explicitly_confirmed: false } // Fails Gate 1 - ] - }; - - const badConfirmResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}/confirm`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_admin" - }, - body: JSON.stringify(badConfirmPayload) - }); - - console.log("Bad Confirm Status (Expect 422):", badConfirmResponse.status); - console.log("Bad Confirm Response:", await badConfirmResponse.json()); - - console.log("\nAttempting to confirm properly..."); - const goodConfirmPayload = { - items: [ - { explicitly_confirmed: true }, - { explicitly_confirmed: true, parsed: { brand: "Hydralazine 25mg" } } - ] - }; - - const goodConfirmResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}/confirm`, { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_ph_admin" - }, - body: JSON.stringify(goodConfirmPayload) - }); - - console.log("Good Confirm Status (Expect 200):", goodConfirmResponse.status); - console.log("Good Confirm Response:", await goodConfirmResponse.json()); - - process.exit(0); -} - -testPhase2(); diff --git a/test-remaining.ts b/test-remaining.ts deleted file mode 100644 index d22d942..0000000 --- a/test-remaining.ts +++ /dev/null @@ -1,61 +0,0 @@ -async function testRemaining() { - console.log("1. Logging in as jayam_web_ai..."); - - const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - grant_type: "client_credentials", - client_id: "jayam_web_ai", - client_secret: "my_secret_key" - }) - }); - - const token = (await tokenResponse.json()).access_token; - - console.log("\n2. Executing Goods Receipt Note (GRN)..."); - const grnResponse = await fetch("http://localhost:8080/v1/inventory/grn", { - method: "POST", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_mgr_1234", - "Idempotency-Key": "grn-uuid-" + Date.now(), - "Content-Type": "application/json" - }, - body: JSON.stringify({ - supplier_id: "sup_120", - invoice_no: "INV/2026/9999", - invoice_date: "2026-07-24", - po_ref: "po_8891", - lines: [ - { - product_id: "prd_4410", - batch_no: "B9999-" + Date.now(), - expiry: "2028-12-31", - qty: 500, - purchase_price: 54.20, - mrp: 78.50 - } - ] - }) - }); - - console.log("GRN Status:", grnResponse.status); - console.log("GRN Results:", JSON.stringify(await grnResponse.json(), null, 2)); - - console.log("\n3. Fetching Audit Logs..."); - const auditResponse = await fetch("http://localhost:8080/v1/audit/logs", { - method: "GET", - headers: { - "Authorization": `Bearer ${token}`, - "X-Actor-Id": "usr_mgr_1234" - } - }); - - console.log("Audit Status:", auditResponse.status); - const auditData = await auditResponse.json(); - console.log("Found Stock Movements:", auditData.stock_movements.length); - console.log("Latest Stock Movement:", JSON.stringify(auditData.stock_movements[0], null, 2)); -} - -testRemaining(); diff --git a/test_ai.ts b/test_ai.ts deleted file mode 100644 index ba15b54..0000000 --- a/test_ai.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { AIService } from './src/modules/ai/service'; -import * as dotenv from 'dotenv'; -dotenv.config(); -const s = new AIService(); -s.processVoiceCommand('low stock').then(res => { - console.log("SUCCESS:", res); - process.exit(0); -}).catch(err => { - console.error("FAIL:", err); - process.exit(1); -});