Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/changelog/2026-W47.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions engine/entities/aquifers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> = {
surficial: 'sand & gravel',
bedrock: 'bedrock',
Expand Down
2 changes: 1 addition & 1 deletion engine/entities/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion engine/entities/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
234 changes: 117 additions & 117 deletions engine/tests/__snapshots__/question-text.txt

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions engine/tests/blockWording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const many = LIST_THRESHOLD + 1;
const pick = <T>(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`],
Expand All @@ -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`);
});
});

Expand All @@ -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');
});
});
10 changes: 5 additions & 5 deletions engine/tests/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
);
});

Expand All @@ -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.',
);
});
});
Expand All @@ -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.',
);
});

Expand Down
8 changes: 4 additions & 4 deletions engine/tests/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
});
Expand All @@ -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();
Expand Down Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion engine/tests/questionText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down
21 changes: 11 additions & 10 deletions engine/tests/stepLabels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}

Expand Down Expand Up @@ -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',
],
Expand All @@ -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',
);
});
Loading