MCP: multi-line --text goes to the CLI as --from-text <temp file> (console_verify kept only the first line on Windows); long JSON output keeps its start and names a file with the whole output (console_plan lost its start URL); test, pitfall 100
This commit is contained in:
parent
73d308164d
commit
e1634f6abe
4 changed files with 66 additions and 2 deletions
24
tests/mcp-text-file.test.ts
Normal file
24
tests/mcp-text-file.test.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// MCP calls: multi-line page text reaches the CLI whole (pitfall 100), long JSON output keeps its start.
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { clip, textToFile } from '../cli/mcp';
|
||||
|
||||
describe('mcp argv and output', () => {
|
||||
test('a multi-line --text= becomes --from-text <file> with the whole text', () => {
|
||||
const page = 'App Privacy\nData Types\nCrash Data\r\nUsed for App Functionality\nPublished a few seconds ago';
|
||||
const argv = textToFile(['console', 'verify', 'apple-app-privacy', `--text=${page}`, '--json']);
|
||||
expect(argv.slice(0, 4)).toEqual(['console', 'verify', 'apple-app-privacy', '--from-text']);
|
||||
expect(argv.some(a => /[\r\n]/.test(a))).toBe(false);
|
||||
expect(readFileSync(argv[4]!, 'utf8')).toBe(page);
|
||||
expect(textToFile(['console', 'verify', 'x', '--text=one line'])).toEqual(['console', 'verify', 'x', '--text=one line']);
|
||||
});
|
||||
test('long JSON keeps its start, long text its end; both name the full file', () => {
|
||||
const json = `{"startUrl":"https://example.com/start",${'"x":1,'.repeat(50)}"end":true}`;
|
||||
const j = clip(json, true, 40);
|
||||
expect(j.startsWith('{"startUrl":"https://example.com/start"')).toBe(true);
|
||||
const file = /the whole output: (.+)\]$/.exec(j)![1]!;
|
||||
expect(readFileSync(file, 'utf8')).toBe(json);
|
||||
expect(clip('a'.repeat(100) + 'ERROR at the end', false, 20).endsWith('ERROR at the end')).toBe(true);
|
||||
expect(clip('short', true, 40)).toBe('short');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue