diff --git a/app/src/components/geology/BorewellProfile.tsx b/app/src/components/geology/BorewellProfile.tsx index 790f34d..b6d9aba 100644 --- a/app/src/components/geology/BorewellProfile.tsx +++ b/app/src/components/geology/BorewellProfile.tsx @@ -50,18 +50,16 @@ export function BorewellProfile({ const pumpAt = borewell.pumpLowering != null && borewell.pumpLowering > 0 && borewell.pumpLowering <= depth ? borewell.pumpLowering : null; const pumpLabelY = pumpAt == null ? null : wl != null && Math.abs(y(pumpAt) - 4 - (y(wl) - 2)) < 13 ? y(wl) + 12 : y(pumpAt) - 4; - // Layer names share a column with the "Water … ft" label. Move a name above or below that label - // when they would overlap, or leave it out if the layer is too thin (the popup still has it). + // Layer names share a column with the "Water … ft" and "Pump … ft" labels. Move a name above or + // below those labels when they would overlap, or leave it out if the layer is too thin (the popup still has it). const waterLabelY = wl != null ? y(wl) - 2 : null; + const fixedLabels = [waterLabelY, pumpLabelY].filter((v) => v != null).sort((a, b) => a - b); const labelY = (y1: number, h: number): number | null => { if (h < 13) return null; + const clear = (at: number) => fixedLabels.every((f) => Math.abs(at - f) >= 13); const centre = y1 + h / 2 + 4; - if (waterLabelY == null || Math.abs(centre - waterLabelY) >= 13) return centre; - const below = waterLabelY + 14; - if (below <= y1 + h - 2) return below; - const above = waterLabelY - 14; - if (above >= y1 + 11) return above; - return null; + if (clear(centre)) return centre; + return fixedLabels.flatMap((f) => [f + 14, f - 14]).find((at) => at >= y1 + 11 && at <= y1 + h - 2 && clear(at)) ?? null; }; // In print, every name is written on its own layer, clear of the water line. A thin layer gets diff --git a/e2e/run.mjs b/e2e/run.mjs index 2de4e03..c13c9d5 100644 --- a/e2e/run.mjs +++ b/e2e/run.mjs @@ -643,6 +643,17 @@ try { return __t.text();`); check("Home shows the numbers, recently added borewells and the backup panel", /3 borewells across/.test(home) && /Back up now/.test(home) && /Needs attention/.test(home), home.split("\n").slice(0, 10).join(" | ")); + + // ── The drawing: a pump lowered to the middle of a layer does not cover the layer's name ── + const labels = await page(` + const b = await __t.invoke('borewell_create', { input: { borewellId: 'LABELS-1', ownerName: 'Label test', city: 'Lucknow', date: '2026-09-01', totalDepth: 200, waterLevel: 108, pumpLowering: 158 } }); + await __t.invoke('strata_save', { borewellId: b.id, layers: [{ startDepth: 0, endDepth: 135, material: 'Clay' }, { startDepth: 135, endDepth: 175, material: 'Sand' }, { startDepth: 175, endDepth: 200, material: 'Clay' }] }); + location.hash = '#/borewell/' + b.id; + const pump = await __t.until(() => [...document.querySelectorAll('main svg text')].find(t => t.textContent === 'Pump 158 ft'), 10000); + const beside = [...pump.closest('svg').querySelectorAll('text')].filter(t => /^(Pump|Water|Sand|Clay) /.test(t.textContent)) + .map(t => ({ name: t.textContent, y: Number(t.getAttribute('y')) })); // 11 px text: baselines closer than that touch + return { names: beside.map(t => t.name), covered: beside.flatMap((a, i) => beside.slice(i + 1).filter(o => Math.abs(a.y - o.y) < 11).map(o => a.name + ' / ' + o.name)) };`); + check("The drawing keeps a layer's name clear of the pump and water labels", labels.names.includes("Sand 135–175") && labels.covered.length === 0, JSON.stringify(labels)); } catch (e) { check("Test run finished", false, String(e)); } finally {