From 69c3d422239a50a83584ad1218bd66e57a63d0e8 Mon Sep 17 00:00:00 2001 From: Prayas Lashkari Date: Tue, 17 Nov 2026 15:28:14 -0500 Subject: [PATCH 1/2] feat(engine): name sample results, ground water aquifers and streams and flowlines as the Type menu does The question sentence, step labels and count messages now use the Type menu's nouns. SPARQL is unchanged; only the question-text snapshot moved. Closes #164 Co-Authored-By: Claude --- engine/entities/aquifers.ts | 4 +- engine/entities/samples.ts | 2 +- engine/entities/streams.ts | 2 +- engine/tests/__snapshots__/question-text.txt | 234 +++++++++---------- engine/tests/blockWording.test.ts | 17 +- engine/tests/errors.test.ts | 10 +- engine/tests/executor.test.ts | 8 +- engine/tests/questionText.test.ts | 2 +- engine/tests/stepLabels.test.ts | 21 +- 9 files changed, 157 insertions(+), 143 deletions(-) diff --git a/engine/entities/aquifers.ts b/engine/entities/aquifers.ts index d8f65d3..6b18291 100644 --- a/engine/entities/aquifers.ts +++ b/engine/entities/aquifers.ts @@ -2,10 +2,10 @@ import type { AquiferFilters } from '../types/query'; import { AQUIFER_TYPE_VALUES, buildAquifersByIri } from '../templates/aquifers'; import { ownFilterSet, subdivisionRegionCheck, type EntityModule } from './types'; -const LABEL = 'aquifers'; +const LABEL = 'ground water aquifers'; const iriVar = (suffix: string): string => `?aquifer${suffix}`; -// One kind selected reads as an adjective ("bedrock aquifers"). +// One kind selected reads as an adjective ("bedrock ground water aquifers"). const KIND_WORDS: Record = { surficial: 'sand & gravel', bedrock: 'bedrock', diff --git a/engine/entities/samples.ts b/engine/entities/samples.ts index 78a3b8e..be09217 100644 --- a/engine/entities/samples.ts +++ b/engine/entities/samples.ts @@ -5,7 +5,7 @@ import { FALLBACK_MATERIAL_TYPES } from '../constants/materialTypes'; import type { EntityModule } from './types'; import { LIST_THRESHOLD, extractLabel, summarize } from './wording'; -const LABEL = 'samples'; +const LABEL = 'sample results'; // Concentration range and the non-detect exclusion, as one parenthetical: // " (10-1000 ng/L, detections only)". The editor's inputs are ng/L and the diff --git a/engine/entities/streams.ts b/engine/entities/streams.ts index 499392c..4dcf3b3 100644 --- a/engine/entities/streams.ts +++ b/engine/entities/streams.ts @@ -4,7 +4,7 @@ import { STREAM_FTYPES } from '../constants/featureTypes'; import { ownFilterSet, type EntityModule } from './types'; import { ftypeLabels, namedOrCounted } from './wording'; -const LABEL = 'streams'; +const LABEL = 'streams and flowlines'; // FTYPE restriction for flowlines, shared by the cell bind below and by the // trace query, where a streams target is the traced flowline itself. diff --git a/engine/tests/__snapshots__/question-text.txt b/engine/tests/__snapshots__/question-text.txt index 5a24380..b457543 100644 --- a/engine/tests/__snapshots__/question-text.txt +++ b/engine/tests/__snapshots__/question-text.txt @@ -2,15 +2,15 @@ # Re-record with: npx vitest run -u ## PREBUILT: facilities-upstream-pfhpa-gw-cumberland - What facilities in Cumberland County, Maine are upstream from PFHpA Groundwater (GW) samples (10-1000 ng/L) in Cumberland County, Maine? + What facilities in Cumberland County, Maine are upstream from PFHpA Groundwater (GW) sample results (10-1000 ng/L) in Cumberland County, Maine? ## PREBUILT: samples-near-landfill-dod-penobscot-knox - What samples in Penobscot County, Maine & Knox County, Maine are within at most 2 miles of Solid Waste Landfill, National Security facilities? + What sample results in Penobscot County, Maine & Knox County, Maine are within at most 2 miles of Solid Waste Landfill, National Security facilities? ## PREBUILT: samples-downstream-waste-indiana - What samples in Indiana are downstream of Waste Treatment and Disposal facilities? + What sample results in Indiana are downstream of Waste Treatment and Disposal facilities? ## PREBUILT: facilities-upstream-streams-cook - What Chemical Manufacturing, Plastics and Rubber Products Manufacturing facilities in Cook County, Illinois are within 50 km upstream from streams? + What Chemical Manufacturing, Plastics and Rubber Products Manufacturing facilities in Cook County, Illinois are within 50 km upstream from streams and flowlines? ## PREBUILT: samples-near-agchem-maine - What samples in Maine are within at most 2 miles of Pesticide, Fertilizer, and Other Agricultural Chemical Manufacturing facilities? + What sample results in Maine are within at most 2 miles of Pesticide, Fertilizer, and Other Agricultural Chemical Manufacturing facilities? ## PREBUILT: waterbodies-near-landfill-dod-penobscot-knox What surface water bodies in Penobscot County, Maine & Knox County, Maine are within at most 2 miles of Solid Waste Landfill, National Security facilities? ## PREBUILT: wells-near-landfill-dod-maine @@ -18,244 +18,244 @@ ## PREBUILT: wells-near-wwtp-maine What wells in Maine are within at most 2 miles of Sewage Treatment Facilities facilities? ## REPRESENTATIVE: samples near facilities - What samples in Maine are within at most 2 miles of facilities? + What sample results in Maine are within at most 2 miles of facilities? ## REPRESENTATIVE: facilities near waterBodies What facilities in Maine are within at most 2 miles of surface water bodies? ## REPRESENTATIVE: waterBodies near wells What surface water bodies in Maine are within at most 2 miles of wells? ## REPRESENTATIVE: wells near aquifers - What wells in Maine are within at most 2 miles of aquifers? + What wells in Maine are within at most 2 miles of ground water aquifers? ## REPRESENTATIVE: aquifers near streams - What aquifers in Maine are within at most 2 miles of streams? + What ground water aquifers in Maine are within at most 2 miles of streams and flowlines? ## REPRESENTATIVE: streams near samples - What streams in Maine are within at most 2 miles of samples? + What streams and flowlines in Maine are within at most 2 miles of sample results? ## REPRESENTATIVE: samples downstream facilities - What samples in Maine are downstream of facilities? + What sample results in Maine are downstream of facilities? ## REPRESENTATIVE: facilities downstream waterBodies What facilities in Maine are downstream of surface water bodies? ## REPRESENTATIVE: waterBodies downstream wells What surface water bodies in Maine are downstream of wells? ## REPRESENTATIVE: wells downstream aquifers - What wells in Maine are downstream of aquifers? + What wells in Maine are downstream of ground water aquifers? ## REPRESENTATIVE: aquifers downstream streams - What aquifers in Maine are downstream of streams? + What ground water aquifers in Maine are downstream of streams and flowlines? ## REPRESENTATIVE: streams downstream samples - What streams in Maine are downstream of samples? + What streams and flowlines in Maine are downstream of sample results? ## REPRESENTATIVE: samples upstream facilities - What samples in Maine are upstream from facilities? + What sample results in Maine are upstream from facilities? ## REPRESENTATIVE: facilities upstream waterBodies What facilities in Maine are upstream from surface water bodies? ## REPRESENTATIVE: waterBodies upstream wells What surface water bodies in Maine are upstream from wells? ## REPRESENTATIVE: wells upstream aquifers - What wells in Maine are upstream from aquifers? + What wells in Maine are upstream from ground water aquifers? ## REPRESENTATIVE: aquifers upstream streams - What aquifers in Maine are upstream from streams? + What ground water aquifers in Maine are upstream from streams and flowlines? ## REPRESENTATIVE: streams upstream samples - What streams in Maine are upstream from samples? + What streams and flowlines in Maine are upstream from sample results? ## REPRESENTATIVE: samples near facilities [region on C] - What samples are within at most 2 miles of facilities in Maine? + What sample results are within at most 2 miles of facilities in Maine? ## REPRESENTATIVE: samples downstream facilities [region on C] - What samples are downstream of facilities in Maine? + What sample results are downstream of facilities in Maine? ## REPRESENTATIVE: samples upstream facilities [region on C] - What samples are upstream from facilities in Maine? + What sample results are upstream from facilities in Maine? ## REPRESENTATIVE: samples downstream(30km) facilities - What samples in Maine are within 30 km downstream of facilities? + What sample results in Maine are within 30 km downstream of facilities? ## REPRESENTATIVE: samples downstream(30km) facilities [region on C] - What samples are within 30 km downstream of facilities in Maine? + What sample results are within 30 km downstream of facilities in Maine? ## REPRESENTATIVE: samples upstream(30km) facilities - What samples in Maine are within 30 km upstream from facilities? + What sample results in Maine are within 30 km upstream from facilities? ## REPRESENTATIVE: samples upstream(30km) facilities [region on C] - What samples are within 30 km upstream from facilities in Maine? + What sample results are within 30 km upstream from facilities in Maine? ## REPRESENTATIVE: filter: samples (substance, material, concentration, no non-detects) - What PFHpA Groundwater samples (4-100 ng/L, detections only) in Maine are downstream of facilities? + What PFHpA Groundwater sample results (4-100 ng/L, detections only) in Maine are downstream of facilities? ## REPRESENTATIVE: filter: facilities (industry) - What samples in Maine are within at most 2 miles of 562212 facilities? + What sample results in Maine are within at most 2 miles of 562212 facilities? ## REPRESENTATIVE: filter: waterBodies (ftype) What 390 surface water bodies in Maine are within at most 2 miles of facilities? ## REPRESENTATIVE: filter: wells (category) What Domestic wells in Maine are within at most 2 miles of facilities? ## REPRESENTATIVE: filter: aquifers (type) - What wells in Maine are within at most 2 miles of bedrock aquifers? + What wells in Maine are within at most 2 miles of bedrock ground water aquifers? ## REPRESENTATIVE: filter: streams (ftype) - What samples in Maine are downstream of 460 streams? + What sample results in Maine are downstream of 460 streams and flowlines? ## REPRESENTATIVE: no region either side - What samples are downstream of facilities? + What sample results are downstream of facilities? ## REPRESENTATIVE: county scope both sides - What samples in Maine are within at most 2 miles of facilities in Maine? + What sample results in Maine are within at most 2 miles of facilities in Maine? ## REPRESENTATIVE: near hops=0 - What samples in Maine are within at most 1 mile of facilities? + What sample results in Maine are within at most 1 mile of facilities? ## REPRESENTATIVE: near hops=2 - What samples in Maine are within at most 3 miles of facilities? + What sample results in Maine are within at most 3 miles of facilities? ## CRITICAL: facilities upstream from streams - What facilities in Maine are upstream from streams? + What facilities in Maine are upstream from streams and flowlines? ## CRITICAL: facilities upstream from PFOS samples in York and Cumberland, facilities left empty - What facilities are upstream from DTXSID3031864 samples in Maine? + What facilities are upstream from DTXSID3031864 sample results in Maine? ## CRITICAL: facilities upstream from PFOS samples in Cumberland, non-detects included - What facilities are upstream from DTXSID3031864 samples in Maine? + What facilities are upstream from DTXSID3031864 sample results in Maine? ## CRITICAL: facilities upstream from PFOS samples in York, detections only - What facilities are upstream from DTXSID3031864 samples (detections only) in Maine? + What facilities are upstream from DTXSID3031864 sample results (detections only) in Maine? ## CRITICAL: facilities within 30km upstream from PFOS samples in York, facilities left empty - What facilities are within 30 km upstream from DTXSID3031864 samples (detections only) in Maine? + What facilities are within 30 km upstream from DTXSID3031864 sample results (detections only) in Maine? ## CRITICAL: facilities within 5km upstream from PFOS samples in York, industry filter, no region on facilities - What 562212 facilities are within 5 km upstream from DTXSID3031864 samples (detections only) in Maine? + What 562212 facilities are within 5 km upstream from DTXSID3031864 sample results (detections only) in Maine? ## CRITICAL: samples ≥ 4 ng/L in Penobscot and Knox near wells in the same counties - What samples (above 4 ng/L) in Maine are within at most 3 miles of wells in Maine? + What sample results (above 4 ng/L) in Maine are within at most 3 miles of wells in Maine? ## CRITICAL: samples ≥ 4 ng/L anywhere near wells in Somerset - What samples (above 4 ng/L) are within at most 3 miles of wells in Maine? + What sample results (above 4 ng/L) are within at most 3 miles of wells in Maine? ## CRITICAL: facilities in Cook County near Cook County wells, no industry filter What facilities in Illinois are within at most 2 miles of wells in Illinois? ## FILTER A: samples: state - What samples in Maine are within at most 2 miles of facilities? + What sample results in Maine are within at most 2 miles of facilities? ## FILTER C: samples: state - What facilities are within at most 2 miles of samples in Maine? + What facilities are within at most 2 miles of sample results in Maine? ## FILTER A: samples: county - What samples in York County are within at most 2 miles of facilities? + What sample results in York County are within at most 2 miles of facilities? ## FILTER C: samples: county - What facilities are within at most 2 miles of samples in York County? + What facilities are within at most 2 miles of sample results in York County? ## FILTER A: facilities: state - What facilities in Maine are within at most 2 miles of samples? + What facilities in Maine are within at most 2 miles of sample results? ## FILTER C: facilities: state - What samples are within at most 2 miles of facilities in Maine? + What sample results are within at most 2 miles of facilities in Maine? ## FILTER A: facilities: county - What facilities in York County are within at most 2 miles of samples? + What facilities in York County are within at most 2 miles of sample results? ## FILTER C: facilities: county - What samples are within at most 2 miles of facilities in York County? + What sample results are within at most 2 miles of facilities in York County? ## FILTER A: waterBodies: state - What surface water bodies in Maine are within at most 2 miles of samples? + What surface water bodies in Maine are within at most 2 miles of sample results? ## FILTER C: waterBodies: state - What samples are within at most 2 miles of surface water bodies in Maine? + What sample results are within at most 2 miles of surface water bodies in Maine? ## FILTER A: waterBodies: county - What surface water bodies in York County are within at most 2 miles of samples? + What surface water bodies in York County are within at most 2 miles of sample results? ## FILTER C: waterBodies: county - What samples are within at most 2 miles of surface water bodies in York County? + What sample results are within at most 2 miles of surface water bodies in York County? ## FILTER A: wells: state - What wells in Maine are within at most 2 miles of samples? + What wells in Maine are within at most 2 miles of sample results? ## FILTER C: wells: state - What samples are within at most 2 miles of wells in Maine? + What sample results are within at most 2 miles of wells in Maine? ## FILTER A: wells: county - What wells in York County are within at most 2 miles of samples? + What wells in York County are within at most 2 miles of sample results? ## FILTER C: wells: county - What samples are within at most 2 miles of wells in York County? + What sample results are within at most 2 miles of wells in York County? ## FILTER A: aquifers: state - What aquifers in Maine are within at most 2 miles of samples? + What ground water aquifers in Maine are within at most 2 miles of sample results? ## FILTER C: aquifers: state - What samples are within at most 2 miles of aquifers in Maine? + What sample results are within at most 2 miles of ground water aquifers in Maine? ## FILTER A: aquifers: county - What aquifers in York County are within at most 2 miles of samples? + What ground water aquifers in York County are within at most 2 miles of sample results? ## FILTER C: aquifers: county - What samples are within at most 2 miles of aquifers in York County? + What sample results are within at most 2 miles of ground water aquifers in York County? ## FILTER A: streams: state - What streams in Maine are within at most 2 miles of samples? + What streams and flowlines in Maine are within at most 2 miles of sample results? ## FILTER C: streams: state - What samples are within at most 2 miles of streams in Maine? + What sample results are within at most 2 miles of streams and flowlines in Maine? ## FILTER A: streams: county - What streams in York County are within at most 2 miles of samples? + What streams and flowlines in York County are within at most 2 miles of sample results? ## FILTER C: streams: county - What samples are within at most 2 miles of streams in York County? + What sample results are within at most 2 miles of streams and flowlines in York County? ## FILTER A: samples: substance - What PFOA samples are within at most 2 miles of facilities? + What PFOA sample results are within at most 2 miles of facilities? ## FILTER C: samples: substance - What facilities are within at most 2 miles of PFOA samples? + What facilities are within at most 2 miles of PFOA sample results? ## FILTER A: samples: material with label - What Groundwater (GW) samples are within at most 2 miles of facilities? + What Groundwater (GW) sample results are within at most 2 miles of facilities? ## FILTER C: samples: material with label - What facilities are within at most 2 miles of Groundwater (GW) samples? + What facilities are within at most 2 miles of Groundwater (GW) sample results? ## FILTER A: samples: material without label - What Groundwater (GW) samples are within at most 2 miles of facilities? + What Groundwater (GW) sample results are within at most 2 miles of facilities? ## FILTER C: samples: material without label - What facilities are within at most 2 miles of Groundwater (GW) samples? + What facilities are within at most 2 miles of Groundwater (GW) sample results? ## FILTER A: samples: min concentration - What samples (above 4 ng/L) are within at most 2 miles of facilities? + What sample results (above 4 ng/L) are within at most 2 miles of facilities? ## FILTER C: samples: min concentration - What facilities are within at most 2 miles of samples (above 4 ng/L)? + What facilities are within at most 2 miles of sample results (above 4 ng/L)? ## FILTER A: samples: max concentration - What samples (below 70 ng/L) are within at most 2 miles of facilities? + What sample results (below 70 ng/L) are within at most 2 miles of facilities? ## FILTER C: samples: max concentration - What facilities are within at most 2 miles of samples (below 70 ng/L)? + What facilities are within at most 2 miles of sample results (below 70 ng/L)? ## FILTER A: samples: concentration range - What samples (10-1000 ng/L) are within at most 2 miles of facilities? + What sample results (10-1000 ng/L) are within at most 2 miles of facilities? ## FILTER C: samples: concentration range - What facilities are within at most 2 miles of samples (10-1000 ng/L)? + What facilities are within at most 2 miles of sample results (10-1000 ng/L)? ## FILTER A: samples: exclude non-detects - What samples (detections only) are within at most 2 miles of facilities? + What sample results (detections only) are within at most 2 miles of facilities? ## FILTER C: samples: exclude non-detects - What facilities are within at most 2 miles of samples (detections only)? + What facilities are within at most 2 miles of sample results (detections only)? ## FILTER A: samples: range and exclude non-detects - What samples (above 4 ng/L, detections only) are within at most 2 miles of facilities? + What sample results (above 4 ng/L, detections only) are within at most 2 miles of facilities? ## FILTER C: samples: range and exclude non-detects - What facilities are within at most 2 miles of samples (above 4 ng/L, detections only)? + What facilities are within at most 2 miles of sample results (above 4 ng/L, detections only)? ## FILTER A: facilities: industry - What Solid Waste Landfill facilities are within at most 2 miles of samples? + What Solid Waste Landfill facilities are within at most 2 miles of sample results? ## FILTER C: facilities: industry - What samples are within at most 2 miles of Solid Waste Landfill facilities? + What sample results are within at most 2 miles of Solid Waste Landfill facilities? ## FILTER A: waterBodies: water type - What Lake / Pond surface water bodies are within at most 2 miles of samples? + What Lake / Pond surface water bodies are within at most 2 miles of sample results? ## FILTER C: waterBodies: water type - What samples are within at most 2 miles of Lake / Pond surface water bodies? + What sample results are within at most 2 miles of Lake / Pond surface water bodies? ## FILTER A: waterBodies: two water types - What Lake / Pond, Reservoir surface water bodies are within at most 2 miles of samples? + What Lake / Pond, Reservoir surface water bodies are within at most 2 miles of sample results? ## FILTER C: waterBodies: two water types - What samples are within at most 2 miles of Lake / Pond, Reservoir surface water bodies? + What sample results are within at most 2 miles of Lake / Pond, Reservoir surface water bodies? ## FILTER A: streams: stream type - What Stream / River streams are within at most 2 miles of samples? + What Stream / River streams and flowlines are within at most 2 miles of sample results? ## FILTER C: streams: stream type - What samples are within at most 2 miles of Stream / River streams? + What sample results are within at most 2 miles of Stream / River streams and flowlines? ## FILTER A: streams: more than three stream types - What streams of 4 types are within at most 2 miles of samples? + What streams and flowlines of 4 types are within at most 2 miles of sample results? ## FILTER C: streams: more than three stream types - What samples are within at most 2 miles of streams of 4 types? + What sample results are within at most 2 miles of streams and flowlines of 4 types? ## FILTER A: facilities: more than three industries - What facilities in 4 industries are within at most 2 miles of samples? + What facilities in 4 industries are within at most 2 miles of sample results? ## FILTER C: facilities: more than three industries - What samples are within at most 2 miles of facilities in 4 industries? + What sample results are within at most 2 miles of facilities in 4 industries? ## FILTER A: wells: classification with label - What Bedrock wells are within at most 2 miles of samples? + What Bedrock wells are within at most 2 miles of sample results? ## FILTER C: wells: classification with label - What samples are within at most 2 miles of Bedrock wells? + What sample results are within at most 2 miles of Bedrock wells? ## FILTER A: wells: classification without label - What Bedrock wells are within at most 2 miles of samples? + What Bedrock wells are within at most 2 miles of sample results? ## FILTER C: wells: classification without label - What samples are within at most 2 miles of Bedrock wells? + What sample results are within at most 2 miles of Bedrock wells? ## FILTER A: aquifers: bedrock - What bedrock aquifers are within at most 2 miles of samples? + What bedrock ground water aquifers are within at most 2 miles of sample results? ## FILTER C: aquifers: bedrock - What samples are within at most 2 miles of bedrock aquifers? + What sample results are within at most 2 miles of bedrock ground water aquifers? ## FILTER A: aquifers: surficial - What sand & gravel aquifers are within at most 2 miles of samples? + What sand & gravel ground water aquifers are within at most 2 miles of sample results? ## FILTER C: aquifers: surficial - What samples are within at most 2 miles of sand & gravel aquifers? + What sample results are within at most 2 miles of sand & gravel ground water aquifers? ## RELATIONSHIP: near {"type":"near","hops":1} - What samples are within at most 2 miles of facilities? + What sample results are within at most 2 miles of facilities? ## RELATIONSHIP: near {"type":"near","hops":2} - What samples are within at most 3 miles of facilities? + What sample results are within at most 3 miles of facilities? ## RELATIONSHIP: near {"type":"near","hops":3} - What samples are within at most 4 miles of facilities? + What sample results are within at most 4 miles of facilities? ## RELATIONSHIP: near {"type":"near","hops":4} - What samples are within at most 5 miles of facilities? + What sample results are within at most 5 miles of facilities? ## RELATIONSHIP: downstream {"type":"downstream"} - What samples are downstream of facilities? + What sample results are downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream"} - What samples are upstream from facilities? + What sample results are upstream from facilities? ## RELATIONSHIP: upstream {"type":"upstream"} - What samples are upstream from facilities? + What sample results are upstream from facilities? ## RELATIONSHIP: downstream {"type":"downstream","maxDistanceKm":5} - What samples are within 5 km downstream of facilities? + What sample results are within 5 km downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream","maxDistanceKm":5} - What samples are within 5 km upstream from facilities? + What sample results are within 5 km upstream from facilities? ## RELATIONSHIP: downstream {"type":"downstream","maxDistanceKm":10} - What samples are within 10 km downstream of facilities? + What sample results are within 10 km downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream","maxDistanceKm":10} - What samples are within 10 km upstream from facilities? + What sample results are within 10 km upstream from facilities? ## RELATIONSHIP: downstream {"type":"downstream","maxDistanceKm":30} - What samples are within 30 km downstream of facilities? + What sample results are within 30 km downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream","maxDistanceKm":30} - What samples are within 30 km upstream from facilities? + What sample results are within 30 km upstream from facilities? ## RELATIONSHIP: downstream {"type":"downstream","maxDistanceKm":50} - What samples are within 50 km downstream of facilities? + What sample results are within 50 km downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream","maxDistanceKm":50} - What samples are within 50 km upstream from facilities? + What sample results are within 50 km upstream from facilities? ## RELATIONSHIP: downstream {"type":"downstream","maxDistanceKm":100} - What samples are within 100 km downstream of facilities? + What sample results are within 100 km downstream of facilities? ## RELATIONSHIP: upstream {"type":"upstream","maxDistanceKm":100} - What samples are within 100 km upstream from facilities? + What sample results are within 100 km upstream from facilities? diff --git a/engine/tests/blockWording.test.ts b/engine/tests/blockWording.test.ts index fe21936..9649a5d 100644 --- a/engine/tests/blockWording.test.ts +++ b/engine/tests/blockWording.test.ts @@ -15,7 +15,7 @@ const many = LIST_THRESHOLD + 1; const pick = (items: T[]): T[] => items.slice(0, many); const BLOCKS: [string, EntityBlock, string][] = [ - ['streams', { type: 'streams', streamFilters: { ftypes: pick(STREAM_FTYPES).map((o) => o.value) } }, `streams of ${many} types`], + ['streams', { type: 'streams', streamFilters: { ftypes: pick(STREAM_FTYPES).map((o) => o.value) } }, `streams and flowlines of ${many} types`], // Only 3 water types exist today; a fourth (a new FTYPE) would read the same way. ['water bodies', { type: 'waterBodies', waterBodyFilters: { ftypes: [...WATER_BODY_FTYPES.map((o) => o.value), 'Estuary'].slice(0, many) } }, `surface water bodies of ${many} types`], ['wells', { type: 'wells', wellFilters: { wellCategories: ['meUse||a', 'meUse||b', 'meUse||c', 'meUse||d'].slice(0, many) } }, `wells of ${many} types`], @@ -31,7 +31,7 @@ describe('a block with more picks than are named', () => { describe('a block with few picks', () => { it('still names them in front of the noun', () => { const block: EntityBlock = { type: 'streams', streamFilters: { ftypes: [STREAM_FTYPES[0].value] } }; - expect(entityFor('streams').describe(block)).toBe(`${STREAM_FTYPES[0].label} streams`); + expect(entityFor('streams').describe(block)).toBe(`${STREAM_FTYPES[0].label} streams and flowlines`); }); }); @@ -51,3 +51,16 @@ describe('facilities and their industry filter', () => { expect(entityFor('facilities').describe(block, totals)).toBe('facilities with an industry code'); }); }); + +// The unfiltered noun matches the Type menu entry, "Ground Water (Aquifers)" +// (#164). One kind picked keeps its word in front of the noun. +describe('aquifers and their kind filter', () => { + it('reads as ground water aquifers with no filter', () => { + expect(entityFor('aquifers').describe({ type: 'aquifers' })).toBe('ground water aquifers'); + }); + + it('puts one picked kind in front of the noun', () => { + const block: EntityBlock = { type: 'aquifers', aquiferFilters: { aquiferTypes: ['bedrock'] } }; + expect(entityFor('aquifers').describe(block)).toBe('bedrock ground water aquifers'); + }); +}); diff --git a/engine/tests/errors.test.ts b/engine/tests/errors.test.ts index e6b2025..37ec1dd 100644 --- a/engine/tests/errors.test.ts +++ b/engine/tests/errors.test.ts @@ -108,20 +108,20 @@ describe('the advice when a question is too big, with both sides counted', () => it('gives both counts and names the bigger block', () => { expect(outcomeMessage(counted(4528, 459877), question())).toBe( - `${TOO_MUCH} The first block matches 4,528 samples, the second 459,877 facilities. Adding a filter or region to the second block is the most effective change.`, + `${TOO_MUCH} The first block matches 4,528 sample results, the second 459,877 facilities. Adding a filter or region to the second block is the most effective change.`, ); }); it('names the first block when it is the bigger one', () => { expect(outcomeMessage(counted(8738, 12), question())).toBe( - `${TOO_MUCH} The first block matches 8,738 samples, the second 12 facilities. Adding a filter or region to the first block is the most effective change.`, + `${TOO_MUCH} The first block matches 8,738 sample results, the second 12 facilities. Adding a filter or region to the first block is the most effective change.`, ); }); it('gives the counts before the distance advice on a trace', () => { const q = question({ relationship: { type: 'downstream', maxDistanceKm: 30 } }); expect(outcomeMessage(counted(70, 676), q)).toBe( - `${TOO_MUCH} The first block matches 70 samples, the second 676 facilities. Try a shorter distance than 30 km, or run those areas one at a time.`, + `${TOO_MUCH} The first block matches 70 sample results, the second 676 facilities. Try a shorter distance than 30 km, or run those areas one at a time.`, ); }); @@ -137,7 +137,7 @@ describe('the advice when a question is too big, with both sides counted', () => counts: { A: 4528, C: 459877 }, }; expect(partialNotice(result, question())).toBe( - 'Showing incomplete results: York County, Maine could not be answered. The first block matches 4,528 samples, the second 459,877 facilities. Adding a filter or region to the second block is the most effective change.', + 'Showing incomplete results: York County, Maine could not be answered. The first block matches 4,528 sample results, the second 459,877 facilities. Adding a filter or region to the second block is the most effective change.', ); }); }); @@ -154,7 +154,7 @@ describe('the message for a run with no answer', () => { 'No facilities match the second block, so the question has no answer. Try a wider region or fewer filters.', ); expect(outcomeMessage(empty('A'), question())).toBe( - 'No samples match the first block, so the question has no answer. Try a wider region or fewer filters.', + 'No sample results match the first block, so the question has no answer. Try a wider region or fewer filters.', ); }); diff --git a/engine/tests/executor.test.ts b/engine/tests/executor.test.ts index c418617..6ead245 100644 --- a/engine/tests/executor.test.ts +++ b/engine/tests/executor.test.ts @@ -190,7 +190,7 @@ describe('a question too big to run whole', () => { expect(result.status).toBe('success'); if (result.status !== 'success') return; expect(result.partial?.[0]).toEqual({ - step: 'Finding samples near facilities', + step: 'Finding sample results near facilities', failed: ['facilities batch 1 (2/2)'], skipped: [], }); @@ -208,8 +208,8 @@ describe('a question too big to run whole', () => { if (result.status !== 'success') return; // Both discovery steps slice the same way, and each has its own budget. expect(result.partial).toEqual([ - { step: 'Finding samples near facilities', failed: [], skipped: ['facilities batch 4'] }, - { step: 'Finding facilities with samples near them', failed: [], skipped: ['facilities batch 4'] }, + { step: 'Finding sample results near facilities', failed: [], skipped: ['facilities batch 4'] }, + { step: 'Finding facilities with sample results near them', failed: [], skipped: ['facilities batch 4'] }, ]); } finally { vi.useRealTimers(); @@ -805,7 +805,7 @@ describe('with chunking on refusal turned off', () => { const on = await run(SAMPLES_NEAR_LANDFILLS, networkOnBatch2()); expect(on.status).toBe('success'); if (on.status !== 'success') return; - expect(on.partial).toEqual([{ step: 'Loading details for samples', failed: ['batch 2'], skipped: [] }]); + expect(on.partial).toEqual([{ step: 'Loading details for sample results', failed: ['batch 2'], skipped: [] }]); }); it('sends every batch however long the step takes, where chunking on stops at 300s', async () => { diff --git a/engine/tests/questionText.test.ts b/engine/tests/questionText.test.ts index 6f71adf..a60debf 100644 --- a/engine/tests/questionText.test.ts +++ b/engine/tests/questionText.test.ts @@ -73,7 +73,7 @@ it('collapses each block to "all counties" against its own state', () => { }, totals, ); - expect(text).toContain('samples in all counties in Illinois'); + expect(text).toContain('sample results in all counties in Illinois'); expect(text).toContain('facilities in all counties in Maine'); }); diff --git a/engine/tests/stepLabels.test.ts b/engine/tests/stepLabels.test.ts index b3db816..10c6c55 100644 --- a/engine/tests/stepLabels.test.ts +++ b/engine/tests/stepLabels.test.ts @@ -44,13 +44,14 @@ it('every question shape gets correct step labels and step set', () => { const steps = planPipeline(question(a, rel, c)); combinations++; - // Nothing unlabelled, and no raw camelCase type name leaking through. + // Nothing unlabelled, and no raw type name leaking through. Some labels + // contain their type name ("ground water aquifers"), so the labels come + // out first: whatever type name is left over is a leak. for (const label of steps.map((s) => s.description)) { assert.ok(label.trim().length > 0, `empty description: ${where}`); + const withoutLabels = ENTITY_TYPES.reduce((text, type) => text.split(entityFor(type).label).join(''), label); for (const type of ENTITY_TYPES) { - if (type !== entityFor(type).label) { - assert.ok(!label.includes(type), `raw type name "${type}" in "${label}": ${where}`); - } + assert.ok(!withoutLabels.includes(type), `raw type name "${type}" in "${label}": ${where}`); } } @@ -121,12 +122,12 @@ it('labels the reported downstream question', () => { assert.deepEqual( reported.map((s) => s.description), [ - 'Counting samples in the first block', + 'Counting sample results in the first block', 'Counting facilities in the second block', - 'Finding samples downstream of facilities', - 'Finding facilities with samples downstream of them', + 'Finding sample results downstream of facilities', + 'Finding facilities with sample results downstream of them', 'Loading downstream stream geometries', - 'Loading details for samples', + 'Loading details for sample results', 'Loading details for facilities', 'Loading region boundaries', ], @@ -140,9 +141,9 @@ it('swaps steps, not words, for the same question upstream', () => { relationship: { type: 'upstream' }, blockC: { type: 'facilities' }, } as AnalysisQuestion); - assert.equal(up.find((s) => s.type === 'FIND_ANCHOR_IRIS')!.description, 'Finding samples upstream from facilities'); + assert.equal(up.find((s) => s.type === 'FIND_ANCHOR_IRIS')!.description, 'Finding sample results upstream from facilities'); assert.equal( up.find((s) => s.type === 'FIND_TARGET_IRIS')!.description, - 'Finding facilities with samples upstream from them', + 'Finding facilities with sample results upstream from them', ); }); From d061ba567ba29e9bb5a467f0af38536b72436034 Mon Sep 17 00:00:00 2001 From: Prayas Lashkari Date: Tue, 17 Nov 2026 15:29:06 -0500 Subject: [PATCH 2/2] docs(changelog): add type menu names in question text to week 47 Co-Authored-By: Claude --- docs/changelog/2026-W47.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/changelog/2026-W47.md b/docs/changelog/2026-W47.md index 47e5f1a..4522b5d 100644 --- a/docs/changelog/2026-W47.md +++ b/docs/changelog/2026-W47.md @@ -19,3 +19,17 @@ **Files touched**: `engine/entities/facilities.ts`, `engine/entities/types.ts`, `engine/templates/hydrate.ts`, `engine/cacheKey.ts` (`DATA_VERSION` 2026-11b), `ui/components/Map/facilityIndustry.ts` (new), `ui/components/Map/MapPopup.tsx`, `ui/components/Map/FacilityLayer.tsx`, `ui/components/Map/StackedPopup.tsx`, `docs/DEBUGGING.md`, `docs/QUERY-SWEEP.md` (Part 12), `docs/SCHEMA.md`, `docs/wiki/Dropdowns Industry.md` **Prevention**: `engine/tests/facilityRegion.test.ts` checks the region check on every facilities side with a region and none without, the collapsed side, the no-filter bind and the optional industry in details (with `LIVE_SPARQL=1`, the Cumberland and Cook counts); `ui/tests/facilityPopup.test.tsx` and `ui/tests/stackedPopup.test.tsx` check "Unspecified or Unknown"; `engine/tests/questions/critical.ts` adds facilities in Cook near Cook wells with no filter. + +2. **Changed: Question Text and Step Labels Use the Type Menu's Names** (2026-11-17) + + **Component**: `label` on the samples, aquifers and streams modules in `engine/entities/` + + **Change**: Issue #164, a follow-up from #70. The question sentence, the pipeline step labels and the count and empty-result messages now say "sample results", "ground water aquifers" and "streams and flowlines", matching the Type menu. Filtered wordings keep their shape with the new noun ("bedrock ground water aquifers", "streams and flowlines of 4 types"). + + **Unchanged**: the SPARQL every question sends (`query-shapes.txt` did not move), entity type names, the cache key, and the hand-written dashboard card titles. + + **Follow-up**: cached dashboard results still list their queries under the old step names until `npm run warm-cache` runs after merge. + + **Files touched**: `engine/entities/samples.ts`, `engine/entities/aquifers.ts`, `engine/entities/streams.ts` + + **Prevention**: `engine/tests/blockWording.test.ts` checks the aquifer and streams wording; `engine/tests/stepLabels.test.ts` checks the sample step labels, and its raw-type-name check now allows labels that contain their type name; `engine/tests/__snapshots__/question-text.txt` re-recorded.