feat: (broken) implement route map and address autocomplete widgets with associated infrastructure testing scripts

This commit is contained in:
ElPoyo
2026-06-05 11:10:32 +02:00
parent 8c01a21728
commit 21d7bc8b87
40 changed files with 21078 additions and 30 deletions
+40
View File
@@ -0,0 +1,40 @@
const axios = require('axios');
const polylineLib = require('@mapbox/polyline');
require('dotenv').config({ path: '.env' });
const { googleMapsComputeRoute } = require('./src/travel.js');
async function testRoute(destination, expectedPrice) {
const origin = "25 Impasse du Puits du Suc, Saint-Martin-en-Haut, France";
console.log(`\nTesting ${destination}...`);
const req = {
headers: { authorization: 'Bearer MOCK' },
body: { origin, destination, vehicleTollCategory: 2 }
};
let resultBody = null;
const res = {
set: () => {}, status: () => res,
json: (data) => { resultBody = data; return res; },
send: (data) => { resultBody = data; return res; }
};
await googleMapsComputeRoute(req, res);
if (resultBody.error) {
console.error(`Error: ${resultBody.error}`);
} else {
const toll = resultBody.routes && resultBody.routes.length > 0 ? resultBody.routes[0].tollCost : 0;
console.log(`Toll: ${toll}€ (Expected: ${expectedPrice}€)`);
}
}
async function run() {
// Mock Firebase auth specifically for this test
const auth = require('./utils/auth');
auth.authenticateUser = async () => {};
await testRoute("Saint-Denis, France", 64.3);
await testRoute("Grenoble, France", 21.7);
await testRoute("Nice, France", 77.2);
}
run();