Skip to content

Commit fb72ebb

Browse files
committed
refactor: remove patchDiscoveryEndpoints function and update ObjectForm test to access record properties
1 parent 833f8be commit fb72ebb

3 files changed

Lines changed: 3 additions & 34 deletions

File tree

apps/console/src/App.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,6 @@ import { PageView } from './components/PageView';
1919
import { ReportView } from './components/ReportView';
2020
import { ExpressionProvider } from './context/ExpressionProvider';
2121

22-
/**
23-
* Patch: MSW discovery response uses 'routes' instead of 'endpoints'.
24-
* This normalizes the shape until @objectstack/plugin-msw is fixed upstream.
25-
*/
26-
function patchDiscoveryEndpoints(adapter: ObjectStackAdapter) {
27-
try {
28-
const client = adapter.getClient();
29-
const info = (client as any).discoveryInfo;
30-
if (info?.routes && !info.endpoints) {
31-
info.endpoints = info.routes;
32-
}
33-
} catch {
34-
// Silently ignore — adapter may not expose getClient()
35-
}
36-
}
37-
3822
import { useParams } from 'react-router-dom';
3923
import { ThemeProvider } from './components/theme-provider';
4024

@@ -83,10 +67,6 @@ export function AppContent() {
8367

8468
await adapter.connect();
8569

86-
// Patch: MSW discovery returns 'routes' instead of 'endpoints'.
87-
// TODO: Fix in @objectstack/plugin-msw to emit correct discovery shape.
88-
patchDiscoveryEndpoints(adapter);
89-
9070
setDataSource(adapter);
9171
} catch (err) {
9272
console.error('[Console] Failed to initialize:', err);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ describe('ObjectForm with MSW Integration', () => {
487487

488488
// Verify data is persisted by fetching it
489489
const result = await client.data.get('contact', createdId);
490-
expect(result.name).toBe('Persist Test');
491-
expect(result.email).toBe('persist@example.com');
490+
expect(result.record.name).toBe('Persist Test');
491+
expect(result.record.email).toBe('persist@example.com');
492492
});
493493
});
494494
});

apps/console/src/mocks/browser.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,7 @@ export async function startMockServer() {
5757
logRequests: true
5858
});
5959

60-
// WORKAROUND: ObjectKernel's PluginLoader uses object spread ({ ...plugin })
61-
// which copies only own-enumerable properties, stripping prototype methods.
62-
// This binds all prototype methods so they survive the spread.
63-
// TODO: Remove once @objectstack/runtime fixes PluginLoader to preserve prototypes.
64-
const fixedMswPlugin = { ...mswPlugin } as any;
65-
for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(mswPlugin))) {
66-
if (typeof (mswPlugin as any)[key] === 'function' && key !== 'constructor') {
67-
fixedMswPlugin[key] = (mswPlugin as any)[key].bind(mswPlugin);
68-
}
69-
}
70-
71-
await kernel.use(fixedMswPlugin);
60+
await kernel.use(mswPlugin);
7261

7362
await kernel.bootstrap();
7463

0 commit comments

Comments
 (0)