1
0

ui-map-api.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /**
  2. * `GET /api/map` — the module aggregation behind the Map (CG-49).
  3. *
  4. * Against a real indexed fixture over a real loopback server, like the rest of
  5. * the viewer's API suite. The fixture is shaped to produce exactly the things
  6. * the endpoint has to get right and that a synthetic payload cannot prove:
  7. *
  8. * - a façade (`src/index.ts`) that must stay its own box rather than being
  9. * folded in with the loose type declarations beside it,
  10. * - real `imports` edges, so the `declared` subset is not always equal to the
  11. * raw count and the layering has something trustworthy to rest on,
  12. * - a two-file import cycle, so the file-level cycle report has a component to
  13. * find,
  14. * - a test directory, so the `test` flag and the root default can be checked.
  15. *
  16. * The pure layout — layering, cycle-breaking, ports — is tested without a
  17. * server in `ui-map-model.test.ts`.
  18. */
  19. import { describe, it, expect, beforeAll, afterAll } from 'vitest';
  20. import * as http from 'http';
  21. import * as fs from 'fs';
  22. import * as os from 'os';
  23. import * as path from 'path';
  24. import CodeGraph from '../src/index';
  25. import { createGraphApi, startUiServer, type GraphApi, type UiServerHandle } from '../src/ui-server';
  26. import {
  27. moduleIdFor,
  28. normalizeRoot,
  29. pickDefaultDepth,
  30. pickDefaultRoot,
  31. resetMapCache,
  32. } from '../src/ui-server/api/map';
  33. let server: UiServerHandle;
  34. let api: GraphApi;
  35. let tempDir: string;
  36. let projectRoot: string;
  37. function request(requestPath: string): Promise<{ status: number; body: string; type?: string }> {
  38. return new Promise((resolve, reject) => {
  39. const req = http.request(
  40. {
  41. host: '127.0.0.1',
  42. port: server.port,
  43. path: requestPath,
  44. method: 'GET',
  45. headers: { Host: `127.0.0.1:${server.port}` },
  46. setHost: false,
  47. },
  48. (res) => {
  49. const chunks: Buffer[] = [];
  50. res.on('data', (c: Buffer) => chunks.push(c));
  51. res.on('end', () =>
  52. resolve({
  53. status: res.statusCode ?? 0,
  54. body: Buffer.concat(chunks).toString('utf-8'),
  55. type: res.headers['content-type'],
  56. })
  57. );
  58. }
  59. );
  60. req.on('error', reject);
  61. req.end();
  62. });
  63. }
  64. async function getMap(query = ''): Promise<any> {
  65. const res = await request(`/api/map${query}`);
  66. expect(res.type).toBe('application/json; charset=utf-8');
  67. expect(res.status).toBe(200);
  68. return JSON.parse(res.body);
  69. }
  70. function write(root: string, rel: string, body: string): void {
  71. const full = path.join(root, rel);
  72. fs.mkdirSync(path.dirname(full), { recursive: true });
  73. fs.writeFileSync(full, body);
  74. }
  75. beforeAll(async () => {
  76. tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-ui-map-'));
  77. projectRoot = path.join(tempDir, 'project');
  78. write(projectRoot, 'src/types.ts', `export interface Row {\n id: string;\n}\n`);
  79. write(
  80. projectRoot,
  81. 'src/db/schema.ts',
  82. `export const TABLES = ['rows'];\n`
  83. );
  84. // db -> core, the LIGHT direction of the mutual pair below.
  85. write(
  86. projectRoot,
  87. 'src/db/store.ts',
  88. `import { Row } from '../types';
  89. import { normalise } from '../core/util';
  90. export class Store {
  91. rows: Row[] = [];
  92. put(row: Row): void {
  93. this.rows.push(normalise(row));
  94. }
  95. }
  96. `
  97. );
  98. // util <-> store is a deliberate two-file import cycle: it gives the file
  99. // cycle report a component to find and the module graph a mutual pair.
  100. write(
  101. projectRoot,
  102. 'src/core/util.ts',
  103. `import { Row } from '../types';
  104. import { Store } from '../db/store';
  105. export function normalise(row: Row): Row {
  106. return { id: row.id.trim() };
  107. }
  108. export function count(store: Store): number {
  109. return store.rows.length;
  110. }
  111. `
  112. );
  113. // Two directory levels under `src`, so depth=2 has something real to split.
  114. write(
  115. projectRoot,
  116. 'src/core/passes/trim.ts',
  117. `import { Row } from '../../types';
  118. export function trim(row: Row): Row {
  119. return { id: row.id.slice(0, 8) };
  120. }
  121. `
  122. );
  123. // core -> db, several times over: the HEAVY direction.
  124. write(
  125. projectRoot,
  126. 'src/core/engine.ts',
  127. `import { Store } from '../db/store';
  128. import { TABLES } from '../db/schema';
  129. import { trim } from './passes/trim';
  130. import { Row } from '../types';
  131. export class Engine {
  132. store = new Store();
  133. boot(): string[] {
  134. return TABLES;
  135. }
  136. add(row: Row): void {
  137. this.store.put(trim(row));
  138. this.store.put(row);
  139. }
  140. }
  141. `
  142. );
  143. write(
  144. projectRoot,
  145. 'src/api/handler.ts',
  146. `import { Engine } from '../core/engine';
  147. import { Row } from '../types';
  148. export function handle(engine: Engine, row: Row): void {
  149. engine.add(row);
  150. }
  151. `
  152. );
  153. write(
  154. projectRoot,
  155. 'src/api/routes.ts',
  156. `import { Engine } from '../core/engine';
  157. import { handle } from './handler';
  158. export function route(engine: Engine): void {
  159. handle(engine, { id: 'x' });
  160. }
  161. `
  162. );
  163. write(
  164. projectRoot,
  165. 'src/index.ts',
  166. `import { Engine } from './core/engine';
  167. import { route } from './api/routes';
  168. export function start(): void {
  169. route(new Engine());
  170. }
  171. `
  172. );
  173. write(
  174. projectRoot,
  175. '__tests__/engine.test.ts',
  176. `import { Engine } from '../src/core/engine';
  177. export function testBoot(): string[] {
  178. return new Engine().boot();
  179. }
  180. `
  181. );
  182. const cg = CodeGraph.initSync(projectRoot, {
  183. config: { include: ['src/**/*.ts', '__tests__/**/*.ts'], exclude: [] },
  184. });
  185. await cg.indexAll();
  186. cg.resolveReferences();
  187. cg.close();
  188. const viewerDir = path.join(tempDir, 'viewer');
  189. fs.mkdirSync(viewerDir, { recursive: true });
  190. fs.writeFileSync(path.join(viewerDir, 'index.html'), '<!doctype html><div id="app"></div>');
  191. resetMapCache();
  192. api = createGraphApi({ projectRoot });
  193. server = await startUiServer({ projectRoot, viewerDir, port: 0, api: api.handler });
  194. }, 120_000);
  195. afterAll(async () => {
  196. api?.close();
  197. await server?.close();
  198. resetMapCache();
  199. if (tempDir && fs.existsSync(tempDir)) fs.rmSync(tempDir, { recursive: true, force: true });
  200. });
  201. describe('moduleIdFor', () => {
  202. it('names a module after the first `depth` segments under the root', () => {
  203. expect(moduleIdFor('src/core/engine.ts', 'src', 1)).toEqual({ id: 'src/core', facade: false });
  204. expect(moduleIdFor('src/a/b/c.ts', 'src', 2)).toEqual({ id: 'src/a/b', facade: false });
  205. expect(moduleIdFor('a/b/c.ts', '', 1)).toEqual({ id: 'a', facade: false });
  206. });
  207. it('keeps a façade as its own box and buckets the other loose files', () => {
  208. expect(moduleIdFor('src/index.ts', 'src', 1)).toEqual({ id: 'src/index.ts', facade: true });
  209. expect(moduleIdFor('src/lib.rs', 'src', 1)?.facade).toBe(true);
  210. expect(moduleIdFor('pkg/__init__.py', 'pkg', 1)?.facade).toBe(true);
  211. expect(moduleIdFor('src/types.ts', 'src', 1)).toEqual({
  212. id: 'src/(root files)',
  213. facade: false,
  214. });
  215. expect(moduleIdFor('types.ts', '', 1)).toEqual({ id: '(root files)', facade: false });
  216. });
  217. it('buckets a loose file into the directory it is actually in, not the top one', () => {
  218. // Two segments at depth 2 is a loose file inside `src/a`, so it belongs to
  219. // that directory's bucket. Folding it into `src/(root files)` would claim a
  220. // file lives somewhere it does not.
  221. expect(moduleIdFor('src/a/loose.ts', 'src', 2)).toEqual({
  222. id: 'src/a/(root files)',
  223. facade: false,
  224. });
  225. });
  226. it('returns null for a file outside the root', () => {
  227. expect(moduleIdFor('__tests__/x.test.ts', 'src', 1)).toBeNull();
  228. // A sibling whose name merely starts with the root is not under it.
  229. expect(moduleIdFor('srcx/y.ts', 'src', 1)).toBeNull();
  230. });
  231. });
  232. describe('normalizeRoot', () => {
  233. it('treats `src`, `src/` and `./src` as one root', () => {
  234. expect(normalizeRoot('src')).toBe('src');
  235. expect(normalizeRoot('src/')).toBe('src');
  236. expect(normalizeRoot('./src')).toBe('src');
  237. expect(normalizeRoot('src\\')).toBe('src');
  238. });
  239. it('treats the repository root as the empty string however it is written', () => {
  240. expect(normalizeRoot('')).toBe('');
  241. expect(normalizeRoot('.')).toBe('');
  242. expect(normalizeRoot('/')).toBe('');
  243. expect(normalizeRoot(undefined)).toBe('');
  244. });
  245. });
  246. describe('pickDefaultRoot', () => {
  247. it('picks the directory holding a clear majority of the non-test symbols', () => {
  248. expect(
  249. pickDefaultRoot([
  250. { path: 'src/a.ts', symbols: 80, test: false },
  251. { path: 'scripts/b.ts', symbols: 5, test: false },
  252. { path: '__tests__/c.ts', symbols: 900, test: true },
  253. ])
  254. ).toBe('src');
  255. });
  256. it('falls back to the repository root when no directory dominates', () => {
  257. expect(
  258. pickDefaultRoot([
  259. { path: 'a/one.ts', symbols: 10, test: false },
  260. { path: 'b/two.ts', symbols: 10, test: false },
  261. { path: 'c/three.ts', symbols: 10, test: false },
  262. ])
  263. ).toBe('');
  264. expect(pickDefaultRoot([{ path: 'flat.ts', symbols: 4, test: false }])).toBe('');
  265. });
  266. });
  267. describe('pickDefaultDepth', () => {
  268. /** `n` files under `dir`, each carrying `each` symbols. */
  269. function spread(dir: string, n: number, each: number, test = false) {
  270. return Array.from({ length: n }, (_, i) => ({
  271. path: `${dir}/f${i}.ts`,
  272. symbols: each,
  273. test,
  274. }));
  275. }
  276. it('goes deeper when one box holds the program', () => {
  277. // The shape this rule exists for: a React-Native-ish repo whose whole app
  278. // is under `src/`. At depth 1 the map is a box labelled `src` and nothing
  279. // else — 285 files and two thirds of the symbols, unopenable.
  280. const files = [
  281. ...spread('src/components', 119, 12),
  282. ...spread('src/app', 53, 21),
  283. ...spread('src/api', 47, 7),
  284. ...spread('src/utils', 24, 6),
  285. ...spread('ios/CaptureView', 63, 28),
  286. ...spread('ios/Camera', 3, 38),
  287. ...spread('.github/workflows', 4, 0),
  288. ];
  289. expect(pickDefaultDepth(files, '')).toBe(2);
  290. });
  291. it('keeps a repository whose directories ARE its modules at one level', () => {
  292. const files = [
  293. ...spread('src/db', 8, 40),
  294. ...spread('src/graph', 9, 40),
  295. ...spread('src/mcp', 7, 40),
  296. ...spread('src/search', 5, 40),
  297. ...spread('src/sync', 4, 40),
  298. ];
  299. expect(pickDefaultDepth(files, 'src')).toBe(1);
  300. });
  301. it('does not open a dominant box that has nothing in it', () => {
  302. // `src/core` holds most of the symbols but only three files: this is a
  303. // small project honestly drawn, not a coarse grouping.
  304. const files = [
  305. ...spread('src/core', 3, 90),
  306. ...spread('src/db', 2, 10),
  307. ...spread('src/api', 2, 10),
  308. { path: 'src/index.ts', symbols: 5, test: false },
  309. ];
  310. expect(pickDefaultDepth(files, 'src')).toBe(1);
  311. });
  312. it('keeps going while the picture is still one box', () => {
  313. // `frontend/` then `frontend/src/` — two levels of packaging before the
  314. // code. Neither is a map; the third level is.
  315. const files = [
  316. ...spread('frontend/src/screens', 15, 10),
  317. ...spread('frontend/src/components', 14, 10),
  318. ...spread('frontend/src/hooks', 8, 10),
  319. ...spread('frontend/src/api', 6, 10),
  320. ...spread('backend/app', 5, 8),
  321. ];
  322. expect(pickDefaultDepth(files, '')).toBe(3);
  323. });
  324. it('stops before a deeper grouping becomes a crowd', () => {
  325. const files = [
  326. ...spread('src/a', 30, 10),
  327. ...Array.from({ length: 70 }, (_, i) => ({
  328. path: `src/b/m${i}/f.ts`,
  329. symbols: 1,
  330. test: false,
  331. })),
  332. ];
  333. // Depth 2 is dominated by `src/a`, but depth 3 would draw 71 boxes.
  334. expect(pickDefaultDepth(files, '')).toBe(2);
  335. });
  336. it('does not chase a tree that has no more levels to give', () => {
  337. const files = [
  338. ...spread('src/a', 30, 10),
  339. ...spread('src/b', 2, 1),
  340. ];
  341. expect(pickDefaultDepth(files, 'src')).toBe(1);
  342. });
  343. it('counts only the modules the map draws by default', () => {
  344. // Test files are hidden unless the reader asks for them, so a depth that
  345. // is only "enough boxes" once tests are counted is not enough boxes.
  346. const files = [
  347. ...spread('src/app', 40, 10),
  348. ...spread('src/__tests__/a', 12, 10, true),
  349. ...spread('src/__tests__/b', 12, 10, true),
  350. ...spread('src/__tests__/c', 12, 10, true),
  351. ];
  352. expect(pickDefaultDepth(files, 'src')).toBe(1);
  353. });
  354. });
  355. describe('GET /api/map', () => {
  356. it('is listed by the API index', async () => {
  357. const res = await request('/api');
  358. const body = JSON.parse(res.body);
  359. expect(body.endpoints.map((e: any) => e.path)).toContain('/api/map');
  360. });
  361. it('opens on the source directory and keeps the façade its own box', async () => {
  362. const map = await getMap();
  363. expect(map.root).toBe('src');
  364. expect(map.depth).toBe(1);
  365. const ids = map.modules.map((m: any) => m.id);
  366. expect(ids).toEqual(['src/(root files)', 'src/api', 'src/core', 'src/db', 'src/index.ts']);
  367. expect(map.modules.find((m: any) => m.id === 'src/core').files).toBe(3);
  368. const facade = map.modules.find((m: any) => m.id === 'src/index.ts');
  369. expect(facade.facade).toBe(true);
  370. expect(facade.files).toBe(1);
  371. expect(facade.symbols).toBeGreaterThan(0);
  372. // Nothing under `src` is a test, so the default root already excludes them.
  373. expect(map.modules.every((m: any) => m.test === false)).toBe(true);
  374. });
  375. it('offers every top-level directory as a root, plus the repository itself', async () => {
  376. const map = await getMap();
  377. expect(map.roots[0]).toEqual({ root: '', label: 'whole repository', files: map.index.files });
  378. expect(map.roots.map((r: any) => r.root)).toEqual(
  379. expect.arrayContaining(['', 'src', '__tests__'])
  380. );
  381. });
  382. it('counts cross-module edges only, with a declared subset and named pairs', async () => {
  383. const map = await getMap();
  384. const link = map.links.find((l: any) => l.source === 'src/api' && l.target === 'src/core');
  385. expect(link).toBeTruthy();
  386. expect(link.count).toBeGreaterThan(0);
  387. // Every kind's count has to add up to the link's own count, or the tooltip
  388. // and the stroke width are describing two different things.
  389. expect(link.byKind.reduce((sum: number, k: any) => sum + k.count, 0)).toBe(link.count);
  390. // `import { Engine }` is a declared dependency; it must survive as one.
  391. expect(link.declared).toBeGreaterThan(0);
  392. expect(link.declared).toBeLessThanOrEqual(link.count);
  393. expect(link.topPairs.length).toBeGreaterThan(0);
  394. expect(link.topPairs.length).toBeLessThanOrEqual(4);
  395. expect(link.topPairs.every((p: any) => p.declared <= p.count)).toBe(true);
  396. // No module ever links to itself: same-module edges are not dependencies.
  397. expect(map.links.every((l: any) => l.source !== l.target)).toBe(true);
  398. });
  399. it('keeps the heavier direction of a mutual pair heavier', async () => {
  400. const map = await getMap();
  401. const coreToDb = map.links.find((l: any) => l.source === 'src/core' && l.target === 'src/db');
  402. const dbToCore = map.links.find((l: any) => l.source === 'src/db' && l.target === 'src/core');
  403. expect(coreToDb).toBeTruthy();
  404. expect(dbToCore).toBeTruthy();
  405. expect(coreToDb.count).toBeGreaterThan(dbToCore.count);
  406. });
  407. it('reports the file-level cycle the fixture contains', async () => {
  408. const map = await getMap();
  409. expect(map.cycles.total).toBeGreaterThanOrEqual(1);
  410. const knot = map.cycles.items.find((c: any) =>
  411. c.files.includes('src/core/util.ts') && c.files.includes('src/db/store.ts')
  412. );
  413. expect(knot, JSON.stringify(map.cycles)).toBeTruthy();
  414. expect(knot.size).toBe(knot.files.length);
  415. expect(knot.modules).toEqual(expect.arrayContaining(['src/core', 'src/db']));
  416. expect(map.cycles.shown).toBe(map.cycles.items.length);
  417. });
  418. it('lists each module\'s files, capped, with the true total beside them', async () => {
  419. const map = await getMap();
  420. for (const module of map.modules) {
  421. expect(module.fileList.total).toBe(module.files);
  422. expect(module.fileList.shown).toBe(module.fileList.items.length);
  423. expect(module.fileList.truncated).toBe(module.fileList.shown < module.fileList.total);
  424. expect(module.fileList.items).toEqual([...module.fileList.items].sort());
  425. }
  426. // A module's files are everything BELOW it, not just the files directly in
  427. // it: `src/core` at depth 1 owns `src/core/passes/trim.ts` too, and the
  428. // panel's list has to match the count on the box.
  429. const core = map.modules.find((m: any) => m.id === 'src/core');
  430. expect(core.fileList.items).toEqual([
  431. 'src/core/engine.ts',
  432. 'src/core/passes/trim.ts',
  433. 'src/core/util.ts',
  434. ]);
  435. });
  436. it('says how many references the confidence floor excluded', async () => {
  437. const map = await getMap();
  438. expect(map.excluded.confidenceBelow).toBe(0.6);
  439. expect(map.excluded.uncertainEdges).toBeGreaterThanOrEqual(0);
  440. });
  441. it('answers the whole repository, where the tests are a test module', async () => {
  442. const map = await getMap('?root=&depth=1');
  443. expect(map.root).toBe('');
  444. const ids = map.modules.map((m: any) => m.id);
  445. expect(ids).toEqual(expect.arrayContaining(['src', '__tests__']));
  446. expect(map.modules.find((m: any) => m.id === '__tests__').test).toBe(true);
  447. expect(map.modules.find((m: any) => m.id === 'src').test).toBe(false);
  448. expect(map.links.some((l: any) => l.source === '__tests__' && l.target === 'src')).toBe(true);
  449. });
  450. it('splits deeper when asked, and `src/` is the same root as `src`', async () => {
  451. const deep = await getMap('?root=src&depth=2');
  452. const ids = deep.modules.map((m: any) => m.id);
  453. // A directory two levels down becomes its own box; a file loose one level
  454. // down joins that level's bucket rather than being promoted to a module.
  455. expect(ids).toContain('src/core/passes');
  456. expect(ids).toContain('src/core/(root files)');
  457. expect(ids).not.toContain('src/core');
  458. // …but the bucket keeps its name only because `src/core/passes` sits beside
  459. // it. `src/api` has nothing below it, so its bucket IS `src/api` and saying
  460. // otherwise would name a directory the repository does not have.
  461. expect(ids).toContain('src/api');
  462. expect(ids).not.toContain('src/api/(root files)');
  463. const slashed = await getMap('?root=src%2F&depth=2');
  464. expect(slashed.modules).toEqual(deep.modules);
  465. });
  466. it('counts the files outside each module that reference into it', async () => {
  467. const map = await getMap('?root=src&depth=1');
  468. const by = new Map<string, any>(map.modules.map((m: any) => [m.id, m]));
  469. // `src/types.ts` and `src/index.ts` are what the rest of the fixture
  470. // imports, so the bucket holding types is the most depended-on box.
  471. const types = by.get('src/(root files)');
  472. expect(types.dependents.files).toBeGreaterThan(0);
  473. expect(types.dependents.modules).toBeGreaterThan(1);
  474. // Every count is FILES OUTSIDE the module: never more than the rest of the
  475. // repository, and a module's own internal imports never inflate it.
  476. const total = map.modules.reduce((sum: number, m: any) => sum + m.files, 0);
  477. for (const module of map.modules) {
  478. expect(module.dependents.files).toBeLessThanOrEqual(total - module.files);
  479. expect(module.dependents.modules).toBeLessThanOrEqual(map.modules.length - 1);
  480. // A module nothing arrives at is an island, and the two must agree —
  481. // they are computed from different queries and a reader sees both.
  482. const arrives = map.links.some((l: any) => l.target === module.id);
  483. if (!arrives) expect(module.dependents.files).toBe(0);
  484. }
  485. });
  486. it('rejects an out-of-range depth as JSON, not as a crash', async () => {
  487. const res = await request('/api/map?depth=9');
  488. expect(res.status).toBe(400);
  489. expect(res.type).toBe('application/json; charset=utf-8');
  490. const body = JSON.parse(res.body);
  491. expect(body.code).toBe('bad-request');
  492. expect(body.error).toContain('depth');
  493. });
  494. it('serves the second identical request from the cache, byte for byte', async () => {
  495. // Other cases in this file have already warmed `src` at depth 1; the point
  496. // here is the first-then-second transition, so start from a cold cache.
  497. resetMapCache();
  498. const first = await getMap('?root=src&depth=1');
  499. const second = await getMap('?root=src&depth=1');
  500. expect(first.timing.cached).toBe(false);
  501. expect(second.timing.cached).toBe(true);
  502. // Everything except the timing stamp must be identical — a map that is not
  503. // reproducible between two reloads is not a map of anything.
  504. const strip = (m: any) => JSON.stringify({ ...m, timing: undefined });
  505. expect(strip(second)).toBe(strip(first));
  506. });
  507. it('does not let one root\'s answer be served for another', async () => {
  508. const src = await getMap('?root=src&depth=1');
  509. const all = await getMap('?root=&depth=1');
  510. expect(all.root).toBe('');
  511. expect(all.modules.map((m: any) => m.id)).not.toEqual(src.modules.map((m: any) => m.id));
  512. });
  513. });