nest-graph-inspector 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/http-output.adapter.d.ts +11 -3
- package/dist/adapters/http-output.adapter.d.ts.map +1 -1
- package/dist/adapters/http-output.adapter.js +60 -22
- package/dist/adapters/http-output.adapter.js.map +1 -1
- package/dist/adapters/viewer-output.adapter.d.ts.map +1 -1
- package/dist/adapters/viewer-output.adapter.js +1 -1
- package/dist/adapters/viewer-output.adapter.js.map +1 -1
- package/dist/nest-graph-inspector.setup.d.ts.map +1 -1
- package/dist/nest-graph-inspector.setup.js +4 -8
- package/dist/nest-graph-inspector.setup.js.map +1 -1
- package/dist/nest-graph-inspector.type.d.ts +15 -17
- package/dist/nest-graph-inspector.type.d.ts.map +1 -1
- package/dist/types/graph-layout.type.d.ts +4 -2
- package/dist/types/graph-layout.type.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/http-output.adapter.spec.ts +274 -202
- package/src/adapters/http-output.adapter.ts +85 -29
- package/src/adapters/viewer-output.adapter.spec.ts +4 -4
- package/src/adapters/viewer-output.adapter.ts +6 -2
- package/src/nest-graph-inspector.setup.spec.ts +12 -41
- package/src/nest-graph-inspector.setup.ts +7 -14
- package/src/nest-graph-inspector.type.ts +17 -17
- package/src/types/graph-layout.type.ts +4 -2
|
@@ -285,15 +285,18 @@ describe(HttpOutputAdapter.name, () => {
|
|
|
285
285
|
},
|
|
286
286
|
body,
|
|
287
287
|
});
|
|
288
|
-
const install = async (
|
|
288
|
+
const install = async (saveAs?: 'file' | 'runtime') => {
|
|
289
289
|
const port = await availablePort();
|
|
290
|
-
await adapter.execute(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
290
|
+
await adapter.execute(
|
|
291
|
+
{} as never,
|
|
292
|
+
{
|
|
293
|
+
type: 'http',
|
|
294
|
+
host: '127.0.0.1',
|
|
295
|
+
port,
|
|
296
|
+
path: '/graph',
|
|
297
|
+
...(saveAs ? { layout: { saveAs } } : {}),
|
|
298
|
+
} as never,
|
|
299
|
+
);
|
|
297
300
|
origin = `http://127.0.0.1:${port}`;
|
|
298
301
|
};
|
|
299
302
|
const expectNoFile = (filePath: string) =>
|
|
@@ -301,6 +304,7 @@ describe(HttpOutputAdapter.name, () => {
|
|
|
301
304
|
|
|
302
305
|
beforeEach(async () => {
|
|
303
306
|
layoutDir = await mkdtemp(join(tmpdir(), 'graph-layout-'));
|
|
307
|
+
jest.spyOn(process, 'cwd').mockReturnValue(layoutDir);
|
|
304
308
|
});
|
|
305
309
|
|
|
306
310
|
afterEach(async () => {
|
|
@@ -308,247 +312,315 @@ describe(HttpOutputAdapter.name, () => {
|
|
|
308
312
|
await rm(layoutDir, { recursive: true, force: true });
|
|
309
313
|
});
|
|
310
314
|
|
|
311
|
-
|
|
312
|
-
|
|
315
|
+
describe("saveAs: 'file' (default)", () => {
|
|
316
|
+
const muse = () => join(layoutDir, '.muse');
|
|
317
|
+
|
|
318
|
+
it('serves an empty layout from both GET paths until one is saved', async () => {
|
|
319
|
+
await install();
|
|
320
|
+
|
|
321
|
+
for (const path of ['/graph/layout.json', '/graph/layout']) {
|
|
322
|
+
const response = await get(`${origin}${path}`);
|
|
323
|
+
|
|
324
|
+
expect(response.statusCode).toBe(200);
|
|
325
|
+
expect(response.headers['content-type']).toBe(
|
|
326
|
+
'application/json; charset=utf-8',
|
|
327
|
+
);
|
|
328
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
329
|
+
version: '1',
|
|
330
|
+
modules: {},
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
313
334
|
|
|
314
|
-
for
|
|
315
|
-
|
|
335
|
+
it('saves a layout from both POST paths to ./.muse, formatted for committing, and serves it back', async () => {
|
|
336
|
+
await install();
|
|
337
|
+
|
|
338
|
+
for (const [path, x] of [
|
|
339
|
+
['/graph/layout', 1],
|
|
340
|
+
['/graph/layout.json', 2],
|
|
341
|
+
] as const) {
|
|
342
|
+
const saved: GraphLayout = {
|
|
343
|
+
...layout,
|
|
344
|
+
modules: { ...layout.modules, AppModule: { position: { x, y: 0 } } },
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const response = await post(`${origin}${path}`, JSON.stringify(saved));
|
|
348
|
+
|
|
349
|
+
expect(response.statusCode).toBe(200);
|
|
350
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
351
|
+
ok: true,
|
|
352
|
+
message: 'Layout saved successfully',
|
|
353
|
+
});
|
|
354
|
+
await expect(readFile(muse(), 'utf8')).resolves.toBe(
|
|
355
|
+
`${JSON.stringify(saved, null, 2)}\n`,
|
|
356
|
+
);
|
|
357
|
+
expect(
|
|
358
|
+
JSON.parse((await get(`${origin}/graph/layout.json`)).body),
|
|
359
|
+
).toEqual(saved);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('saves explicitly configured saveAs: "file" to ./.muse too', async () => {
|
|
364
|
+
await install('file');
|
|
365
|
+
|
|
366
|
+
const response = await post(
|
|
367
|
+
`${origin}/graph/layout`,
|
|
368
|
+
JSON.stringify(layout),
|
|
369
|
+
);
|
|
316
370
|
|
|
317
371
|
expect(response.statusCode).toBe(200);
|
|
318
|
-
expect(
|
|
319
|
-
|
|
372
|
+
await expect(readFile(muse(), 'utf8')).resolves.toBe(
|
|
373
|
+
serializeGraphLayout(layout),
|
|
374
|
+
);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('rejects an invalid layout with the reasons, and leaves the saved one alone', async () => {
|
|
378
|
+
await writeFile(muse(), serializeGraphLayout(layout));
|
|
379
|
+
await install();
|
|
380
|
+
|
|
381
|
+
const response = await post(
|
|
382
|
+
`${origin}/graph/layout`,
|
|
383
|
+
JSON.stringify({
|
|
384
|
+
version: '2',
|
|
385
|
+
modules: { UserModule: { position: { x: 'left', y: 0 } } },
|
|
386
|
+
}),
|
|
320
387
|
);
|
|
388
|
+
|
|
389
|
+
expect(response.statusCode).toBe(400);
|
|
321
390
|
expect(JSON.parse(response.body)).toEqual({
|
|
322
|
-
|
|
323
|
-
|
|
391
|
+
ok: false,
|
|
392
|
+
message: 'Invalid layout payload',
|
|
393
|
+
errors: [
|
|
394
|
+
'layout/version must be "1"',
|
|
395
|
+
'layout/modules/UserModule/position/x must be a finite number',
|
|
396
|
+
],
|
|
324
397
|
});
|
|
325
|
-
|
|
326
|
-
|
|
398
|
+
await expect(readFile(muse(), 'utf8')).resolves.toBe(
|
|
399
|
+
serializeGraphLayout(layout),
|
|
400
|
+
);
|
|
401
|
+
});
|
|
327
402
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
['/graph/layout', 1],
|
|
334
|
-
['/graph/layout.json', 2],
|
|
335
|
-
] as const) {
|
|
336
|
-
const saved: GraphLayout = {
|
|
337
|
-
...layout,
|
|
338
|
-
modules: { ...layout.modules, AppModule: { position: { x, y: 0 } } },
|
|
339
|
-
};
|
|
403
|
+
it.each([
|
|
404
|
+
['an empty body', ''],
|
|
405
|
+
['malformed JSON', '{"version":'],
|
|
406
|
+
])('rejects %s', async (_label, body) => {
|
|
407
|
+
await install();
|
|
340
408
|
|
|
341
|
-
const response = await post(`${origin}
|
|
409
|
+
const response = await post(`${origin}/graph/layout`, body);
|
|
342
410
|
|
|
343
|
-
expect(response.statusCode).toBe(
|
|
411
|
+
expect(response.statusCode).toBe(400);
|
|
344
412
|
expect(JSON.parse(response.body)).toEqual({
|
|
345
|
-
ok:
|
|
346
|
-
message: '
|
|
413
|
+
ok: false,
|
|
414
|
+
message: 'Request body is not valid JSON.',
|
|
347
415
|
});
|
|
348
|
-
await
|
|
349
|
-
|
|
416
|
+
await expectNoFile(muse());
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('refuses a body over the size limit before parsing it', async () => {
|
|
420
|
+
await install();
|
|
421
|
+
|
|
422
|
+
const response = await post(
|
|
423
|
+
`${origin}/graph/layout`,
|
|
424
|
+
'x'.repeat(MAX_LAYOUT_BODY_BYTES + 1),
|
|
350
425
|
);
|
|
351
|
-
expect(
|
|
352
|
-
JSON.parse((await get(`${origin}/graph/layout.json`)).body),
|
|
353
|
-
).toEqual(saved);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
426
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
427
|
+
expect(response.statusCode).toBe(413);
|
|
428
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
429
|
+
ok: false,
|
|
430
|
+
message: 'Request body is too large.',
|
|
431
|
+
});
|
|
432
|
+
await expectNoFile(muse());
|
|
433
|
+
});
|
|
360
434
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
JSON.stringify(layout),
|
|
364
|
-
);
|
|
435
|
+
it('refuses to read or save the layout without a token', async () => {
|
|
436
|
+
await install();
|
|
365
437
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
438
|
+
const read = await httpGet(`${origin}/graph/layout.json`);
|
|
439
|
+
const save = await httpRequest(`${origin}/graph/layout`, {
|
|
440
|
+
method: 'POST',
|
|
441
|
+
headers: { 'content-type': 'application/json' },
|
|
442
|
+
body: JSON.stringify(layout),
|
|
443
|
+
});
|
|
371
444
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
445
|
+
expect(read.statusCode).toBe(401);
|
|
446
|
+
expect(save.statusCode).toBe(401);
|
|
447
|
+
await expectNoFile(muse());
|
|
448
|
+
});
|
|
375
449
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
JSON.stringify(layout),
|
|
379
|
-
);
|
|
450
|
+
it('reports a layout file it cannot read back instead of serving it as empty', async () => {
|
|
451
|
+
await install();
|
|
380
452
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
).resolves.toBe(serializeGraphLayout(layout));
|
|
385
|
-
});
|
|
453
|
+
// What a merge conflict leaves behind in a committed layout file.
|
|
454
|
+
await writeFile(muse(), '<<<<<<< HEAD\n{}\n');
|
|
455
|
+
const unparsable = await get(`${origin}/graph/layout.json`);
|
|
386
456
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
457
|
+
expect(unparsable.statusCode).toBe(500);
|
|
458
|
+
expect(JSON.parse(unparsable.body)).toMatchObject({ ok: false });
|
|
459
|
+
expect(JSON.parse(unparsable.body).message).toContain(
|
|
460
|
+
`Graph layout file ${muse()} is not valid JSON`,
|
|
461
|
+
);
|
|
391
462
|
|
|
392
|
-
|
|
393
|
-
`${origin}/graph/layout
|
|
394
|
-
JSON.stringify({
|
|
395
|
-
version: '2',
|
|
396
|
-
modules: { UserModule: { position: { x: 'left', y: 0 } } },
|
|
397
|
-
}),
|
|
398
|
-
);
|
|
463
|
+
await writeFile(muse(), JSON.stringify({ version: '1' }));
|
|
464
|
+
const invalid = await get(`${origin}/graph/layout.json`);
|
|
399
465
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
'layout/modules/UserModule/position/x must be a finite number',
|
|
407
|
-
],
|
|
466
|
+
expect(invalid.statusCode).toBe(500);
|
|
467
|
+
expect(JSON.parse(invalid.body)).toEqual({
|
|
468
|
+
ok: false,
|
|
469
|
+
message: `Graph layout file ${muse()} is not a valid graph layout`,
|
|
470
|
+
errors: ['layout is missing required property "modules"'],
|
|
471
|
+
});
|
|
408
472
|
});
|
|
409
|
-
await expect(readFile(filePath, 'utf8')).resolves.toBe(
|
|
410
|
-
serializeGraphLayout(layout),
|
|
411
|
-
);
|
|
412
|
-
});
|
|
413
473
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
474
|
+
it('lands overlapping saves one at a time, so the file always holds one whole layout', async () => {
|
|
475
|
+
await install();
|
|
476
|
+
// Different sizes on purpose: two interleaved writes of unequal length
|
|
477
|
+
// would leave the longer one's tail behind the shorter one.
|
|
478
|
+
const large: GraphLayout = {
|
|
479
|
+
version: '1',
|
|
480
|
+
modules: Object.fromEntries(
|
|
481
|
+
Array.from({ length: 500 }, (_, index) => [
|
|
482
|
+
`Module${index}`,
|
|
483
|
+
{ position: { x: index, y: index } },
|
|
484
|
+
]),
|
|
485
|
+
),
|
|
486
|
+
};
|
|
422
487
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
488
|
+
const responses = await Promise.all([
|
|
489
|
+
post(`${origin}/graph/layout`, JSON.stringify(large)),
|
|
490
|
+
post(`${origin}/graph/layout`, JSON.stringify(layout)),
|
|
491
|
+
post(`${origin}/graph/layout`, JSON.stringify(large)),
|
|
492
|
+
]);
|
|
493
|
+
|
|
494
|
+
expect(responses.map((response) => response.statusCode)).toEqual([
|
|
495
|
+
200, 200, 200,
|
|
496
|
+
]);
|
|
497
|
+
expect([
|
|
498
|
+
serializeGraphLayout(large),
|
|
499
|
+
serializeGraphLayout(layout),
|
|
500
|
+
]).toContain(await readFile(muse(), 'utf8'));
|
|
427
501
|
});
|
|
428
|
-
await expectNoFile(filePath);
|
|
429
502
|
});
|
|
430
503
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
504
|
+
describe("saveAs: 'runtime'", () => {
|
|
505
|
+
it('serves an empty layout from both GET paths until one is saved, entirely from RAM', async () => {
|
|
506
|
+
await install('runtime');
|
|
434
507
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
'x'.repeat(MAX_LAYOUT_BODY_BYTES + 1),
|
|
438
|
-
);
|
|
508
|
+
for (const path of ['/graph/layout.json', '/graph/layout']) {
|
|
509
|
+
const response = await get(`${origin}${path}`);
|
|
439
510
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
511
|
+
expect(response.statusCode).toBe(200);
|
|
512
|
+
expect(response.headers['content-type']).toBe(
|
|
513
|
+
'application/json; charset=utf-8',
|
|
514
|
+
);
|
|
515
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
516
|
+
version: '1',
|
|
517
|
+
modules: {},
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
444
522
|
});
|
|
445
|
-
await expectNoFile(filePath);
|
|
446
|
-
});
|
|
447
523
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
await install(filePath);
|
|
524
|
+
it('saves and reads back a layout from memory, writing nothing to disk', async () => {
|
|
525
|
+
await install('runtime');
|
|
451
526
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
527
|
+
for (const [path, x] of [
|
|
528
|
+
['/graph/layout', 1],
|
|
529
|
+
['/graph/layout.json', 2],
|
|
530
|
+
] as const) {
|
|
531
|
+
const saved: GraphLayout = {
|
|
532
|
+
...layout,
|
|
533
|
+
modules: { ...layout.modules, AppModule: { position: { x, y: 0 } } },
|
|
534
|
+
};
|
|
458
535
|
|
|
459
|
-
|
|
460
|
-
expect(save.statusCode).toBe(401);
|
|
461
|
-
await expectNoFile(filePath);
|
|
462
|
-
});
|
|
536
|
+
const response = await post(`${origin}${path}`, JSON.stringify(saved));
|
|
463
537
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
538
|
+
expect(response.statusCode).toBe(200);
|
|
539
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
540
|
+
ok: true,
|
|
541
|
+
message: 'Layout saved successfully',
|
|
542
|
+
});
|
|
543
|
+
expect(
|
|
544
|
+
JSON.parse((await get(`${origin}/graph/layout.json`)).body),
|
|
545
|
+
).toEqual(saved);
|
|
546
|
+
}
|
|
467
547
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const unparsable = await get(`${origin}/graph/layout.json`);
|
|
548
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
549
|
+
});
|
|
471
550
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
`Graph layout file ${filePath} is not valid JSON`,
|
|
476
|
-
);
|
|
551
|
+
it('rejects an invalid layout without touching the in-memory layout or disk', async () => {
|
|
552
|
+
await install('runtime');
|
|
553
|
+
await post(`${origin}/graph/layout`, JSON.stringify(layout));
|
|
477
554
|
|
|
478
|
-
|
|
479
|
-
|
|
555
|
+
const response = await post(
|
|
556
|
+
`${origin}/graph/layout`,
|
|
557
|
+
JSON.stringify({
|
|
558
|
+
version: '2',
|
|
559
|
+
modules: { UserModule: { position: { x: 'left', y: 0 } } },
|
|
560
|
+
}),
|
|
561
|
+
);
|
|
480
562
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
563
|
+
expect(response.statusCode).toBe(400);
|
|
564
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
565
|
+
ok: false,
|
|
566
|
+
message: 'Invalid layout payload',
|
|
567
|
+
errors: [
|
|
568
|
+
'layout/version must be "1"',
|
|
569
|
+
'layout/modules/UserModule/position/x must be a finite number',
|
|
570
|
+
],
|
|
571
|
+
});
|
|
572
|
+
expect(
|
|
573
|
+
JSON.parse((await get(`${origin}/graph/layout.json`)).body),
|
|
574
|
+
).toEqual(layout);
|
|
575
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
486
576
|
});
|
|
487
|
-
});
|
|
488
577
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
578
|
+
it.each([
|
|
579
|
+
['an empty body', ''],
|
|
580
|
+
['malformed JSON', '{"version":'],
|
|
581
|
+
])('rejects %s', async (_label, body) => {
|
|
582
|
+
await install('runtime');
|
|
494
583
|
|
|
495
|
-
|
|
496
|
-
`${origin}/graph/layout`,
|
|
497
|
-
JSON.stringify(layout),
|
|
498
|
-
);
|
|
584
|
+
const response = await post(`${origin}/graph/layout`, body);
|
|
499
585
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
586
|
+
expect(response.statusCode).toBe(400);
|
|
587
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
588
|
+
ok: false,
|
|
589
|
+
message: 'Request body is not valid JSON.',
|
|
590
|
+
});
|
|
591
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
592
|
+
});
|
|
505
593
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
await install(filePath);
|
|
509
|
-
// Different sizes on purpose: two interleaved writes of unequal length
|
|
510
|
-
// would leave the longer one's tail behind the shorter one.
|
|
511
|
-
const large: GraphLayout = {
|
|
512
|
-
version: '1',
|
|
513
|
-
modules: Object.fromEntries(
|
|
514
|
-
Array.from({ length: 500 }, (_, index) => [
|
|
515
|
-
`Module${index}`,
|
|
516
|
-
{ position: { x: index, y: index } },
|
|
517
|
-
]),
|
|
518
|
-
),
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
const responses = await Promise.all([
|
|
522
|
-
post(`${origin}/graph/layout`, JSON.stringify(large)),
|
|
523
|
-
post(`${origin}/graph/layout`, JSON.stringify(layout)),
|
|
524
|
-
post(`${origin}/graph/layout`, JSON.stringify(large)),
|
|
525
|
-
]);
|
|
526
|
-
|
|
527
|
-
expect(responses.map((response) => response.statusCode)).toEqual([
|
|
528
|
-
200, 200, 200,
|
|
529
|
-
]);
|
|
530
|
-
expect([
|
|
531
|
-
serializeGraphLayout(large),
|
|
532
|
-
serializeGraphLayout(layout),
|
|
533
|
-
]).toContain(await readFile(filePath, 'utf8'));
|
|
534
|
-
});
|
|
594
|
+
it('refuses a body over the size limit before parsing it', async () => {
|
|
595
|
+
await install('runtime');
|
|
535
596
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
597
|
+
const response = await post(
|
|
598
|
+
`${origin}/graph/layout`,
|
|
599
|
+
'x'.repeat(MAX_LAYOUT_BODY_BYTES + 1),
|
|
600
|
+
);
|
|
539
601
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
602
|
+
expect(response.statusCode).toBe(413);
|
|
603
|
+
expect(JSON.parse(response.body)).toEqual({
|
|
604
|
+
ok: false,
|
|
605
|
+
message: 'Request body is too large.',
|
|
606
|
+
});
|
|
607
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
543
608
|
});
|
|
544
609
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
610
|
+
it('refuses to read or save the layout without a token', async () => {
|
|
611
|
+
await install('runtime');
|
|
612
|
+
|
|
613
|
+
const read = await httpGet(`${origin}/graph/layout.json`);
|
|
614
|
+
const save = await httpRequest(`${origin}/graph/layout`, {
|
|
615
|
+
method: 'POST',
|
|
616
|
+
headers: { 'content-type': 'application/json' },
|
|
617
|
+
body: JSON.stringify(layout),
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
expect(read.statusCode).toBe(401);
|
|
621
|
+
expect(save.statusCode).toBe(401);
|
|
622
|
+
await expectNoFile(join(layoutDir, '.muse'));
|
|
623
|
+
});
|
|
552
624
|
});
|
|
553
625
|
});
|
|
554
626
|
|