Core Changes: - Completely rewrote CustomResolver reducer with dependency-ordered processing - Enhanced plugin initialization with proper dependency injection - Improved delta processing and property value tracking - Added robust error handling for duplicate property IDs Resolver Improvements: - Updated to use new accumulator structure - Implemented execution order processing for plugins - Enhanced debug logging and error reporting - Simplified TimestampResolver by removing unused initializer Configuration Updates: - Added TypeScript path aliases for test helpers - Improved module resolution paths Key Benefits: - More robust plugin dependency management - More efficient state updates - Enhanced type safety - Better error messages and debugging - More consistent plugin initialization This refactoring focuses on improving the robustness of the resolver, especially around plugin lifecycle management and dependency handling. The changes ensure better separation of concerns and more predictable behavior when dealing with complex plugin dependencies.
63 lines
1.6 KiB
TypeScript
63 lines
1.6 KiB
TypeScript
import { createOrchestrator, type NodeConfig } from '@src/orchestration';
|
|
import type { NodeHandle } from '@src/orchestration/types';
|
|
// Increase test timeout to 30 seconds
|
|
jest.setTimeout(30000);
|
|
|
|
describe('Run (Orchestrated)', () => {
|
|
const orchestrator = createOrchestrator('in-memory');
|
|
let nodeHandle: NodeHandle;
|
|
let apiUrl: string;
|
|
|
|
beforeAll(async () => {
|
|
// Configure and start the node
|
|
const config: NodeConfig = {
|
|
id: 'app-001',
|
|
};
|
|
nodeHandle = await orchestrator.startNode(config);
|
|
apiUrl = nodeHandle.getApiUrl?.() || 'http://localhost:3000'; // Default URL if getApiUrl is not available
|
|
}, 60000); // Increase timeout to 60s for this hook
|
|
|
|
afterAll(async () => {
|
|
// Stop the node
|
|
if (nodeHandle) {
|
|
await orchestrator.stopNode(nodeHandle);
|
|
}
|
|
});
|
|
|
|
test('can put a new user and fetch it', async () => {
|
|
// Create a new record
|
|
const createResponse = await fetch(`${apiUrl}/user`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
id: 'peon-1',
|
|
properties: {
|
|
name: 'Peon',
|
|
age: 263,
|
|
},
|
|
}),
|
|
});
|
|
|
|
const createdUser = await createResponse.json();
|
|
expect(createdUser).toMatchObject({
|
|
id: 'peon-1',
|
|
properties: {
|
|
name: 'Peon',
|
|
age: 263,
|
|
},
|
|
});
|
|
|
|
// Read the created record
|
|
const getResponse = await fetch(`${apiUrl}/user/peon-1`);
|
|
const fetchedUser = await getResponse.json();
|
|
|
|
expect(fetchedUser).toMatchObject({
|
|
id: 'peon-1',
|
|
properties: {
|
|
name: 'Peon',
|
|
age: 263,
|
|
},
|
|
});
|
|
});
|
|
});
|