diff --git a/api-v3/test/unit/f6-1-operational-context-consistency.test.ts b/api-v3/test/unit/f6-1-operational-context-consistency.test.ts index 4e388cf..ea6900a 100644 --- a/api-v3/test/unit/f6-1-operational-context-consistency.test.ts +++ b/api-v3/test/unit/f6-1-operational-context-consistency.test.ts @@ -75,12 +75,25 @@ test('F6.1 historical operational lists read Company and Area from the parent In assert.doesNotMatch(reports, /context_asset\.operator_company_id/); }); -test('F6.1 WEB keeps operator selection at creation and removes it from Inventory edits', () => { +test('F6.1 WEB Inventory searches use physical Area and never the operator snapshot filter', () => { + const inspectionEditor = source('../web-v2/src/pages/InspectionVisitEditorF4Page.tsx'); + const fieldDiscoveries = source('../web-v2/src/pages/FieldDiscoveriesPage.tsx'); + + for (const page of [inspectionEditor, fieldDiscoveries]) { + assert.match(page, /listAssets\(\{[\s\S]{0,250}operationalAreaId:/); + assert.doesNotMatch(page, /listAssets\(\{[\s\S]{0,250}operatorCompanyId:/); + } +}); + +test('F6.1 WEB derives the creation snapshot from the active Area operator and removes it from Inventory edits', () => { const editor = source('../web-v2/src/pages/AssetEditorPage.tsx'); const contextPanel = source('../web-v2/src/features/assets/AssetContextHistoryPanel.tsx'); assert.match(editor, /createAsset\(\{[\s\S]*operatorCompanyId: operatorCompanyId \|\| null/); assert.doesNotMatch(editor, /updateAsset\(id, \{[^}]*operatorCompanyId/); + assert.doesNotMatch(editor, /parent\.operatorCompany/); + assert.match(editor, /listCompaniesForArea\(operationalAreaId\)\.then\(\(loadedCompanies\)/); + assert.match(editor, /loadedCompanies\.length === 1 \? loadedCompanies\[0\]\.id : ''/); assert.match(editor, /Snapshot histórico de alta/); assert.match(contextPanel, /Cambiar contexto físico/); assert.doesNotMatch(contextPanel, /operatorCompanyId:/);