Arreglado vision y funcion de zonas a evitar

This commit is contained in:
2026-09-10 08:59:29 +02:00
parent d50333f82a
commit 7f17dfeb2a
8 changed files with 71 additions and 71 deletions

View File

@@ -58,23 +58,27 @@ List<double[]> Ring(double lon, double lat, double size) =>
await Walk();
var far = new List<List<double[]>> { Ring(-2.3, 43.0, .01) };
await Walk(far);
Check(fake.Calls == 1, "Zona lejana reutiliza la geometria conocida");
Check(fake.Calls == 2 && fake.Zones == 1, "Toda zona activa se envia a V2 aunque este lejos de la ruta previa");
var near = new List<List<double[]>> { Ring(-1.985, 43.315, .001), Ring(-1.982, 43.317, .001) };
await Walk(near);
Check(fake.Zones == 2, "Se envian todos los poligonos");
await Walk(near);
Check(fake.Calls == 2, "Mismas zonas reutilizan cache restringida");
Check(fake.Calls == 3, "Mismas zonas reutilizan cache restringida");
near[0][0][0] += .00001;
await Walk(near);
Check(fake.Calls == 3, "Mover un vertice invalida esa entrada de cache");
Check(fake.Calls == 4, "Mover un vertice invalida esa entrada de cache");
await Walk(new() { Ring(-2.2, 43.1, .5) });
Check(fake.Calls == 4, "Una zona que rodea la ruta no se ignora aunque sus vertices esten lejos");
Check(fake.Calls == 5, "Una zona que rodea la ruta no se ignora aunque sus vertices esten lejos");
fake.Fail = true;
var retry = new List<List<double[]>> { Ring(-1.984, 43.312, .0002) };
await Walk(retry);
fake.Fail = false;
await Walk(retry);
Check(fake.Calls == 6, "Un fallo temporal no queda guardado en cache de zonas");
Check(fake.Calls == 7, "Un fallo temporal no queda guardado en cache de zonas");
var puntos = new List<double[]> { new[] { 43.314, -1.984 }, new[] { 43.315, -1.983 } };
await (Task<(double[,]?, double, double)>)walk.Invoke(planner,
new object?[] { 43.31, -1.99, 43.32, -1.98, near, puntos })!;
Check(fake.Zones == 2 && fake.Points == 2, "Se envian juntos todos los poligonos y puntos activos");
var page = new PlanificadorRutas();
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
var options = (List<AlternativaRuta>)typeof(PlanificadorRutas).GetField("_opcionesRuta", flags)!.GetValue(page)!;
@@ -102,6 +106,7 @@ sealed class FakeValhalla : IClienteValhalla
public int Calls { get; private set; }
public int Zones { get; private set; }
public int Points { get; private set; }
public bool Fail { get; set; }
public Task<(double[,]? Linea, double DistanciaMetros, double DuracionSegundos)> ObtenerRutaAsync(
double latitudDesde, double longitudDesde, double latitudHasta, double longitudHasta,
@@ -110,6 +115,7 @@ sealed class FakeValhalla : IClienteValhalla
{
Calls++;
Zones = excludePolygons?.Count ?? 0;
Points = excludeLocations?.Count ?? 0;
return Task.FromResult<(double[,]?, double, double)>(Fail ? (null, 0, 0) :
(new[,] { { latitudDesde, longitudDesde }, { latitudHasta, longitudHasta } }, 100, 100));
}

View File

@@ -14,9 +14,10 @@ const path = require("node:path");
await page.goto("http://127.0.0.1:5199", { waitUntil: "domcontentloaded" });
await page.waitForFunction(() => !!window.rt?._dotNetHelper && !!window.__rtLeafletMap);
const initialErrors = errors.slice();
await page.keyboard.press("Control+Shift+KeyZ");
await page.keyboard.press("Control+Shift+KeyE");
await page.locator(".zones-panel").waitFor();
await page.waitForTimeout(1000);
await page.getByRole("button", { name: "Polígono", exact: true }).click();
await page.getByRole("button", { name: "Añadir zona", exact: true }).click();
for (const [x, y] of [[600, 420], [850, 430], [760, 640]]) {
await page.mouse.click(x, y);
@@ -52,7 +53,7 @@ const path = require("node:path");
await page.locator(".zones-panel").waitFor({ state: "detached" });
assert.equal(await page.locator(".rt-exclusion-vertex").count(), 0);
assert.equal(await page.locator('path[stroke="#e879f9"], path[stroke="#f97316"]').count(), 0);
await page.keyboard.press("Control+Shift+KeyZ");
await page.keyboard.press("Control+Shift+KeyE");
await page.locator(".zones-panel").waitFor();
assert.equal(await page.locator(".zones-panel__item").count(), 2, "Reabrir conserva zonas editables");
await page.getByRole("checkbox", { name: "Activar zona", exact: true }).first().uncheck();
@@ -60,7 +61,7 @@ const path = require("node:path");
await page.reload();
await page.waitForFunction(() => !!window.rt?._dotNetHelper && !!window.__rtLeafletMap);
await page.waitForTimeout(1000);
await page.keyboard.press("Control+Shift+KeyZ");
await page.keyboard.press("Control+Shift+KeyE");
await page.locator(".zones-panel__item").first().waitFor();
assert.equal(await page.locator(".zones-panel__item").count(), 2, "F5 conserva zonas");
assert.equal(await page.getByRole("checkbox", { name: "Activar zona", exact: true }).first().isChecked(), false);
@@ -81,6 +82,16 @@ const path = require("node:path");
await page.getByRole("button", { name: "Eliminar zona", exact: true }).first().click();
await page.waitForFunction(() => document.querySelectorAll(".zones-panel__item").length === 1);
assert.equal(await page.locator(".zones-panel__item").count(), 1);
await page.getByRole("button", { name: "Punto", exact: true }).click();
await page.getByRole("button", { name: "Añadir punto", exact: true }).click();
await page.mouse.click(1050, 720);
await page.waitForFunction(() => document.querySelectorAll(".zones-panel__item").length === 2);
assert.match(await page.locator(".zones-panel__item").last().innerText(), /Punto/);
assert.equal(await page.locator(".zones-panel__item").last().innerText().then(text => text.includes("abierta")), false,
"Un clic cierra la exclusion puntual");
const puntoGuardado = await page.evaluate(() => JSON.parse(localStorage.getItem("rutasdbus.zonas.v1")).at(-1));
assert.equal(puntoGuardado.EsPunto, true);
assert.equal(puntoGuardado.Vertices.length, 1, "El punto se guarda con un solo vertice");
await page.getByRole("button", { name: "Borrar todas", exact: true }).click();
await page.waitForFunction(() => document.querySelectorAll(".zones-panel__item").length === 0);
assert.equal(await page.locator(".zones-panel__item").count(), 0);
@@ -88,6 +99,7 @@ const path = require("node:path");
await page.screenshot({ path: path.join(artifacts, "mobile.png") });
const box = await page.locator(".zones-panel").boundingBox();
assert.ok(box.x >= 0 && box.x + box.width <= 390 && box.y + box.height <= 844, "Panel dentro del movil");
await page.getByRole("button", { name: "Polígono", exact: true }).click();
await page.getByRole("button", { name: "Añadir zona", exact: true }).click();
await page.getByRole("button", { name: "Cerrar herramienta", exact: true }).click();
await page.setViewportSize({ width: 1440, height: 1000 });
@@ -99,7 +111,7 @@ const path = require("node:path");
const newErrors = errors.filter(error => !initialErrors.includes(error) && !externalErrors.includes(error));
assert.equal(newErrors.length, 0, newErrors.join("\n"));
if (externalErrors.length) console.log("Aviso del complemento externo de geocodificacion: " + externalErrors[0]);
console.log("OK multiples zonas, arrastre en vivo, cierre, reapertura, borrado, alturas de botones y movil");
console.log("OK poligonos y puntos, arrastre en vivo, cierre, reapertura, borrado, alturas de botones y movil");
} finally {
await browser.close();
}