Currently, document reports in the system are missing titles at the top of their content. The attached screenshot shows an "SDG Report" document that begins directly with a "Table of Contents" section without any document title or header identifying what the document is about.
- Document template system (both static and dynamic templates)
- Document rendering/generation system
- All report types that use document templates
Current Behavior:
- Documents start directly with their content (e.g., "Table of Contents")
- No title header is displayed at the top of the document
- Document identification is only visible in browser tabs or page metadata
Expected Behavior:
- All document templates should include the document title in
<h1>
tags at the top of the template - The document title should include both the document type and the virtual entity name (e.g., "John Lewis - ESG Report")
- This applies to both static and dynamic document templates
- The title should be prominent and clearly identify what the document is about
- Issue ID: EKO-218
- Screenshot Evidence:
tmp/linear-images/desc_e09e5dbd.png
shows an "SDG Report" document missing the title header - URL Context: Document appears to be part of the ekointel.app/customer/documents system
- Document Type: The example shows what appears to be an "Inflexion and Trust" report with SDG content
- Title Format: Documents should display titles in the format:
{Virtual Entity Name} - {Document Type}
(e.g., "John Lewis - ESG Report") - HTML Structure: Title must be wrapped in
<h1>
tags for proper semantic structure - Placement: Title should appear at the very top of the document content, before any other elements including Table of Contents
- Scope: This change must be applied to:
- All existing document templates
- Dynamic document templates
- Any document generation systems
- Browser Context: Issue visible across web browsers in the customer application
- User Impact: Affects document readability and professional presentation
- System Integration: May require updates to template rendering systems
- All generated documents display a clear, properly formatted title at the top
- Title includes both entity name and document type
- Title uses proper HTML semantic structure (
<h1>
tags) - Change is applied consistently across all document templates
- No regression in existing document functionality
The issue involves a critical gap in the document creation pipeline where [ENTITY_NAME]
placeholders in dynamic template titles are not being substituted with actual entity names during document creation. While the system correctly displays entity context in breadcrumbs and navigation (showing "John Lewis" and "Run 3659"), the document content itself shows literal [ENTITY_NAME] - EKO Report
instead of the expected "John Lewis - EKO Report".
Through systematic code tracing, I identified the complete document creation flow and the precise point of failure:
-
Dynamic Template Generation (
/apps/customer/components/editor/templates/dynamic-template-generator.ts
, line 276):content: [{ type: 'text', text: `[ENTITY_NAME] - ${displayName} Report` }]
- Creates TipTap JSON structure with literal
[ENTITY_NAME]
placeholder text - Templates are generated with proper hierarchical structure but placeholders remain unprocessed
- Creates TipTap JSON structure with literal
-
Template Selection Processing (
/apps/customer/components/editor/templates/DocumentTemplates.tsx
, lines 1273-1289):// Update template title and content for entity-aware naming if (selectedEntityName && requiresEntity) { // Update the template name to include entity name modifiedTemplate.name = createDocumentTitle(template.name, selectedEntityName) // Update data structure titles if template uses structured data if (modifiedTemplate.data?.content) { modifiedTemplate.data = { ...modifiedTemplate.data, content: modifiedTemplate.data.content.map((node: any) => { if (node.type === 'heading' && node.attrs?.level === 1) { return createTitleHeading(createDocumentTitle(template.name, selectedEntityName)) } return node // ← CRITICAL GAP: Placeholders in text content are not processed }), } } }
- Current Logic: Only replaces entire level-1 headings with new
createTitleHeading()
content - Missing Logic: Does not recursively process text nodes within TipTap JSON to replace
[ENTITY_NAME]
placeholders - Impact: Dynamic templates with placeholder text pass through unchanged
- Current Logic: Only replaces entire level-1 headings with new
-
Document Creation (
/apps/customer/app/customer/documents/new/page.tsx
, line 174):data: template.data || null,
- Template data inserted directly into database without further placeholder processing
- Unsubstituted placeholders persist in final document content
The core issue lies in the hierarchical nature of TipTap JSON structures. Dynamic templates create nested content structures like:
{
"type": "heading",
"attrs": { "level": 1 },
"content": [
{
"type": "text",
"text": "[ENTITY_NAME] - SDG Report"
}
]
}
The current handleSelectTemplate()
function only processes the top level of the content array and replaces entire heading nodes, but it doesn't recursively traverse nested content
arrays to find and replace text-level placeholders.
What's needed is a recursive function to traverse the entire TipTap JSON structure and replace [ENTITY_NAME]
placeholders in all text nodes:
function substitutePlaceholders(content: any[], entityName: string): any[] {
return content.map(node => {
if (node.content) {
return {
...node,
content: substitutePlaceholders(node.content, entityName)
}
}
if (node.type === 'text' && node.text) {
return {
...node,
text: node.text.replace(/\[ENTITY_NAME\]/g, entityName)
}
}
return node
})
}
The investigation confirms that entity context IS available at the point where substitution should occur:
selectedEntityName
is properly passed tohandleSelectTemplate()
- Entity names are correctly displayed in breadcrumbs and navigation
- The entity selection system works correctly
- The only missing piece is the recursive text processing logic
Location: /apps/customer/components/editor/templates/dynamic-template-generator.ts
- Database Source: Templates generated from
xfer_model_sections
table in Supabase customer database - ESG Models: Supports multiple frameworks - EKO, SDG, Doughnut Economics, Plant-based Treaty
- Structure: Templates create hierarchical TipTap documents with proper placeholder integration
- Title Generation: Line 276 specifically creates
[ENTITY_NAME] - ${displayName} Report
format
Current Flow:
dynamic-template-generator.ts
creates templates with[ENTITY_NAME]
placeholdersDocumentTemplates.tsx
receives entity context but only processes heading replacements- Templates with unprocessed placeholders passed to document creation
- Documents stored in
doc_documents
table with literal placeholder text
- Database Field:
doc_documents.title
column stores user-editable document titles - UI Location: Editable via
EditableLabel
component in document editor header - Current Usage: Used for browser tab titles, document lists, but NOT displayed in document content
Entity Data Structure (from xfer_entities
table):
entity_xid
: Unique entity identifier (e.g., "GVNZgYj9x7")name
: Display name (e.g., "John Lewis", "Inflexion and Trust")type
: Entity type ("company", "organisation")
Entity Selection: DocumentEntityRunSelector
component manages entity/run context for document generation
TipTap Document Schema: Documents use ProseMirror-compatible JSON with:
type: 'doc'
root containercontent: []
array of document elements- First element is typically
tableOfContents
or content sections - Missing: No standardized title/heading structure at document start
- Multi-Column Layout Template: Uses
type: 'heading', attrs: { level: 1 }
for titles - ESG Report Template: Has hardcoded
type: 'heading'
with "ESG Report" text - Other Templates: Use markdown strings starting directly with content
- Current Structure: Start with
tableOfContents
, thenreportSummary
- Title Format: Model-based naming (e.g., "SDG Report", "EKO Report")
- Missing Entity Context: No entity name incorporated in generated titles
Python HTML Templates (/backoffice/src/eko/analysis_v2/effects/templates/
):
- Base Template:
base.html
uses{% block title %}
and{% block heading %}
- Report Template:
report.html
extends base with entity-specific titles - Current Implementation: Backend templates DO include entity names in titles (e.g., "Effect Analysis for {{ data.entity }}")
- Shows
EditableLabel
for title editing in header - Document content rendered via
EkoDocumentEditor
- Gap: Document content doesn't display the title from metadata
- Sets
window.document.title
for PDF naming - Shows document title in print header (outside document content)
- Gap: Document content itself lacks title structure for printed content
- Uses
PublicDocumentViewer
for read-only display - Gap: Shared documents lack proper title display
- TableOfContentsExtension: Searches for
h1-h6
headings in document - ReportSectionExtension: Generates content sections
- ReportSummaryExtension: Creates summary sections
- All Extensions: Support heading structures and would work with title additions
- Documents Storage:
doc_documents
table withtitle
,entity_id
,data
fields - Entity Information:
xfer_entities
provides entity names for title generation - Template Metadata: Dynamic templates can access entity context during generation
-
Inconsistent Title Implementation: Backend Python templates include entity names in titles, but frontend document templates do not
-
Entity Context Available: Both document metadata (
entity_id
) and entity name information (xfer_entities.name
) are available for title generation -
Template System Flexibility: Both static and dynamic templates support TipTap heading structures via
type: 'heading'
nodes -
Missing Standardization: No consistent pattern for title placement across different template types
-
Print/Share Impact: Missing titles affect professional presentation in print and public sharing contexts
-
Existing Infrastructure: Table of Contents system already searches for headings, so adding titles would improve navigation
- Must maintain compatibility with existing TipTap document structure
- Need to preserve template flexibility for both static and dynamic generation
- Dynamic templates require entity context at generation time
- Static templates need to handle cases without entity context
- Templates must maintain professional ESG reporting standards
- Entity names must be accurate and properly formatted
- Changes must not break existing documents or templates
- Print and sharing functionality must be preserved
Based on analysis, the solution must:
- Add standardized
<h1>
titles to all document templates (static and dynamic) - Include entity names in titles where entity context is available (e.g., "John Lewis - ESG Report")
- Support fallback titles for templates without entity context (e.g., "Meeting Notes", "Task List")
- Maintain template flexibility for both simple content and complex TipTap JSON structures
- Ensure consistency across editor, print, and public sharing contexts
- Preserve existing functionality of table of contents and navigation systems
The solution involves systematically adding standardized <h1>
titles to all document templates while maintaining the existing TipTap document structure and template flexibility. The approach addresses both static templates and dynamic ESG report templates with proper entity name integration.
-
Title Format Standardization: Implement consistent title format:
{Entity Name} - {Document Type}
for entity-based documents, with fallback to just{Document Type}
for generic templates -
TipTap Document Structure: Add title as the first element in the document content array using the existing
type: 'heading', attrs: { level: 1 }
structure -
Entity Context Integration: Leverage existing entity information from
xfer_entities
table and document metadata to populate entity names in titles -
Template System Compatibility: Maintain backward compatibility with existing template structure while adding the new title element
-
Utility Function Approach: Create reusable utility functions for title generation to ensure consistency across static and dynamic templates
- Gradual Rollout: Update templates systematically, testing each type before moving to the next
- Fallback Handling: Ensure templates work gracefully when entity information is unavailable
- Existing Document Preservation: Changes only affect new document generation, not existing documents
- Cross-Context Testing: Verify functionality across editor, print, and sharing contexts
- Table of Contents: New titles will automatically appear in table of contents due to existing heading detection
- Document Editor: Titles will be editable like other heading elements
- Print System: Titles will appear in printed documents improving professional presentation
- Public Sharing: Shared documents will have proper identification headers
Create the foundational utility functions and type definitions needed for title generation across all templates.
Update all static templates in DocumentTemplates.tsx to include proper titles with entity integration where applicable.
Enhance the dynamic template generator to include entity-specific titles for all ESG report types.
Comprehensive testing across all document types, contexts, and edge cases to ensure proper functionality.
- Title Generation Functions: Test utility functions with various entity and document type combinations
- Template Structure Validation: Ensure generated templates have correct TipTap JSON structure
- Edge Case Handling: Test scenarios with missing entity data, special characters in names, etc.
- Document Generation: Test full document creation flow with new titles
- Cross-Context Functionality: Verify titles work in editor, print, and sharing contexts
- Existing Document Compatibility: Ensure existing documents continue to function properly
- Visual Verification: Confirm titles appear correctly formatted in all document types
- Professional Presentation: Validate that documents maintain ESG reporting standards
- Print and Share Quality: Ensure professional appearance in print and shared documents
- TipTap Editor System: Relies on existing TipTap document structure and heading support
- Entity Data Availability: Requires access to
xfer_entities
table data for entity names - Template System Architecture: Depends on current static and dynamic template systems
- Entity Context Limitations: Some static templates may not have entity context available
- Template Migration Complexity: Ensuring all template types are updated consistently
- Cross-Browser Compatibility: Title rendering must work across all supported browsers
- Database Schema Stability: Relies on current structure of
xfer_entities
anddoc_documents
tables - TipTap Library Version: Must maintain compatibility with current TipTap version
The comprehensive test suite covers all aspects of the document title functionality across different contexts and edge cases. Tests are designed to fail initially (red phase of TDD) and will pass once the implementation is complete.
- Coverage: All 8 static templates (Blank Document, Meeting Notes, Project Proposal, Weekly Report, Task List, Research Notes, Brainstorming Session, Multi-Column Layout)
- Test Focus: Verify each template displays correct
<h1>
title as first document element - Expected Behavior: Templates should show simple document type names (e.g., "Meeting Notes", "Task List")
- File Location:
apps/customer/tests/issues/issue-eko-218.spec.ts
- Coverage: ESG reports and other entity-dependent templates
- Test Focus: Verify titles include entity names in format "Entity Name - Document Type"
- Expected Behavior: Templates should dynamically generate titles using selected entity context
- Edge Cases: Fallback behavior when entity context unavailable
- Coverage: Document structure validation and semantic HTML
- Test Focus:
- Title appears as first element before Table of Contents
- Proper
<h1>
semantic structure usage - Title editability within TipTap editor
- Integration Points: Table of Contents system integration
- Coverage: Editor, print, and sharing contexts
- Test Focus:
- Titles display correctly in document editor
- Print view includes proper titles
- Shared documents show titles consistently
- Contexts Tested: Edit view, print view, public sharing
- Coverage: Error scenarios and data quality issues
- Test Focus:
- Special characters in entity names
- Missing entity data handling
- Prevention of "undefined" or "null" in titles
- Title format consistency across document lifecycle
- Red Phase: All tests initially fail as title functionality doesn't exist yet
- Green Phase: Implementation will make tests pass systematically
- Refactor Phase: Code cleanup while maintaining passing tests
- TestUtils Class: Leverages existing
TestUtils
for consistent test patterns - Authentication: Automatic login handling for authenticated routes
- Document Creation: Standardized document creation from templates
- Editor Interaction: Reliable TipTap editor interaction patterns
- Real Browser Testing: Tests run in actual browser environment
- User-Centric Approach: Tests simulate real user workflows
- Stable Selectors: Uses
data-testid
attributes for reliable element selection - Timeout Handling: Appropriate timeouts for complex template loading
- Primary Scenario: Tests with selected entity for entity-dependent templates
- Fallback Scenario: Tests without entity selection for basic templates
- Edge Cases: Special characters in entity names, missing entity data
Template Type | Entity Required | Expected Title Format |
---|---|---|
Static Basic | No | "Template Name" |
Static Business | No | "Template Name" |
Dynamic ESG | Yes | "Entity Name - Template Name" |
Dynamic Reports | Yes | "Entity Name - Template Name" |
- All document templates display proper
<h1>
titles - Entity-specific templates include entity names correctly
- Titles appear as first document element before other content
- Table of contents integration works properly
- Semantic HTML structure (
<h1>
tags) usage - TipTap editor compatibility maintained
- Cross-browser functionality verified
- Performance impact minimal
- Professional document presentation
- Consistent title formatting
- Editable titles in document editor
- Print and sharing contexts display titles correctly
- Isolated Tests: Each test is independent and can run separately
- Clean State: Tests clean up after themselves
- Robust Selectors: Uses stable element selection strategies
- Error Handling: Graceful handling of test environment variations
This comprehensive testing approach ensures that the document title functionality works correctly across all use cases while maintaining system reliability and user experience quality.
After conducting a comprehensive code review, I have identified critical issues that explain why users report entity names are still not appearing in document titles. The implementation appears complete on the surface, but there are fundamental flaws in the entity detection and title generation system that prevent the feature from working correctly.
PRIMARY ISSUE: Dynamic Templates Fail Entity Detection
- Critical Problem: Dynamic templates generated by
generateDynamicTemplates()
do NOT contain literal[ENTITY_ID]
strings that the detection logic requires - Detection Logic:
JSON.stringify(template.data).includes('[ENTITY_ID]')
only works for static templates - Impact: All dynamic templates (ESG Reports, SDG Reports, etc.) are treated as non-entity-requiring templates, completely bypassing entity name logic
- User Experience: Users selecting "John Lewis" + "ESG Report" get generic titles like "ESG Report" instead of "John Lewis - ESG Report"
Evidence from Code Analysis:
Static Templates (Working):
// Static ESG Report template - Contains literal [ENTITY_ID] placeholders
{
endpoint: '/report/entity/[ENTITY_ID]/[RUN_ID]/harm/model/sdg/section/13_climate_action',
// ✅ This IS detected by JSON.stringify().includes('[ENTITY_ID]')
}
Dynamic Templates (Broken):
// Dynamic template generation - Constructs endpoints at runtime
endpoint: `/report/entity/[ENTITY_ID]/[RUN_ID]/harm/model/${model}/section/${section.section}?includeDisclosures=true`
// ❌ Template literals are resolved, no literal '[ENTITY_ID]' string for detection
- Severity: Critical - Core functionality broken
- Location:
DocumentTemplates.tsx
line 1253, 1368 - Issue:
JSON.stringify(template.data).includes('[ENTITY_ID]')
fails for dynamic templates - Impact: Dynamic templates never get entity names in titles
- Root Cause: Detection relies on string matching, but dynamic templates don't contain literal detection strings
- Severity: High - Hardcoded titles without entity context
- Location:
dynamic-template-generator.ts
line 274 - Issue: Static title generation:
${displayName} Report
without entity names - Impact: All dynamic templates get generic titles regardless of entity selection
- Code:
content: [{ type: 'text', text: '${displayName} Report' }]
- No entity context
- Severity: Medium - System design issue
- Issue: Entity requirement detection based on string matching instead of explicit metadata
- Impact: Fragile detection system prone to false negatives
- Technical Debt: Poor separation between detection logic and template metadata
- Severity: Medium - Performance and security concerns
- Issues:
- JSON.stringify on large template objects for simple detection
- API endpoint patterns exposed in client-side template data
- Production console logging exposes internal structure
Files Examined: 5 critical system files Issues Found: 13 total issues (2 Critical, 3 High, 6 Medium, 2 Low) Testing Status: Tests pass but don't catch the actual user-reported problem User Impact: Feature appears implemented but doesn't work for primary use case
1. Template Processing Flow (DocumentTemplates.tsx lines 1232-1290)
// Current broken flow:
const allTemplates = [...dynamicTemplates, ...templates] // Dynamic templates first
const requiresEntity = template.data && JSON.stringify(template.data).includes('[ENTITY_ID]')
// ❌ Dynamic templates NEVER match this detection
if (selectedEntityName && requiresEntity) {
modifiedTemplate.name = createDocumentTitle(template.name, selectedEntityName)
// ❌ This code path is NEVER executed for dynamic templates
}
2. Dynamic Template Entity Detection (Line 1368)
const requiresEntity = template.data && JSON.stringify(template.data).includes('[ENTITY_ID]')
const isDisabled = requiresEntity && (!selectedEntity || !entitiesLoaded)
// ❌ Dynamic templates are never disabled, appear selectable, but don't work correctly
3. Title Generation Inconsistency
- Static Templates: Have proper entity detection and title modification
- Dynamic Templates: Generate with static titles, no entity integration
- Result: Inconsistent user experience between template types
Requirements Analysis:
- ❌ Dynamic templates do NOT include entity names (primary user case)
- ✅ Static templates include proper titles
- ❌ Entity-specific templates fail to detect entity requirements
- ✅ Semantic HTML structure is correct where implemented
- ❌ Professional presentation compromised for ESG reports
System Integration:
- ❌ Entity selection system works but isn't properly integrated with dynamic templates
- ✅ TipTap editor integration functional
- ❌ Template detection system fundamentally flawed
- ✅ Database queries and caching functional
Location: dynamic-template-generator.ts
Required: Add explicit entity requirement metadata to generated templates
// Fix required:
template: DynamicTemplate = {
id,
name,
description,
category,
icon,
requiresEntity: true, // ← ADD THIS EXPLICIT METADATA
data: {...}
}
Location: dynamic-template-generator.ts
line 274
Required: Modify title generation to accept entity context
// Fix required - Dynamic title generation with entity context
if (entityName) {
content.push({
type: 'heading',
attrs: { level: 1 },
content: [{ type: 'text', text: `${entityName} - ${displayName} Report` }],
})
} else {
// Fallback for templates without entity context
}
Location: DocumentTemplates.tsx
lines 1253, 1368
Required: Support both string detection and explicit metadata
// Fix required:
const requiresEntity = template.requiresEntity ||
(template.data && JSON.stringify(template.data).includes('[ENTITY_ID]'))
Current Tests Pass But Miss Core Issue:
- Tests verify template structure but not actual user workflow
- Integration tests don't catch entity detection failure
- E2E tests may use mocked data that bypasses the real problem
Additional Testing Required:
- End-to-end tests with real entity selection and dynamic template creation
- Integration tests specifically for entity detection logic
- User journey tests from entity selection through document creation
User Impact: HIGH
- Primary use case (entity-specific ESG reports) completely broken
- Users experience inconsistent behavior between template types
- Professional document presentation compromised
Business Impact: HIGH
- Core ESG reporting functionality non-functional
- User reports indicate feature not working despite apparent implementation
- Potential reputation impact from broken key feature
Status: Implementation is incomplete and non-functional for primary use case Recommendation: DO NOT deploy to production until critical fixes are implemented Priority: Immediate action required to fix core functionality
Next Steps Required:
- Implement explicit entity metadata for dynamic templates
- Fix dynamic template title generation with entity context
- Update entity detection logic to support both detection methods
- Add comprehensive integration tests for entity detection flow
- Perform end-to-end testing with real user workflows
The implementation must be completed before this feature can be considered ready for production deployment.
-
CRITICAL: Implement recursive placeholder substitution in DocumentTemplates
- Location:
/apps/customer/components/editor/templates/DocumentTemplates.tsx
lines 1278-1289 - Task: Add recursive
substitutePlaceholders()
function to process TipTap JSON and replace[ENTITY_NAME]
placeholders - Issue:
handleSelectTemplate()
only replaces entire headings, doesn't process text nodes with placeholders - Impact: Users see literal
[ENTITY_NAME] - EKO Report
instead ofJohn Lewis - EKO Report
- Implementation:
function substitutePlaceholders(content: any[], entityName: string): any[] { return content.map(node => { if (node.content) { return { ...node, content: substitutePlaceholders(node.content, entityName) } } if (node.type === 'text' && node.text) { return { ...node, text: node.text.replace(/\[ENTITY_NAME\]/g, entityName) } } return node }) }
- Location:
-
HIGH: Integrate placeholder substitution into template processing
- Location:
/apps/customer/components/editor/templates/DocumentTemplates.tsx
lines 1273-1289 - Task: Call
substitutePlaceholders()
onmodifiedTemplate.data.content
when entity context is available - Issue: Current logic only handles heading replacement but not recursive text substitution
- Impact: Dynamic templates with entity context don't get proper title substitution
- Location:
-
MEDIUM: Add comprehensive testing for placeholder substitution
- Location: Test files for DocumentTemplates component
- Task: Add tests that verify
[ENTITY_NAME]
placeholders are replaced in TipTap JSON content - Issue: Current tests don't cover the actual user-reported problem of placeholder substitution
- Impact: Bugs in placeholder logic not caught during development
-
HIGH: Add DynamicTemplate interface property for entity requirements
- Location:
/apps/customer/components/editor/templates/dynamic-template-generator.ts
interface - Task: Extend DynamicTemplate interface to include
requiresEntity?: boolean
property - Issue: No explicit way to mark dynamic templates as requiring entities
- Impact: Forces reliance on fragile string detection methods
- Location:
-
HIGH: Update DocumentTemplates type checking
- Location:
/apps/customer/components/editor/templates/DocumentTemplates.tsx
- Task: Update TypeScript types to handle both static and dynamic template entity detection
- Issue: Type system doesn't enforce proper entity requirement handling
- Impact: Runtime errors and inconsistent behavior
- Location:
-
MEDIUM: Replace JSON.stringify detection with explicit metadata
- Location:
/apps/customer/components/editor/templates/DocumentTemplates.tsx
- Task: Refactor entity detection to use explicit template metadata instead of string matching
- Issue: Inefficient and fragile detection method using JSON.stringify
- Impact: Performance overhead and potential false negatives
- Location:
-
MEDIUM: Add comprehensive integration tests for entity detection
- Location:
/apps/customer/tests/issues/issue-eko-218.spec.ts
- Task: Add tests that verify entity detection works for both static and dynamic templates
- Issue: Current tests don't catch the core entity detection failure
- Impact: Bugs slip through testing that break core user functionality
- Location:
-
MEDIUM: Remove production console logging
- Location:
/apps/customer/components/editor/templates/dynamic-template-generator.ts
- Task: Remove or conditionally disable console logging in production
- Issue: Production logs expose internal template generation details
- Impact: Security concern and log noise
- Location:
-
LOW: Add proper error handling for missing entity context
- Location: Dynamic template generation functions
- Task: Add comprehensive error handling when entity data is unavailable
- Issue: Potential runtime errors when entity data is missing
- Impact: Poor user experience with unclear error states
-
LOW: Optimize template processing performance
- Location: Template generation and selection logic
- Task: Optimize entity detection and template processing for large template sets
- Issue: JSON.stringify and inefficient processing on large objects
- Impact: Potential performance degradation with many templates
-
CRITICAL: Create end-to-end test for entity + dynamic template workflow
- Location:
/apps/customer/tests/issues/issue-eko-218.spec.ts
- Task: Add test that verifies complete user workflow from entity selection to document creation
- Issue: No test that validates the complete user journey that is broken
- Impact: Core user functionality broken but not caught by tests
- Location:
-
HIGH: Add unit tests for entity detection logic
- Location: Template component test files
- Task: Test entity detection for both static and dynamic templates
- Issue: Entity detection logic not properly tested
- Impact: Logic bugs not caught during development
-
MEDIUM: Validate fix with real user data
- Location: Manual testing checklist
- Task: Test with actual entity names and dynamic templates from database
- Issue: Tests may pass with mocked data but fail with real data
- Impact: Production deployment may still fail for users
-
LOW: Update template documentation with entity requirements
- Location: Template system documentation
- Task: Document how entity detection works and requirements for template development
- Issue: Unclear how entity detection system is supposed to work
- Impact: Future development may repeat same mistakes
-
LOW: Add architectural documentation for template system
- Location: System documentation
- Task: Document the relationship between static/dynamic templates and entity detection
- Issue: Complex system without clear architectural documentation
- Impact: Hard to maintain and extend template system