previewPane.test.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. import {
  4. getPreviewPaneSafeErrorMessage,
  5. getPreviewPaneDisplayOptions,
  6. isPreviewPaneFileTooLargeError,
  7. isPptxPreviewFileTooLarge,
  8. isPreviewPaneMissingFileError,
  9. shouldToastPptxReferenceFileMissing,
  10. resolvePptxPreviewReadErrorMessage,
  11. resolvePreviewPaneImageSource,
  12. resolvePreviewPaneMediaSource,
  13. resolveMediaPlaybackErrorMessageId,
  14. resolvePreviewPanePdfSource,
  15. resolvePreviewPanePptxSource,
  16. resolvePreviewPaneTextFileResult,
  17. shouldShowPreviewPaneHeaderDivider,
  18. } from "@/PreviewPane.js";
  19. import { createDiffSourceFilePreviewSource, getDiffSourceFileTarget } from "@/lib/codeViewer.js";
  20. import { getPreviewPaneErrorTextClass } from "@/previewPaneContent.js";
  21. describe("PreviewPane helpers", () => {
  22. it.each([
  23. [3, "codeViewer.mediaUnsupported"],
  24. [4, "codeViewer.mediaUnsupported"],
  25. [2, "codeViewer.mediaLoadFailed"],
  26. [1, "codeViewer.mediaLoadFailed"],
  27. [undefined, "codeViewer.mediaLoadFailed"],
  28. ])("classifies media error code %s", (code, expectedMessageId) => {
  29. expect(resolveMediaPlaybackErrorMessageId(code)).toBe(expectedMessageId);
  30. });
  31. it("媒体预览只走 mediaPreviewService,不回退到 file.readMediaPreview", () => {
  32. const source = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  33. const mediaEffectStart = source.indexOf("if (!mediaSource)");
  34. const mediaEffectEnd = source.indexOf(" useEffect(() => {", mediaEffectStart + 1);
  35. const mediaEffect = source.slice(mediaEffectStart, mediaEffectEnd);
  36. expect(mediaEffectStart).toBeGreaterThan(0);
  37. expect(mediaEffect).toContain("mediaPreviewService");
  38. expect(mediaEffect).toContain(".prepare({");
  39. expect(mediaEffect).not.toContain("fileService.readMediaPreview");
  40. expect(mediaEffect.indexOf("preparedPreviewId = previewId")).toBeLessThan(
  41. mediaEffect.indexOf("generation !== mediaPreviewGenerationRef.current"),
  42. );
  43. });
  44. it("媒体播放器错误时支持通过 service 刷新 URL 并恢复播放状态", () => {
  45. const source = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  46. expect(source).toContain("refreshPlaybackUrl");
  47. expect(source).toContain("mediaPlaybackRestoreRef");
  48. expect(source).toContain("onMediaLoadedMetadata");
  49. expect(source).toContain("mediaPreviewGenerationRef");
  50. });
  51. it.each([
  52. ["clip.mp4", "video", "video/mp4"],
  53. ["clip.mov", "video", "video/quicktime"],
  54. ["clip.webm", "video", "video/webm"],
  55. ["clip.m4v", "video", "video/x-m4v"],
  56. ["song.mp3", "audio", "audio/mpeg"],
  57. ["song.wav", "audio", "audio/wav"],
  58. ["song.m4a", "audio", "audio/mp4"],
  59. ["song.ogg", "audio", "audio/ogg"],
  60. ["song.opus", "audio", "audio/opus"],
  61. ["song.flac", "audio", "audio/flac"],
  62. ["song.weba", "audio", "audio/webm"],
  63. ])("upgrades %s to a media source", (name, kind, mediaType) => {
  64. expect(
  65. resolvePreviewPaneMediaSource({
  66. type: "file",
  67. title: name,
  68. path: `/workspace/${name}`,
  69. }),
  70. ).toMatchObject({
  71. type: "media",
  72. kind,
  73. mediaType,
  74. path: `/workspace/${name}`,
  75. });
  76. });
  77. it.each(["report.docx", "report.doc", "table.xlsx", "table.xls", "slides.pptx", "paper.pdf"])(
  78. "shows the document header divider for %s",
  79. (path) => {
  80. expect(
  81. shouldShowPreviewPaneHeaderDivider({
  82. type: "file",
  83. title: path,
  84. path: `/workspace/${path}`,
  85. }),
  86. ).toBe(true);
  87. },
  88. );
  89. it("does not add the document header divider to ordinary previews", () => {
  90. expect(
  91. shouldShowPreviewPaneHeaderDivider({
  92. type: "file",
  93. title: "app.ts",
  94. path: "/workspace/app.ts",
  95. }),
  96. ).toBe(false);
  97. });
  98. it("keeps the diff source header action visible as text", () => {
  99. const source = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  100. const triggerIndex = source.indexOf("data-diff-source-preview-trigger");
  101. const triggerSource = source.slice(triggerIndex - 600, triggerIndex + 800);
  102. expect(triggerIndex).toBeGreaterThan(0);
  103. expect(triggerSource).toContain('size="default"');
  104. expect(triggerSource).toContain("rounded-lg");
  105. expect(triggerSource).toContain('id: "codeViewer.openSourcePreview"');
  106. expect(triggerSource).toContain("<span>");
  107. });
  108. it("uses the shared open-with ordering for preview pane editor actions", () => {
  109. const source = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  110. const editorSelectionIndex = source.indexOf("const editorSelection = useMemo");
  111. const editorSelectionSource = source.slice(editorSelectionIndex, editorSelectionIndex + 500);
  112. expect(editorSelectionIndex).toBeGreaterThan(0);
  113. expect(editorSelectionSource).toContain("resolveWorkspaceEditorSelection({");
  114. expect(editorSelectionSource).toContain("remoteTarget: openInEditorRemoteTarget");
  115. expect(source).toContain("const selectedEditor = editorSelection.selectedEditor");
  116. expect(source).toContain("const [preferredEditorId] = useState");
  117. expect(source).not.toContain("persistLastSelectedEditorId");
  118. expect(source).not.toContain("const availableEditors = installedEditors");
  119. });
  120. it("uses media preview for raster image file sources", () => {
  121. expect(
  122. resolvePreviewPaneImageSource({
  123. type: "file",
  124. title: "Lark_Suite_logo_2022.png.png",
  125. path: "/workspace/Lark_Suite_logo_2022.png.png",
  126. }),
  127. ).toEqual({
  128. type: "image",
  129. title: "Lark_Suite_logo_2022.png.png",
  130. path: "/workspace/Lark_Suite_logo_2022.png.png",
  131. mediaType: "image/png",
  132. });
  133. });
  134. it("keeps svg file sources out of media preview so source mode still works", () => {
  135. expect(
  136. resolvePreviewPaneImageSource({
  137. type: "file",
  138. title: "logo.svg",
  139. path: "/workspace/logo.svg",
  140. }),
  141. ).toBeNull();
  142. });
  143. it("upgrades pdf file sources to the dedicated pdf preview", () => {
  144. expect(
  145. resolvePreviewPanePdfSource({
  146. type: "file",
  147. title: "report.pdf",
  148. path: "/workspace/report.pdf",
  149. }),
  150. ).toEqual({
  151. type: "pdf",
  152. title: "report.pdf",
  153. path: "/workspace/report.pdf",
  154. });
  155. expect(
  156. resolvePreviewPanePdfSource({
  157. type: "file",
  158. title: "REPORT.PDF",
  159. path: "/workspace/REPORT.PDF",
  160. }),
  161. ).toEqual({
  162. type: "pdf",
  163. title: "REPORT.PDF",
  164. path: "/workspace/REPORT.PDF",
  165. });
  166. });
  167. it("passes through pdf sources and rejects non-pdf sources", () => {
  168. const pdfSource = {
  169. type: "pdf" as const,
  170. title: "report.pdf",
  171. path: "/workspace/report.pdf",
  172. };
  173. expect(resolvePreviewPanePdfSource(pdfSource)).toBe(pdfSource);
  174. expect(
  175. resolvePreviewPanePdfSource({
  176. type: "file",
  177. title: "index.ts",
  178. path: "/workspace/index.ts",
  179. }),
  180. ).toBeNull();
  181. expect(resolvePreviewPanePdfSource(null)).toBeNull();
  182. });
  183. it("hides the more menu for pdf previews", () => {
  184. // pdf 是专用只读预览,没有源码视图,也不该出现自动换行开关
  185. expect(
  186. getPreviewPaneDisplayOptions({
  187. type: "file",
  188. title: "report.pdf",
  189. path: "/workspace/report.pdf",
  190. }).hasMoreMenu,
  191. ).toBe(false);
  192. expect(
  193. getPreviewPaneDisplayOptions({
  194. type: "pdf",
  195. title: "report.pdf",
  196. path: "/workspace/report.pdf",
  197. }).hasMoreMenu,
  198. ).toBe(false);
  199. });
  200. it("upgrades pptx file sources and preserves workspace scope", () => {
  201. const source = {
  202. type: "file" as const,
  203. title: "ROADMAP.PPTX",
  204. path: "/workspace/ROADMAP.PPTX",
  205. workspacePath: "/workspace",
  206. workspaceIdentity: "ssh:demo:/workspace",
  207. workspaceRemoteSessionId: "remote-1",
  208. };
  209. expect(resolvePreviewPanePptxSource(source)).toEqual({
  210. ...source,
  211. type: "pptx",
  212. });
  213. });
  214. it("passes through pptx sources and rejects non-pptx sources", () => {
  215. const pptxSource = {
  216. type: "pptx" as const,
  217. title: "slides.pptx",
  218. path: "/workspace/slides.pptx",
  219. };
  220. expect(resolvePreviewPanePptxSource(pptxSource)).toBe(pptxSource);
  221. expect(
  222. resolvePreviewPanePptxSource({
  223. type: "file",
  224. title: "legacy.ppt",
  225. path: "/workspace/legacy.ppt",
  226. }),
  227. ).toBeNull();
  228. expect(resolvePreviewPanePptxSource(null)).toBeNull();
  229. });
  230. it("only requests a missing-file toast for reference-driven PPTX navigation", () => {
  231. const missingError = Object.assign(new Error("missing"), { code: "ENOENT" });
  232. expect(
  233. shouldToastPptxReferenceFileMissing(
  234. {
  235. type: "pptx",
  236. title: "slides.pptx",
  237. path: "/workspace/slides.pptx",
  238. referenceNavigation: {
  239. requestId: "navigation-1",
  240. pageIndex: 2,
  241. expectedSourceFingerprint: `sha256:${"a".repeat(64)}`,
  242. },
  243. },
  244. missingError,
  245. ),
  246. ).toBe(true);
  247. expect(
  248. shouldToastPptxReferenceFileMissing(
  249. {
  250. type: "pptx",
  251. title: "slides.pptx",
  252. path: "/workspace/slides.pptx",
  253. },
  254. missingError,
  255. ),
  256. ).toBe(false);
  257. });
  258. it("hides the more menu for pptx previews", () => {
  259. expect(
  260. getPreviewPaneDisplayOptions({
  261. type: "file",
  262. title: "slides.pptx",
  263. path: "/workspace/slides.pptx",
  264. }).hasMoreMenu,
  265. ).toBe(false);
  266. expect(
  267. getPreviewPaneDisplayOptions({
  268. type: "pptx",
  269. title: "slides.pptx",
  270. path: "/workspace/slides.pptx",
  271. }).hasMoreMenu,
  272. ).toBe(false);
  273. });
  274. it("enforces the 64 MB PPTX preview source limit", () => {
  275. expect(isPptxPreviewFileTooLarge(64 * 1024 * 1024)).toBe(false);
  276. expect(isPptxPreviewFileTooLarge(64 * 1024 * 1024 + 1)).toBe(true);
  277. });
  278. it("keeps PPTX rendering lazy and uses DESIGN typography tokens", () => {
  279. const contentSource = readFileSync("packages/ui/src/previewPanePptxContent.tsx", "utf8");
  280. const viewerSource = readFileSync(
  281. "packages/ui/src/components/ui/pptx-preview-viewer.tsx",
  282. "utf8",
  283. );
  284. expect(contentSource).toContain("lazy(() =>");
  285. expect(viewerSource).toContain('import("@/presentation/pptxRendererPreviewEngine.js")');
  286. expect(viewerSource).toContain("IntersectionObserver");
  287. expect(viewerSource).not.toMatch(/\btext-(?:xs|sm|base|lg|xl)\b/);
  288. expect(viewerSource.match(/\bbg-surface\/30\b/g)).toHaveLength(2);
  289. });
  290. it("hides the more menu when a preview source has no display options", () => {
  291. expect(
  292. getPreviewPaneDisplayOptions({
  293. type: "image",
  294. title: "logo.png",
  295. path: "/workspace/logo.png",
  296. mediaType: "image/png",
  297. }).hasMoreMenu,
  298. ).toBe(false);
  299. expect(
  300. getPreviewPaneDisplayOptions({
  301. type: "patch",
  302. title: "changes.patch",
  303. patch: "diff --git a/a b/a",
  304. }).hasMoreMenu,
  305. ).toBe(false);
  306. expect(
  307. getPreviewPaneDisplayOptions({
  308. type: "multi-file-diff",
  309. title: "changes.patch",
  310. path: "/workspace/app.ts",
  311. beforeContent: "const value = 1;",
  312. afterContent: "const value = 2;",
  313. }).hasMoreMenu,
  314. ).toBe(false);
  315. expect(
  316. getPreviewPaneDisplayOptions({
  317. type: "file",
  318. title: "logo.png",
  319. path: "/workspace/logo.png",
  320. }).hasMoreMenu,
  321. ).toBe(false);
  322. expect(
  323. getPreviewPaneDisplayOptions({
  324. type: "file",
  325. title: "report.xlsx",
  326. path: "/workspace/report.xlsx",
  327. }).hasMoreMenu,
  328. ).toBe(false);
  329. expect(
  330. getPreviewPaneDisplayOptions({
  331. type: "file",
  332. title: "proposal.docx",
  333. path: "/workspace/proposal.docx",
  334. }).hasMoreMenu,
  335. ).toBe(false);
  336. expect(
  337. getPreviewPaneDisplayOptions({
  338. type: "file",
  339. title: "legacy.doc",
  340. path: "/workspace/legacy.doc",
  341. }).hasMoreMenu,
  342. ).toBe(false);
  343. });
  344. it("shows the more menu when a preview source has display options", () => {
  345. expect(
  346. getPreviewPaneDisplayOptions({
  347. type: "text",
  348. title: "README.md",
  349. path: "/workspace/README.md",
  350. content: "# Title",
  351. language: "markdown",
  352. }).hasMoreMenu,
  353. ).toBe(true);
  354. expect(
  355. getPreviewPaneDisplayOptions({
  356. type: "file",
  357. title: "logo.svg",
  358. path: "/workspace/logo.svg",
  359. }).hasMoreMenu,
  360. ).toBe(true);
  361. expect(
  362. getPreviewPaneDisplayOptions({
  363. type: "text",
  364. title: "index.ts",
  365. content: "export {};",
  366. language: "typescript",
  367. }).hasMoreMenu,
  368. ).toBe(true);
  369. });
  370. it("keeps code-review sources in code mode with only the wrap control", () => {
  371. const options = getPreviewPaneDisplayOptions({
  372. type: "code-review",
  373. title: "README.md",
  374. path: "/workspace/README.md",
  375. workspacePath: "/workspace",
  376. review: {
  377. requestId: "review-1",
  378. title: "Review title",
  379. body: "Review body",
  380. },
  381. });
  382. expect(options).toEqual({
  383. canToggleCodeWrap: true,
  384. canToggleMarkdownView: false,
  385. canToggleSvgView: false,
  386. hasMoreMenu: true,
  387. });
  388. });
  389. it("shows the wrap option after svg is switched to code mode", () => {
  390. const svgSource = {
  391. type: "file" as const,
  392. title: "logo.svg",
  393. path: "/workspace/logo.svg",
  394. };
  395. expect(
  396. getPreviewPaneDisplayOptions(svgSource, {
  397. svgViewMode: "preview",
  398. }).canToggleCodeWrap,
  399. ).toBe(false);
  400. expect(
  401. getPreviewPaneDisplayOptions(svgSource, {
  402. svgViewMode: "code",
  403. }).canToggleCodeWrap,
  404. ).toBe(true);
  405. });
  406. it("detects missing-file preview errors without depending on platform error objects", () => {
  407. expect(
  408. isPreviewPaneMissingFileError(
  409. new Error(
  410. "ENOENT: no such file or directory, stat 'D:\\CODE\\Demo_OCR\\OCR4-Ollama-Bundle\\paper.md'",
  411. ),
  412. ),
  413. ).toBe(true);
  414. expect(isPreviewPaneMissingFileError({ code: "ENOENT" })).toBe(true);
  415. expect(isPreviewPaneMissingFileError(new Error("permission denied"))).toBe(false);
  416. });
  417. it("detects the bounded binary preview size error for localized UI copy", () => {
  418. expect(
  419. isPreviewPaneFileTooLargeError(new Error("File is too large to preview: 26214401 bytes")),
  420. ).toBe(true);
  421. expect(isPreviewPaneFileTooLargeError(new Error("permission denied"))).toBe(false);
  422. });
  423. it("only treats truncated text as too large and preserves binary detection", () => {
  424. const truncatedText = {
  425. path: "/workspace/large.log",
  426. content: "partial",
  427. offset: 0,
  428. bytesRead: 256 * 1024,
  429. totalBytes: 256 * 1024 + 1,
  430. truncated: true,
  431. isBinary: false,
  432. };
  433. const truncatedBinary = {
  434. ...truncatedText,
  435. content: "",
  436. isBinary: true,
  437. };
  438. expect(resolvePreviewPaneTextFileResult(truncatedText)).toEqual({
  439. filePreview: null,
  440. fileTooLarge: true,
  441. });
  442. expect(resolvePreviewPaneTextFileResult(truncatedBinary)).toEqual({
  443. filePreview: truncatedBinary,
  444. fileTooLarge: false,
  445. });
  446. });
  447. it("maps the old remote PPTX 8 MB limit without exposing its absolute path", () => {
  448. const sourcePath = "/srv/private/customer/slides.pptx";
  449. const message = resolvePptxPreviewReadErrorMessage(
  450. new Error(`File is too large to preview: ${sourcePath}`),
  451. {
  452. sourcePath,
  453. fileMissingMessage: "missing",
  454. legacyFileTooLargeMessage: "legacy 8 MB limit",
  455. incompleteFileMessage: "incomplete",
  456. },
  457. );
  458. expect(message).toBe("legacy 8 MB limit");
  459. expect(message).not.toContain("/srv/private/customer");
  460. });
  461. it("keeps only the file name when another PPTX read error contains an absolute path", () => {
  462. expect(
  463. getPreviewPaneSafeErrorMessage(
  464. new Error("Permission denied: D:\\private\\customer\\slides.pptx"),
  465. "D:\\private\\customer\\slides.pptx",
  466. ),
  467. ).toBe("Permission denied: slides.pptx");
  468. });
  469. it("routes Office files through the bounded binary preview service", () => {
  470. const source = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  471. expect(source).toContain(".readBinaryPreview({ path: source.path })");
  472. expect(source).toMatch(/!imageSource\s*&&\s*!pdfSource\s*&&\s*!officePreviewKind/);
  473. });
  474. it("renders missing-file preview errors as tertiary helper text", () => {
  475. const missingFileMessage = "文件不存在,或当前环境无法访问该路径。";
  476. expect(getPreviewPaneErrorTextClass(missingFileMessage, missingFileMessage)).toBe(
  477. "text-foreground-subtlest",
  478. );
  479. expect(getPreviewPaneErrorTextClass("permission denied", missingFileMessage)).toBe(
  480. "text-destructive",
  481. );
  482. });
  483. it("reads scroll metrics from the real preview content scroller", async () => {
  484. const previewPaneModule = await import("@/PreviewPane.js");
  485. expect(typeof previewPaneModule.readPreviewPaneScrollMetrics).toBe("function");
  486. expect(
  487. previewPaneModule.readPreviewPaneScrollMetrics({
  488. scrollHeight: 2400,
  489. scrollTop: 720,
  490. }),
  491. ).toEqual({
  492. scrollHeight: 2400,
  493. scrollTop: 720,
  494. });
  495. });
  496. it("wires scroll memory through to the CodeViewer scroll container", () => {
  497. const previewPaneSource = readFileSync("packages/ui/src/PreviewPane.tsx", "utf8");
  498. const contentSource = readFileSync("packages/ui/src/previewPaneContent.tsx", "utf8");
  499. const codeContentSource = readFileSync("packages/ui/src/previewPaneCodeContent.tsx", "utf8");
  500. const codeViewerSource = readFileSync("packages/ui/src/components/ui/code-viewer.tsx", "utf8");
  501. expect(previewPaneSource).toContain("scrollContainerRef={scrollContainerRef}");
  502. expect(contentSource).toContain("scrollContainerRef?: Ref<HTMLDivElement>");
  503. expect(codeContentSource).toContain("scrollContainerRef?: Ref<HTMLDivElement>");
  504. expect(codeViewerSource).toContain("assignCodeViewerScrollContainerRef");
  505. });
  506. it("builds a normal file preview source from diff preview sources", () => {
  507. expect(
  508. createDiffSourceFilePreviewSource(
  509. {
  510. type: "multi-file-diff",
  511. title: "demo.ts",
  512. path: "/workspace/demo.ts",
  513. beforeContent: "const value = 1;",
  514. afterContent: "const value = 2;",
  515. workspaceIdentity: "ssh:test:/workspace",
  516. workspaceRemoteSessionId: "remote-1",
  517. },
  518. "/workspace",
  519. ),
  520. ).toEqual({
  521. type: "file",
  522. title: "demo.ts",
  523. path: "/workspace/demo.ts",
  524. workspacePath: "/workspace",
  525. workspaceIdentity: "ssh:test:/workspace",
  526. workspaceRemoteSessionId: "remote-1",
  527. });
  528. expect(
  529. createDiffSourceFilePreviewSource(
  530. {
  531. type: "patch",
  532. title: "Diff",
  533. patch: [
  534. "diff --git a/src/demo.ts b/src/demo.ts",
  535. "--- a/src/demo.ts",
  536. "+++ b/src/demo.ts",
  537. "@@ -1 +1 @@",
  538. "-old",
  539. "+new",
  540. ].join("\n"),
  541. },
  542. "/workspace",
  543. ),
  544. ).toEqual({
  545. type: "file",
  546. title: "demo.ts",
  547. path: "/workspace/src/demo.ts",
  548. workspacePath: "/workspace",
  549. });
  550. });
  551. it("uses deletion patch headers but refuses relative paths without workspace scope", () => {
  552. const deletionPatch = [
  553. "diff --git a/src/deleted.ts b/src/deleted.ts",
  554. "--- a/src/deleted.ts",
  555. "+++ /dev/null",
  556. "@@ -1 +0,0 @@",
  557. "-old",
  558. ].join("\n");
  559. expect(
  560. getDiffSourceFileTarget({
  561. type: "patch",
  562. title: "Diff",
  563. patch: deletionPatch,
  564. }),
  565. ).toBe("src/deleted.ts");
  566. expect(
  567. createDiffSourceFilePreviewSource({
  568. type: "patch",
  569. title: "Diff",
  570. patch: deletionPatch,
  571. }),
  572. ).toBeNull();
  573. });
  574. });