Файли
openidea/src/features/notebook/collapsed.test.ts
T
Delaruno20таDelaruno20 7d4c58a0f1 feat(notebook): fold cells and outputs in the notebook editor (#5650)
A chevron in each cell toolbar folds the cell to one line (its first non-blank line, or a Markdown heading's text) with its output count; clicking the line unfolds it. Code cells with outputs get Hide Output / Show Output, which folds only the outputs, and the notebook toolbar gets Collapse All Cells / Expand All Cells. Fold state is view state on NotebookSession; the .ipynb file is not modified. The singular output counts use their own catalog keys so they don't collide with the run output pane's "{name} output".

Co-authored-by: Delaruno20 <[email protected]>
2026-11-25 08:46:07 +08:00

25 рядки
835 B
TypeScript

import { describe, expect, it } from "vitest";
import { collapsedSummary } from "./NotebookEditor";
describe("a folded notebook cell", () => {
it("shows a code cell's first non-blank line and its output count", () => {
expect(collapsedSummary({ cellType: "code", source: "\n import pandas as pd\nx = 1", outputs: [{}, {}] })).toEqual(
{
text: "import pandas as pd",
outputs: 2,
},
);
});
it("shows a Markdown heading without its marks, and no outputs", () => {
expect(collapsedSummary({ cellType: "markdown", source: "## Results\nbody", outputs: [] })).toEqual({
text: "Results",
outputs: 0,
});
});
it("is empty for a blank cell", () => {
expect(collapsedSummary({ cellType: "code", source: " \n", outputs: [] })).toEqual({ text: "", outputs: 0 });
});
});