Skip to content

Commit 80fa066

Browse files
committed
fix: update BASE_URL to localhost in test files; enhance data handling in ObjectKanban and ObjectTimeline components
1 parent 923a0fb commit 80fa066

File tree

6 files changed

+36
-8
lines changed

6 files changed

+36
-8
lines changed

packages/plugin-calendar/src/ObjectCalendar.msw.test.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setupServer } from 'msw/node';
77
import { http, HttpResponse } from 'msw';
88
import React from 'react';
99

10-
const BASE_URL = 'http://test-api.com';
10+
const BASE_URL = 'http://localhost';
1111

1212
// --- Mock Data ---
1313

@@ -32,13 +32,22 @@ const mockEvents = {
3232
// --- MSW Setup ---
3333

3434
const handlers = [
35+
http.options('*', () => {
36+
return new HttpResponse(null, { status: 200 });
37+
}),
38+
3539
http.get(`${BASE_URL}/api/v1`, () => {
3640
return HttpResponse.json({ status: 'ok', version: '1.0.0' });
3741
}),
3842

3943
// Data Query: GET /api/v1/data/events
4044
http.get(`${BASE_URL}/api/v1/data/events`, () => {
4145
return HttpResponse.json(mockEvents);
46+
}),
47+
48+
// Metadata Query
49+
http.get(`${BASE_URL}/api/v1/metadata/object/events`, () => {
50+
return HttpResponse.json({ fields: {} });
4251
})
4352
];
4453

packages/plugin-form/src/ObjectForm.msw.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ContactObject } from '../../../examples/crm/src/objects/contact.object'
1313
// Register widget renderers
1414
registerAllFields();
1515

16-
const BASE_URL = process.env.OBJECTSTACK_API_URL || 'http://test-api.com';
16+
const BASE_URL = process.env.OBJECTSTACK_API_URL || 'http://localhost';
1717

1818
// --- Mock Data ---
1919

packages/plugin-grid/src/ObjectGrid.msw.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ContactObject } from '../../../examples/crm/src/objects/contact.object'
1212

1313
registerAllFields();
1414

15-
const BASE_URL = process.env.OBJECTSTACK_API_URL || 'http://test-api.com';
15+
const BASE_URL = process.env.OBJECTSTACK_API_URL || 'http://localhost';
1616

1717
// --- Mock Data ---
1818

packages/plugin-kanban/src/ObjectKanban.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ export const ObjectKanban: React.FC<ObjectKanbanProps> = ({
4242
const results = await dataSource.find(schema.objectName, {
4343
options: { $top: 100 } // Fetch up to 100 cards
4444
});
45-
// Handle { value: [] } OData shape or direct array
46-
const data = (results as any).value || results;
47-
console.log("ObjectKanban fetched:", JSON.stringify(data));
45+
// Handle { value: [] } OData shape or { data: [] } shape or direct array
46+
let data = results;
47+
if ((results as any).value) {
48+
data = (results as any).value;
49+
} else if ((results as any).data) {
50+
data = (results as any).data;
51+
}
52+
4853
if (Array.isArray(data)) {
4954
setFetchedData(data);
5055
}

packages/plugin-timeline/src/ObjectTimeline.msw.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { setupServer } from 'msw/node';
77
import { http, HttpResponse } from 'msw';
88
import React from 'react';
99

10-
const BASE_URL = 'http://test-api.com';
10+
const BASE_URL = 'http://localhost';
1111

1212
// --- Mock Data ---
1313

@@ -22,6 +22,14 @@ const mockMilestones = {
2222
// --- MSW Setup ---
2323

2424
const handlers = [
25+
http.options('*', () => {
26+
return new HttpResponse(null, { status: 200 });
27+
}),
28+
29+
http.get(`${BASE_URL}/api/v1`, () => {
30+
return HttpResponse.json({ status: 'ok', version: '1.0.0' });
31+
}),
32+
2533
http.get(`${BASE_URL}/api/v1/data/milestones`, () => {
2634
return HttpResponse.json(mockMilestones);
2735
})

packages/plugin-timeline/src/ObjectTimeline.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ export const ObjectTimeline: React.FC<ObjectTimelineProps> = ({
4848
const results = await dataSource.find(schema.objectName, {
4949
options: { $top: 100 }
5050
});
51-
const data = (results as any).value || results;
51+
let data = results;
52+
if ((results as any).value) {
53+
data = (results as any).value;
54+
} else if ((results as any).data) {
55+
data = (results as any).data;
56+
}
57+
5258
if (Array.isArray(data)) {
5359
setFetchedData(data);
5460
}

0 commit comments

Comments
 (0)