mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-20 14:05:08 +00:00
style: format test file
This commit is contained in:
parent
283ad4d370
commit
012d5b488c
1 changed files with 12 additions and 55 deletions
|
|
@ -64,11 +64,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
|
|
||||||
// New implementation should return true (FIX!)
|
// New implementation should return true (FIX!)
|
||||||
const newResult = isImageLine(lineWithImageSequence);
|
const newResult = isImageLine(lineWithImageSequence);
|
||||||
assert.strictEqual(
|
assert.strictEqual(newResult, true, "Fix: new implementation returns true for line containing image sequence");
|
||||||
newResult,
|
|
||||||
true,
|
|
||||||
"Fix: new implementation returns true for line containing image sequence",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("new implementation detects Kitty sequences in any position", async () => {
|
it("new implementation detects Kitty sequences in any position", async () => {
|
||||||
|
|
@ -80,18 +76,11 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
"Suffix text \x1b_Ga=T,data...\x1b\\ suffix",
|
"Suffix text \x1b_Ga=T,data...\x1b\\ suffix",
|
||||||
"Middle \x1b_Ga=T,data...\x1b\\ more text",
|
"Middle \x1b_Ga=T,data...\x1b\\ more text",
|
||||||
// Very long line (simulating 300KB+ crash scenario)
|
// Very long line (simulating 300KB+ crash scenario)
|
||||||
"Text before " +
|
"Text before " + "\x1b_Ga=T,f=100" + "A".repeat(300000) + " text after",
|
||||||
"\x1b_Ga=T,f=100" +
|
|
||||||
"A".repeat(300000) +
|
|
||||||
" text after",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const line of scenarios) {
|
for (const line of scenarios) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(line), true, `Should detect Kitty sequence in: ${line.slice(0, 50)}...`);
|
||||||
isImageLine(line),
|
|
||||||
true,
|
|
||||||
`Should detect Kitty sequence in: ${line.slice(0, 50)}...`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -104,18 +93,11 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
"Suffix text \x1b]1337;File=inline=1:data==\x07 suffix",
|
"Suffix text \x1b]1337;File=inline=1:data==\x07 suffix",
|
||||||
"Middle \x1b]1337;File=inline=1:data==\x07 more text",
|
"Middle \x1b]1337;File=inline=1:data==\x07 more text",
|
||||||
// Very long line (simulating 304KB crash scenario)
|
// Very long line (simulating 304KB crash scenario)
|
||||||
"Text before " +
|
"Text before " + "\x1b]1337;File=size=800,600;inline=1:" + "B".repeat(300000) + " text after",
|
||||||
"\x1b]1337;File=size=800,600;inline=1:" +
|
|
||||||
"B".repeat(300000) +
|
|
||||||
" text after",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const line of scenarios) {
|
for (const line of scenarios) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(line), true, `Should detect iTerm2 sequence in: ${line.slice(0, 50)}...`);
|
||||||
isImageLine(line),
|
|
||||||
true,
|
|
||||||
`Should detect iTerm2 sequence in: ${line.slice(0, 50)}...`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -143,14 +125,9 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
|
|
||||||
// Simulate output when read tool processes an image
|
// Simulate output when read tool processes an image
|
||||||
// The line might have text from the read result plus the image escape sequence
|
// The line might have text from the read result plus the image escape sequence
|
||||||
const toolOutputLine =
|
const toolOutputLine = "Read image file [image/jpeg]\x1b]1337;File=size=800,600;inline=1:base64image...\x07";
|
||||||
"Read image file [image/jpeg]\x1b]1337;File=size=800,600;inline=1:base64image...\x07";
|
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(toolOutputLine), true, "Should detect image sequence in tool output line");
|
||||||
isImageLine(toolOutputLine),
|
|
||||||
true,
|
|
||||||
"Should detect image sequence in tool output line",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("detects Kitty sequences from Image component", async () => {
|
it("detects Kitty sequences from Image component", async () => {
|
||||||
|
|
@ -159,11 +136,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
// Kitty image component creates multi-line output with escape sequences
|
// Kitty image component creates multi-line output with escape sequences
|
||||||
const kittyLine = "\x1b_Ga=T,f=100,t=f,d=base64data...\x1b\\\x1b_Gm=i=1;\x1b\\";
|
const kittyLine = "\x1b_Ga=T,f=100,t=f,d=base64data...\x1b\\\x1b_Gm=i=1;\x1b\\";
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(kittyLine), true, "Should detect Kitty image component output");
|
||||||
isImageLine(kittyLine),
|
|
||||||
true,
|
|
||||||
"Should detect Kitty image component output",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles ANSI codes before image sequences", async () => {
|
it("handles ANSI codes before image sequences", async () => {
|
||||||
|
|
@ -213,11 +186,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
|
|
||||||
// New implementation should detect it (prevents crash)
|
// New implementation should detect it (prevents crash)
|
||||||
const detected = isImageLine(crashLine);
|
const detected = isImageLine(crashLine);
|
||||||
assert.strictEqual(
|
assert.strictEqual(detected, true, "Should detect image sequence in very long line, preventing TUI crash");
|
||||||
detected,
|
|
||||||
true,
|
|
||||||
"Should detect image sequence in very long line, preventing TUI crash",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles lines exactly matching crash log dimensions", async () => {
|
it("handles lines exactly matching crash log dimensions", async () => {
|
||||||
|
|
@ -236,11 +205,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
const line = `${prefix}${sequence}${padding}${suffix}`;
|
const line = `${prefix}${sequence}${padding}${suffix}`;
|
||||||
|
|
||||||
assert.strictEqual(line.length, 58649);
|
assert.strictEqual(line.length, 58649);
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(line), true, "Should detect image sequence in 58649-char line");
|
||||||
isImageLine(line),
|
|
||||||
true,
|
|
||||||
"Should detect image sequence in 58649-char line",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -251,11 +216,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
// Very long line WITHOUT image sequences
|
// Very long line WITHOUT image sequences
|
||||||
const longText = "A".repeat(100000);
|
const longText = "A".repeat(100000);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(longText), false, "Should not detect images in plain long text");
|
||||||
isImageLine(longText),
|
|
||||||
false,
|
|
||||||
"Should not detect images in plain long text",
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not detect images in lines with file paths", async () => {
|
it("does not detect images in lines with file paths", async () => {
|
||||||
|
|
@ -269,11 +230,7 @@ describe("Bug regression: isImageLine() crash with image escape sequences", () =
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const path of filePaths) {
|
for (const path of filePaths) {
|
||||||
assert.strictEqual(
|
assert.strictEqual(isImageLine(path), false, `Should not falsely detect image sequence in path: ${path}`);
|
||||||
isImageLine(path),
|
|
||||||
false,
|
|
||||||
`Should not falsely detect image sequence in path: ${path}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue