From 2e0a841fd1ce85e7e8579e7cb964092fa6cf4107 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Fri, 8 May 2026 22:21:46 +0100 Subject: [PATCH] Relax 2 grammar-fragile boundary assertions to symbol-presence checks The boundary test had two stale assertions failing because the implementation grammar shifted while preserving the contract: - usePatrolIntelligenceState now imports buildPatrolInvestigationContextSummary inside a multi-line grouped import. Replace the single-line literal match with two checks (symbol present + module present). - patrolInvestigationContextModel now passes a precomputed commandCount through normalizeNonNegativeCount to formatCommandSummary instead of '.commands?.length ?? 0'. Assert the helper is invoked and the legacy '.commands.join' path is absent without prescribing the exact arg shape. Both contracts are still enforced; the assertions just stop tracking import formatting and helper-call argument shape. --- .../frontendResourceTypeBoundaries.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts index a47c7a94b..894864fa4 100644 --- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts +++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts @@ -4340,9 +4340,11 @@ describe('frontend resource type boundaries', () => { expect(aiIntelligenceSummaryModelSource).toContain( 'export function normalizeIntelligenceSummary', ); - expect(patrolIntelligenceStateSource).toContain( - "import { buildPatrolInvestigationContextSummary } from './patrolInvestigationContextModel';", - ); + // Verify the symbol is imported from the model without prescribing a + // specific single- vs multi-line import shape; usePatrolIntelligenceState + // groups several patrolInvestigationContextModel imports together. + expect(patrolIntelligenceStateSource).toContain('buildPatrolInvestigationContextSummary'); + expect(patrolIntelligenceStateSource).toContain("from './patrolInvestigationContextModel'"); expect(patrolIntelligenceStateSource).not.toContain('recent_changes?.length'); expect(patrolIntelligenceStateSource).not.toContain('governed resource${'); expect(patrolInvestigationContextModelSource).toContain( @@ -4357,9 +4359,11 @@ describe('frontend resource type boundaries', () => { expect(patrolInvestigationContextModelSource).toContain( 'export function buildPatrolAssistantFindingBriefing', ); - expect(patrolInvestigationContextModelSource).toContain( - 'formatCommandSummary(record.proposed_fix.commands?.length ?? 0)', - ); + // formatCommandSummary is the canonical helper for command-count copy. + // The model now passes a precomputed commandCount through + // normalizeNonNegativeCount instead of computing from a commands array, + // so assert the helper is used and the legacy join path is not. + expect(patrolInvestigationContextModelSource).toContain('formatCommandSummary('); expect(patrolInvestigationContextModelSource).not.toContain( 'record.proposed_fix.commands.join', );