Files
paseo/packages/app/src/components/markdown/part-groups.test.ts
T
Mohamed BoudraandGitHub 3163e212fb Attach pull request feedback to chat (#1400)
* feat(app): add pull request panel context actions

Attach pull request comments, reviews, and failed check details to chat context. The PR panel now lives in its own module so the activity, query, and context policies have one home.

* fix(server): mark capped check details as truncated

* fix(app): preserve concurrent PR panel attachments

* fix(server): preserve annotation truncation state

* fix(app): keep matrix check attachments distinct

* fix(app): streamline pull request context attachments

* fix(app): simplify pull request feedback rendering

* feat(app): group pull request review threads

* fix(app): tidy pull request panel boundaries

* fix: use worktree cwd for dev services

* fix(app): keep git query keys UI-free

* feat(app): collapse resolved comments and add chat actions to headers

* fix: address PR feedback and Playwright flakes

* fix(app): hide check chat action without attachment scope

* fix(server): dedupe inline review timeline comments
2026-06-12 13:43:01 +08:00

93 lines
2.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { MarkdownDisplayPart } from "./html-ish";
import { groupMarkdownParts } from "./part-groups";
describe("groupMarkdownParts", () => {
const flowImage: MarkdownDisplayPart = {
kind: "inlineImage",
alt: "Priority",
src: "https://example.com/priority.svg",
flowsWithText: true,
};
it("flows an image with the lead paragraph and keeps later paragraphs full width", () => {
expect(
groupMarkdownParts([
flowImage,
{ kind: "markdown", text: " **Title line**\n\nSecond paragraph." },
]),
).toEqual([
{
kind: "imageText",
images: [flowImage],
lead: "**Title line**",
rest: "Second paragraph.",
},
]);
});
it("flows an image with a single-paragraph text", () => {
expect(groupMarkdownParts([flowImage, { kind: "markdown", text: " Only line" }])).toEqual([
{ kind: "imageText", images: [flowImage], lead: "Only line", rest: "" },
]);
});
it("groups two consecutive flowing images with the lead paragraph", () => {
const secondImage: MarkdownDisplayPart = {
kind: "inlineImage",
alt: "Severity",
src: "https://example.com/severity.svg",
flowsWithText: true,
};
expect(
groupMarkdownParts([
flowImage,
{ kind: "markdown", text: " " },
secondImage,
{ kind: "markdown", text: " **Title text here**\n\nBody paragraph." },
]),
).toEqual([
{
kind: "imageText",
images: [flowImage, secondImage],
lead: "**Title text here**",
rest: "Body paragraph.",
},
]);
});
it("keeps standalone images as plain parts", () => {
const image: MarkdownDisplayPart = {
kind: "inlineImage",
alt: "Shot",
src: "https://example.com/shot.png",
};
expect(groupMarkdownParts([image, { kind: "markdown", text: "\n\nCaption" }])).toEqual([
{ kind: "part", part: image },
{ kind: "part", part: { kind: "markdown", text: "\n\nCaption" } },
]);
});
it("keeps a flowing image alone when no markdown follows", () => {
expect(groupMarkdownParts([flowImage])).toEqual([{ kind: "part", part: flowImage }]);
});
it("keeps a flowing image alone when the following markdown starts with a blank line", () => {
expect(groupMarkdownParts([flowImage, { kind: "markdown", text: "\n\nBelow" }])).toEqual([
{ kind: "part", part: flowImage },
{ kind: "part", part: { kind: "markdown", text: "\n\nBelow" } },
]);
});
it("passes other part kinds through unchanged", () => {
const details: MarkdownDisplayPart = { kind: "details", summary: "More", body: "Body" };
expect(groupMarkdownParts([{ kind: "markdown", text: "Intro" }, details])).toEqual([
{ kind: "part", part: { kind: "markdown", text: "Intro" } },
{ kind: "part", part: details },
]);
});
});