feat(coding): add Main Data Service Host adapter

This commit is contained in:
2026-08-26 19:10:37 +08:00
parent 003fe210f4
commit c19227a4d4
10 changed files with 1771 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { readFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
describe('Data Service Host API registration', () => {
it('registers before the existing Works catch-all', async () => {
const source = await readFile(resolve('electron/api/route-handlers.ts'), 'utf8');
expect(source).toMatch(
/import\s+\{\s*handleDataServiceRoutes\s*\}\s+from\s+['"]\.\/routes\/data-service['"]/,
);
const routeList = source.match(/hostApiRouteHandlers[^=]*=\s*\[([\s\S]*?)\];/);
expect(routeList?.[1]).toBeDefined();
const dataServiceIndex = routeList?.[1].indexOf('handleDataServiceRoutes') ?? -1;
const worksIndex = routeList?.[1].indexOf('handleWorksRoutes') ?? -1;
expect(dataServiceIndex).toBeGreaterThanOrEqual(0);
expect(worksIndex).toBeGreaterThan(dataServiceIndex);
});
});