Skip to content

Commit 310cdd0

Browse files
committed
Enhance ObjectView to support additional fields for timeline, map, and gantt views
1 parent 09ec3c4 commit 310cdd0

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

apps/console/src/__tests__/ViewSwitching.test.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,36 @@ describe('Console View Switching Integration', () => {
9797

9898
renderObjectView();
9999

100-
// Should NOT show "Unknown component type"
100+
// 1. Check registry has the component (verifies import)
101+
expect(ComponentRegistry.has('object-timeline')).toBe(true);
102+
103+
// 2. Check no error boundary (verifies unknown type)
101104
expect(screen.queryByText(/Unknown component type/i)).not.toBeInTheDocument();
102105

103-
expect(ComponentRegistry.has('object-timeline')).toBe(true);
106+
// 3. Check CONTENT is rendered (verifies options/props passed correctly + not blank)
107+
// Since we are using the real Timeline component, we need to know what it renders when empty.
108+
// It usually renders a list or empty state.
109+
// If options were missing, it might crash or render completely blank.
110+
// Let's assume it renders at least the wrapper or "No items"
111+
const timeline = document.querySelector('.object-timeline') || document.querySelector('ol');
112+
expect(timeline).toBeInTheDocument();
104113
});
105114

106115
it('switches to Map view correctly', () => {
107116
mockSearchParams.set('view', 'sites');
108117
renderObjectView();
109118

110-
expect(screen.queryByText(/Unknown component type/i)).not.toBeInTheDocument();
111119
expect(ComponentRegistry.has('object-map')).toBe(true);
120+
expect(screen.queryByText(/Unknown component type/i)).not.toBeInTheDocument();
121+
122+
// 3. Verify content
123+
// Map usually renders a container.
124+
// If we missed options mapping, it might be 0 height or error.
125+
const mapContainer = document.querySelector('.object-map') || document.querySelector('[class*="leaflet"]');
126+
// Since we don't have leaflet installed/mocked fully, it might be just a div.
127+
// But checking that *something* is in the View area is key.
128+
const viewArea = document.querySelector('.flex-1.overflow-hidden.relative');
129+
expect(viewArea).not.toBeEmptyDOMElement();
112130
});
113131

114132
it('switches to Gantt view correctly', () => {

apps/console/src/components/ObjectView.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ export function ObjectView({ dataSource, objects, onEdit }: any) {
114114
titleField: activeView.titleField || 'name',
115115
colorField: activeView.colorField,
116116
allDayField: activeView.allDayField,
117+
},
118+
timeline: {
119+
dateField: activeView.dateField || activeView.startDateField || 'due_date',
120+
titleField: activeView.titleField || objectDef.titleField || 'name',
121+
descriptionField: activeView.descriptionField,
122+
},
123+
map: {
124+
locationField: activeView.locationField || 'location',
125+
titleField: activeView.titleField || objectDef.titleField || 'name',
126+
},
127+
gantt: {
128+
startDateField: activeView.startDateField || 'start_date',
129+
endDateField: activeView.endDateField || 'end_date',
130+
progressField: activeView.progressField,
131+
dependenciesField: activeView.dependenciesField,
117132
}
118133
}
119134
};

0 commit comments

Comments
 (0)